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 #36776 - Fixed issue where composite content views promoted to … #10752

Merged
merged 1 commit into from
Oct 2, 2023

Conversation

qcjames53
Copy link
Contributor

@qcjames53 qcjames53 commented Sep 25, 2023

…lifecycle environments referencing the env name would error on promotion.

Changed env replacement source.

What are the changes introduced in this pull request?

Composite content views containing archived repositories have their environment set to nil. When promoting this CVV to a lifecycle environment with a registry name containing the lifecycle environment's name, this would previously cause the action to error out. After the changes, if the env is unset, Katello will use a different naming schema to name containers. This should only impact archived repositories.

Considerations taken when implementing this change?

I reworked a little logic in app/models/katello/repository.rb. There is a truth table in the comments which shows the decisions taken.

What are the testing steps for this pull request?

  1. Create a product:
hammer product create --description "Product Busybox Container" --name Product_Busybox_Container --label "Product_Busybox_Container" --organization myorg
  1. Create a repository and sync it:
hammer repository create \
  --content-type "docker" \
  --organization myorg \
  --product "Product_Busybox_Container" \
  --url "https://registry-1.docker.io/" \
  --name "library/busybox" \
  --docker-upstream-name "library/busybox" \
  --label "library_busybox" \
  --include-tags "stable, 1.35.0"
hammer repository synchronize --name "library/busybox" --product "Product_Busybox_Container" --organization myorg
  1. Create a content view with this repo and publish it:
hammer content-view create --label ContentView_Busybox --name ContentView_Busybox --organization-label myorg --repository-ids <repo_id>
hammer content-view publish --organization myorg --name ContentView_Busybox
  1. Using the UI, go to Content -> Lifecycle -> Content Views. Create a content view of type composite content view. I left auto-publish unchecked.
  2. Once created, add the ContentView_Busybox CV to this composite CV.
  3. Go to Content -> Lifecycle -> Lifecycle Environments. Create an environment path. Click on the newly-created environment path. On the details tab, modify the registry name pattern to <%= repository.name %>.
  4. Create another environment path. Set its registry name pattern to <%= lifecycle_environment.label %>/<%= repository.name %>
  5. Go to Content -> Lifecycle -> Content Views. Click on the kebab menu next to your composite content view and select promote. Select the first lifecycle environment and publish. There should be no errors because the environment isn't being referenced.
  6. Refresh the page. Click on the kebab menu next to your composite content view and select promote. Select the second lifecycle environment and publish. This PR should not error out either.
  7. Using Katello console, you should be able to inspect the names of the promoted containers. They should not follow the environment pattern but should instead follow the default schema.

@theforeman-bot
Copy link

Issues: #36776

@ianballou
Copy link
Member

After the changes, if the env is unset, Katello will grab a valid environment from the first non-archived repository in the repository's content view.

I haven't fully looked through the code yet, but I don't think the special registry naming scheme should even apply to archived repositories. The archived repositories shouldn't be exposed to users besides for debugging. While I'm guessing this stops the error, the env picked likely doesn't match the repository.

Could we instead stop using the special naming scheme for archived repositories? Perhaps just ignore the registry naming pattern?

@qcjames53 qcjames53 force-pushed the 36776 branch 2 times, most recently from 9577664 to ecb1d4f Compare September 26, 2023 15:06
@qcjames53
Copy link
Contributor Author

After the changes, if the env is unset, Katello will grab a valid environment from the first non-archived repository in the repository's content view.

I haven't fully looked through the code yet, but I don't think the special registry naming scheme should even apply to archived repositories. The archived repositories shouldn't be exposed to users besides for debugging. While I'm guessing this stops the error, the env picked likely doesn't match the repository.

Could we instead stop using the special naming scheme for archived repositories? Perhaps just ignore the registry naming pattern?

I implemented the suggestions we talked about in our PM, meaning if the environment does not exist (as in archived repos), render the name as if a pattern is not provided. I reworked the logic a little to make it easier to understand and added a big table in the documentation to explain everything.

Copy link
Member

@ianballou ianballou left a comment

Choose a reason for hiding this comment

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

I haven't tested it, but the logic looks solid to me! Thanks for the table.

app/models/katello/repository.rb Outdated Show resolved Hide resolved
app/models/katello/repository.rb Outdated Show resolved Hide resolved
@qcjames53 qcjames53 force-pushed the 36776 branch 3 times, most recently from cbc68e0 to 81ae607 Compare September 27, 2023 14:43
Copy link
Member

@ianballou ianballou left a comment

Choose a reason for hiding this comment

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

Functionality-wise it works like a charm

@qcjames53 qcjames53 force-pushed the 36776 branch 2 times, most recently from 2ddbfa2 to b44a866 Compare September 29, 2023 14:33
…lifecycle environments referencing the env name would error on promotion.

Changed env replacement source.

Force pushing to rerun tests.

Rubocop fixes

Changed several factors for how the container name is rendered. Documented thought process.

Fixed existing unit test to test on new naming schema instead of testing for overlap with a poor env pattern.

Rubocop fixes

Added test to check for docker repo container name overlap.

Modified documentation to rerun tests.

Rubocop fixes
Copy link
Member

@ianballou ianballou left a comment

Choose a reason for hiding this comment

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

Ship it!

@qcjames53 qcjames53 merged commit 173b904 into Katello:master Oct 2, 2023
@qcjames53 qcjames53 deleted the 36776 branch October 2, 2023 14:09
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.

3 participants