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

Support empty rhsm_url setting on proxies #11328

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ekohl
Copy link
Member

@ekohl ekohl commented Mar 3, 2025

What are the changes introduced in this pull request?

This drops the compatibility fallbacks that were in place for pre-3.1
installations. Since then the value has been present.

Now it becomes possible to not set a value which means the RHSM URL is
on the Foreman instance itself. This is useful for Pulp-only
installations without any RHSM reverse proxy setup.

Considerations taken when implementing this change?

We don't care about pre-Foreman 3.1 installations and this is long term to support the use of standa lone Pulp proxies via https://github.com/evgeni/pulp_smart_proxy.

For now this is a draft because I'm looking for feedback if this is a good idea at all.

What are the testing steps for this pull request?

There are unit tests (which I don't think will pass). It also doesn't cover the nil vs empty string, which should be handled via .presence.

# Since Foreman 3.1 this setting is set. No value means direct use
if (rhsm_url_setting = setting(SmartProxy::PULP3_FEATURE, 'rhsm_url').presence)
URI(rhsm_url_setting)
else
URI(rhsm_url)
Copy link
Member

Choose a reason for hiding this comment

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

Isn't that recursive now?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it is. I hate Rails' URL helpers

Copy link
Member

Choose a reason for hiding this comment

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

Sure, but where should rhsm_url come from even w/o Rails?
I think the following should work?

def rhsm_url
  if (rhsm_url_setting = setting(SmartProxy::PULP3_FEATURE, 'rhsm_url').presence)
    URI(rhsm_url_setting)
  else
    URI("https://#{URI.parse(url).host}/rhsm")
  end
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.

Rails itself should be able to look up the route and generate the url. The whole change here is also that it's the Foreman URL now, not on the proxy. Essentially making it opt in whether there is a reverse proxy for RHSM

Copy link
Member Author

Choose a reason for hiding this comment

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

I ended up using the foreman_url setting and hardcode the path instead of figuring out the URL helpers. They don't appear to be included in the helper and passing in context is going to be too hard (and possibly wrong).

This drops the compatibility fallbacks that were in place for pre-3.1
installations. Since then the value has been present.

Now it becomes possible to not set a value which means the RHSM URL is
on the Foreman instance itself. This is useful for Pulp-only
installations without any RHSM reverse proxy setup.
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.

2 participants