Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MiqRegion#remote_*_url returning invalid URL on podified #22668

Merged
merged 2 commits into from
Aug 22, 2023

Conversation

agrare
Copy link
Member

@agrare agrare commented Aug 17, 2023

On appliances the remote_ui_url/remote_ws_url methods find an active MiqServer and use that server's hostname/ipaddress to build a URL for access.

On podified the hostname is the name of the orchestrator pod which isn't usable to be able to access the UI.

We have the proper hostname to access the httpd route in the APPLICATION_DOMAIN env var, use that if we are on podified.

Move the bulk of the logic into MiqServer
Comment on lines 191 to 197
def remote_ui_ipaddress
server = remote_ui_miq_server
server.try(:ipaddress)
remote_ui_miq_server&.ui_ipaddress
end

def remote_ui_hostname
server = remote_ui_miq_server
server && (server.hostname || server.ipaddress)
remote_ui_miq_server&.ui_hostname
end
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE these methods don't appear to be used outside of the remote_*_address/url methods but since they aren't private I don't want to remove them especially for something we might backport.

remote_ui_ipaddress, remote_ui_hostname, remote_ws_ipaddress, remote_ws_hostname

@agrare agrare force-pushed the remote_ui_ws_address_podified branch from 3623d1c to 458338c Compare August 17, 2023 17:04
@miq-bot
Copy link
Member

miq-bot commented Aug 17, 2023

Checked commits agrare/manageiq@11bc6ae~...458338c with ruby 2.6.10, rubocop 1.28.2, haml-lint 0.35.0, and yamllint
3 files checked, 0 offenses detected
Everything looks fine. ⭐

Comment on lines +424 to +428
if MiqEnvironment::Command.is_podified?
ENV.fetch("APPLICATION_DOMAIN")
else
contact_with == :hostname ? ui_hostname : ui_ipaddress
end
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE it is a bit of duplication to check for is_podified? in both these methods and in ui_address, but with the contact_with == :hostname and ::Settings.webservices.contactwith == 'hostname' checks it seemed cleaner than trying to deal with contact_with = :ipaddress but that returning nil on podified.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is it probably belongs in the kubernetes module for the MiqServer::WorkerManagement but we include kubernetes, process, or systemd regardless of the type of server we're running. I guess this is the only thing you can do.

There are these methods in worker_management though, although the interface is ugly from here: server.worker_manager.class.podified?

It feels like the worker_manager should know this answer for what type it is and cache the result. Alas, this code is fine for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(it would have been nice to just override this method in kubernetes.rb but we include these modules regardless of what type of manager we are)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I didn't think that WorkerManagement was the right place for this since it is more appliance-level but I agree it would be much cleaner to have a k8s subclass for this. Maybe we do a similar model for EnvironmentManagement (aka convert from simple module to a class then have systemd/kubernetes subclasses)?

@kbrock kbrock merged commit f6b1d9b into ManageIQ:master Aug 22, 2023
9 checks passed
@kbrock kbrock self-assigned this Aug 22, 2023
@agrare agrare deleted the remote_ui_ws_address_podified branch August 22, 2023 13:20
@Fryguy
Copy link
Member

Fryguy commented Aug 30, 2023

Backported to quinteros in commit 9e44bb2.

commit 9e44bb2c6bdecc2435783772f757def54bce4b3b
Author: Keenan Brock <[email protected]>
Date:   Tue Aug 22 09:19:59 2023 -0400

    Merge pull request #22668 from agrare/remote_ui_ws_address_podified
    
    Fix MiqRegion#remote_*_url returning invalid URL on podified
    
    (cherry picked from commit f6b1d9b418bcce437065bf1fec7af016c133ad10)

Fryguy pushed a commit that referenced this pull request Aug 30, 2023
Fix MiqRegion#remote_*_url returning invalid URL on podified

(cherry picked from commit f6b1d9b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants