Standardize True/False/Unknown status throughout eventing#2341
Conversation
|
This PR is much too large. I would recommend splitting it into one PR per resource. |
|
/hold |
grantr
left a comment
There was a problem hiding this comment.
First batch of comments. Thanks @capri-xiyue for doing this consistency work!
| if bc := brokerCondSet.Manage(bs).GetCondition(BrokerConditionReady); bc != nil { | ||
| msg = bc.Message | ||
| } | ||
| if bs.IsUnknown() { |
There was a problem hiding this comment.
If both IsReady() and IsUnknown() return false, is it guaranteed that IsFalse will return true? Or do the status conventions define False as !Ready && !Unknown?
Put another way, I'm wondering what we should do if IsReady, IsUnknown, and IsFalse all return false. Maybe that never happens?
There was a problem hiding this comment.
I added the logic that mark the Broker unknown when the status is invalid (the status is not one of Unknown,False, True)
| } else if test.dependencyStatus == corev1.ConditionUnknown { | ||
| ts.MarkDependencyUnknown("The status of dependency is unknown", "The status of dependency is unknown: nil") | ||
| } else { | ||
| ts.MarkDependencyFailed("The status of dependency is false", "The status of dependency is unknown: nil") |
There was a problem hiding this comment.
Is this last parameter supposed to say unknown or false?
There was a problem hiding this comment.
Yep. The convention of the codebase is to use "Failed" instead of "False"
There was a problem hiding this comment.
That is only for batch type resources.
There was a problem hiding this comment.
What is the definition of "batch type resource"? I checked the codebase, for example https://github.com/knative/eventing/blob/master/pkg/apis/eventing/v1alpha1/broker_lifecycle.go, it use MarkXXXXFailed for TriggerChannel, Ingress and Filter.
There was a problem hiding this comment.
Think of it as 'run to completion', once you create a managed condition set, you either create a "living" or "batch". Living means it has a Top Level Condition that is Ready (True, False, or Unknown), creating a Batch means it has a Top Level Condition that is Succeeded (True, False, or Unknown). I think Batch is a poor name but I think it comes from there since k8s Batch resources have this condition for them.
There was a problem hiding this comment.
I checked k8s docs, https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/ is an example of batch type resources, right? In knative eventing, is there any resources that belongs to batch type resources. It looks like we should create another issue to fix this. I checked the code, knative eventing uses MarkXXXFailed for all resources even they belongs to "living".
| } | ||
|
|
||
| // GetTopLevelCondition returns the top level Condition. | ||
| func (bs *BrokerStatus) GetTopLevelCondition() *apis.Condition { |
There was a problem hiding this comment.
This change needs to happen in Serving, Sample-Source and Sample-Controller now too right?
There was a problem hiding this comment.
Yep. I think this change needs to happen in Serving and Sample-Source. But it won't break anything if people don't use it now. People can also use GetCondition(t apis.ConditionType) to get the top level condition. GetTopLevelCondition just provides a more convenient way to achieve it. What do you mean by "Sample-Controller"(The controller for reconcile)?
| } else { | ||
| msg := bc.Message | ||
| if bc.IsUnknown() { | ||
| et.MarkBrokerUnknown("BrokerUnknown", "The status of Broker is Unknown: %s", msg) |
There was a problem hiding this comment.
I think you can just use the condition directly to propagate: https://github.com/knative/serving/blob/ec457adcb1466abfcbc1c0a069e60285e769d135/pkg/apis/serving/v1alpha1/route_lifecycle.go#L157-L171
The current way is dropping the real reason and messages so it makes it hard to use.
| msg := "nil" | ||
| if bc := brokerCondSet.Manage(bs).GetCondition(BrokerConditionReady); bc != nil { | ||
| msg = bc.Message | ||
| msg := bc.Message |
There was a problem hiding this comment.
| } else if test.dependencyStatus == corev1.ConditionUnknown { | ||
| ts.MarkDependencyUnknown("The status of dependency is unknown", "The status of dependency is unknown: nil") | ||
| } else { | ||
| ts.MarkDependencyFailed("The status of dependency is false", "The status of dependency is unknown: nil") |
There was a problem hiding this comment.
That is only for batch type resources.
| // subCondSet is a condition set with Ready as the happy condition and | ||
| // ReferencesResolved and ChannelReady as the dependent conditions. | ||
| var subCondSet = apis.NewLivingConditionSet(SubscriptionConditionReferencesResolved, SubscriptionConditionAddedToChannel, SubscriptionConditionChannelReady) | ||
| var SubCondSet = apis.NewLivingConditionSet(SubscriptionConditionReferencesResolved, SubscriptionConditionAddedToChannel, SubscriptionConditionChannelReady) |
There was a problem hiding this comment.
do you want to export this?
There was a problem hiding this comment.
For this
, I will need SubCondSet to get top level condition. Is there any disadvantage to export this?There was a problem hiding this comment.
something could edit it and do unexpected things
|
/unhold |
|
The following is the coverage report on the affected files.
|
|
Thanks for the cleanup and using the case statements. Looks real nice! /lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: capri-xiyue, n3wscott The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes #2187
Proposed Changes
Release Note