Repository navigation
Open
Labels
area/APIAPI objects and controllerskind/cleanupCategorizes issue or PR as related to cleaning up code, process, or technical debt.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.triage/acceptedIssues which should be fixed (post-triage)
Milestone
Description
Not all of our conditions follow our condition conventions.
We also don't propagate conditions in a consistent (or even correct) way: #4937
I'm opening this to track some work around wrangling our conditions.
- Resources that reconcile child resources should have a condition for each child that reflects the child's top-level "happy state" (TLHS) condition.
- This makes it easy to propagate conditions from our children.
- A resource's own TLHS condition should depend on those child conditions via ConditionSets.
- This makes it easy to propagate conditions to our parent.
- We should always update a resource's observed generation to indicate that we've attempted to reconcile its spec.
- This allows our parent to know if our status is up to date.
- If the observed generation of a child resource does not match its current generation, we should mark it as NotReconciled since its state does not yet reflect its spec yet.
- This ensures we don’t reflect stale child statuses.
- This might not make sense in some cases (e.g. a Revision reconciling a Deployment would flip back and forth between Ready and Unknown, given that the KPA will be constantly bumping the Deployment's Generation).
- If there is an non-terminal error during reconciliation, Ready should become unknown.
- This ensures we aren’t prematurely Ready and that we aren’t swallowing errors.
- If the observed generation does match, and we did not encounter an error, we should propagate the child’s TLHS condition into our own.
- This is the happy path.
In general, everything should look something like this:

Here's (a bit simplified) Service as an example. Service is pretty close to correct, but it's not unconditionally bumping ObservedGeneration or updating its status with reconciliation errors (bolded things aren't correct (yet)):

We'll also need to rework the Revision and KPA and SKS conditions to fit better into this world, since they're all over the place.
TODO
- Consistently update
ObservedGeneration - Surface reconciliation errors in conditions.
- Modify conditions to be in terms of child resources.
- Consistently propagate child conditions.
- Attempt to refactor/code-gen this stuff so we don't regress.
- Update sample-controller with parent->child best practices.
/area API
Reacted by Jean-Rémy Bancel, Zhimin Xiang, Chi Zhang and Kenjiro Nakayama
Metadata
Metadata
Assignees
Labels
area/APIAPI objects and controllerskind/cleanupCategorizes issue or PR as related to cleaning up code, process, or technical debt.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.triage/acceptedIssues which should be fixed (post-triage)
Type
Projects
- StatusShow more project fieldsReady To Work
Activity
markusthoemmes commentedon Aug 7, 2019
Thanks for the writeup @jonjohnsonjr. That makes a lot of sense to me!
jonjohnsonjr commentedon Aug 7, 2019
@JRBANCEL pointed out some more inconsistencies in our lifecycle Mark* methods:
The naming is inconsistent: NotReady means Unknown, other times NotReady means failed. It's not clear from the method name what state you're actually setting.
For simple methods that just set the state I'd propose following this pattern, since it's most prevalent:
MarkFooReady -> Ready=True
MarkFooNotReady -> Ready=Unknown
MarkFooFailed -> Ready=False
There are a lot of convenience methods to make setting certain statuses more legible, we should probably leave those alone for now.
ZhiminXiang commentedon Sep 9, 2019
We also need
MarkFooNotOwnedfor the case where Foo resource is not owned by the parent resource, andMarkFooNotReconciledfor the case wheregeneration != observedGeneration. We probably want to add these two functions into our standard.nimakaviani commentedon Oct 16, 2019
@dgerd opened an issue and a proposal (#5780) on how to deal with condition types and marking resource status. PR #5804 already implements that proposal for revision lifecycle and I plan to continue the refactoring for other resource status markers as well.
nimakaviani commentedon Oct 16, 2019
also this #5804 (comment) for cross referencing.
dgerd commentedon Dec 2, 2019
As part of #4937 I took a look at our current reconciler loops and put together a few state machines to help visualize the potential condition sets you can end up with. A few thoughts about them:
controllers should report the most recent generation seen in status when they post status. From our API specification we state:The latest metadata.generation that the reconciler has observed. If observedGeneration is updated, conditions MUST be updated with current status in the same transaction.If we make all reconciler exits post status this would allow us to just bump observedGeneration from the controller framework at the beginning of the reconcile loop. The current state of the world is:I haven put together a Revision reconciler state machine yet, but here are the Service, Route, and Config ones.
KService Reconciler
Route Reconciler
Configuration Reconciler
knative-housekeeping-robot commentedon Mar 2, 2020
Issues go stale after 90 days of inactivity.
Mark the issue as fresh by adding the comment
/remove-lifecycle stale.Stale issues rot after an additional 30 days of inactivity and eventually close.
If this issue is safe to close now please do so by adding the comment
/close.Send feedback to Knative Productivity Slack channel or file an issue in knative/test-infra.
/lifecycle stale
knative-housekeeping-robot commentedon Apr 1, 2020
Stale issues rot after 30 days of inactivity.
Mark the issue as fresh by adding the comment
/remove-lifecycle rotten.Rotten issues close after an additional 30 days of inactivity.
If this issue is safe to close now please do so by adding the comment
/close.Send feedback to Knative Productivity Slack channel or file an issue in knative/test-infra.
/lifecycle rotten
knative-housekeeping-robot commentedon May 1, 2020
Rotten issues close after 30 days of inactivity.
Reopen the issue with
/reopen.Mark the issue as fresh by adding the comment
/remove-lifecycle rotten.Send feedback to Knative Productivity Slack channel or file an issue in knative/test-infra.
/close
33 remaining items