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

Fixes #38270 - Don't create content view environment when CV is not published to LCE #11338

Merged
merged 3 commits into from
Mar 27, 2025

Conversation

jeremylenz
Copy link
Member

@jeremylenz jeremylenz commented Mar 5, 2025

What are the changes introduced in this pull request?

Previously Katello would create a Katello::ContentViewEnvironment when creating a host, if none existed with that combination of cv/lce. The problem is that creating one without the corresponding Pulp content being hosted (e.g. publishing/promoting the content view to the LCE) will break things.

Considerations taken when implementing this change?

The UI already guards against this, so I think this fix is mainly for Robottelo.

What are the testing steps for this pull request?

Try hammer host create with --lifecycle-environment-id and --content-view-id options

With a valid combination (published/promoted CV), it should work.
With an invalid combination, you should get one of the new error messages (see the code).

@jeremylenz jeremylenz force-pushed the 38270-no-first-or-create-silly branch from a4c74d0 to 6ab8066 Compare March 5, 2025 21:30
@jeremylenz
Copy link
Member Author

Requires theforeman/hammer-cli-foreman#638 to see the hammer error.

@qcjames53
Copy link
Contributor

I have confirmed that this is working as intended for both a valid and invalid combination of CV and LE. I need to investigate the test failures before acking, however.

Comment on lines 171 to 173
cv_name = ::Katello::ContentView.find_by(:id => content_view_id)&.name
fail ::Katello::Errors::ContentViewEnvironmentError, _("Unable to find a content view with ID %s") % content_view_id if cv_name.nil?
env_name = ::Katello::KTEnvironment.find_by(:id => lifecycle_environment_id)&.name
Copy link
Member Author

Choose a reason for hiding this comment

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

@jeremylenz Shouldn't these use labels and not names?

Copy link
Member Author

Choose a reason for hiding this comment

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

Great catch! updated

Copy link
Contributor

Choose a reason for hiding this comment

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

Labels now render instead of names:

Could not create the host:
  Cannot assign content view environment RHEL_9_LE/Default_Organization_View: The content view has either not been published or has not been promoted to that lifecycle environment.

@jeremylenz jeremylenz force-pushed the 38270-no-first-or-create-silly branch from 4943f41 to 62721a5 Compare March 21, 2025 14:41
Copy link
Contributor

@qcjames53 qcjames53 left a comment

Choose a reason for hiding this comment

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

Ignoring the failing React tests due to us waiting on Patternfly 5, everything looks great! I was able to confirm the error renders properly with the related hammer PR and we're no longer creating new CVEs. The source looks good to me so I'm ACKing!

@jeremylenz jeremylenz force-pushed the 38270-no-first-or-create-silly branch from 62721a5 to 55843a2 Compare March 26, 2025 13:44
@jeremylenz
Copy link
Member Author

Rebased

@jeremylenz
Copy link
Member Author

Ruby test failures are related! looking

@jeremylenz jeremylenz force-pushed the 38270-no-first-or-create-silly branch from 55843a2 to d762594 Compare March 26, 2025 17:03
@jeremylenz
Copy link
Member Author

updated tests

@jeremylenz jeremylenz merged commit 1c02a47 into Katello:master Mar 27, 2025
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants