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 #36690 - Validate *all* products before saving to sync plans #10703

Merged
merged 1 commit into from
Sep 8, 2023

Conversation

sjha4
Copy link
Member

@sjha4 sjha4 commented Aug 21, 2023

What are the changes introduced in this pull request?

Adds a validate_and_update_products method to sync plans which runs a complete validation of all products of sync plan to remove any possible invalid products left around due to errors in product deletion/repository disable actions etc for any reason.

Considerations taken when implementing this change?

What are the testing steps for this pull request?

To test, you'll have to create invalid data to reproduce the error. To do so, you'll need to disable a validation on sync plans model.

  1. Comment out the line validate :product_enabled like #validate :product_enabled
  2. Restart the server.
  3. Make sure your org has a valid subscription and create a sync plan (Menu > Content> Sync Plans) to run the following steps on.
    4.In foreman-rake console:
    Do this:
sync_plan = Katello::SyncPlan.first
sync_plan.product_ids = [1,2,3,4]
sync_plan.save!
  1. Uncomment the #validate :product_enabled like validate :product_enabled
  2. Restart server
  3. Try enabling a couple redhat products (Content > Redhat repositories > Enable some random products, don't have to sync or anything) and adding them to the sync plan above.
  4. See the error on master branch.
  5. With changes above, you should be able to correct the sync plan and see messages in foreman log when sync plan is updated.

@theforeman-bot
Copy link

Issues: #36690

@sjha4
Copy link
Member Author

sjha4 commented Aug 28, 2023

[test katello]

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.

Hi Samir!

I was able to confirm the changes work as advertised for a variety of scenarios with enabled and disabled products. It all seems very robust. Outside of a couple questions, this looks great to me.

app/models/katello/sync_plan.rb Outdated Show resolved Hide resolved
app/controllers/katello/api/v2/sync_plans_controller.rb Outdated Show resolved Hide resolved
app/models/katello/sync_plan.rb Show resolved Hide resolved
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.

The changes look great to me. Ack'ed :)

@sjha4 sjha4 merged commit 68294f2 into Katello:master Sep 8, 2023
5 checks passed
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.

3 participants