Repository navigation
Conversation
object.LastSpecUpdated() rewrites lastApliedSpec, but it needs to be saved only after successful reconciliation
db05053 to
2d5341f
Compare
There was a problem hiding this comment.
All reported issues were addressed
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
| } | ||
| specChanged := object.LastSpecUpdated() | ||
| // keep previous lastAppliedSpec until success, next reconcile diffs against it to clean up | ||
| specChanged := object.DeepCopy().LastSpecUpdated() |
There was a problem hiding this comment.
The alternative is to have GetLastSpecUpdated and SetLastSpecUpdated, which would be cleaner, but more invasive
Haleygo
left a comment
There was a problem hiding this comment.
From what I can see, the persisting lastAplliedSpec asap was introduced on purpose in 471f183:
Previously, operator update lastAppliedSpec only when object was successfully reconciled.
It made impossible to properly detect changes between prev and current object state. And diff was calculated incorrectly.
Since operator executes Update requests only on object diff, failed changes cannot be removed and rollback was not possible.
But the code seems to have changed since then: spec updates now diff desired against live and no longer depend on prev. The only remaining use of prev is the 3-way merge of labels and annotations, where a key is removed only if prev has it and the new spec doesn't. So the trade-off is limited to metadata:
| Case | Old: stored before reconcile | New: stored after success |
|---|---|---|
| A → B fails → fixed or retried | A's dropped labels and annotations remain indefinitely ❌ | Removed ✅ |
| A → B fails partway → reverted to A | B's partially applied labels and annotations are removed ✅ | Remain ❌ |
I'm OK with changing the behavior, since case 1 seems to be the more common path: a failed change usually gets fixed forward.
Please add the detailed reason for this change to the description so the context is complete to track.
cc @f41gh7 in case you have other reason for the current behavior.
|
There is no good way to fix. Both options have own problems. And yes, changes seems to be always go forward. Currently, if update process interrupted in a middle, if it will continue from the last successful step. For example, if there is a condition like - In opposite, rollback of the changes could potentially fail, if it's interrupted. But with explicit |
Describe your changes
object.LastSpecUpdated()rewriteslastApliedSpec, but it needs to be saved only after successful reconciliation. When reconcile fails the object spec would be saved unconditionally and later reconcile attempts would not, for example, remove extra labels etc.Checklist
## tip.e2e tests
e2e tests don't run on every push. Comment
/run-e2eon this pull request to run them,or to run them again after new commits.
See CONTRIBUTING.md for details.