Fixes #37820 - If a smart proxy sync task fails in plan, we don't report it in sync status #11142
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What are the changes introduced in this pull request?
By default, plan phase and finalize phase in actions are wrapped in a single transaction. Any error in these phases rolls back all DB changes during the phase.
One of those changes is a link record to the task that links the resource (smart proxy in this action) and the task so we can query the tasks back using for_resource helper like here:
katello/app/models/katello/concerns/smart_proxy_extensions.rb
Line 460 in 746bda7
The issue is when the action fails during the plan phase the link record is deleted as part of the transaction rollback.
Considerations taken when implementing this change?
We can turn the transaction middleware off for an action. Doing this for smart proxy sync means that any DB changes made during a failed plan/finalize phase will persist.
Looking at the capsule sync task, the only DB op we do in finalize is around audit records. We should be able to live without having it wrapped in a transaction.
What are the testing steps for this pull request?