Skip to content

Standardize True/False/Unknown status throughout eventing#2341

Merged
knative-prow-robot merged 6 commits into
knative:masterfrom
capri-xiyue:issue_2187
Jan 6, 2020
Merged

Standardize True/False/Unknown status throughout eventing#2341
knative-prow-robot merged 6 commits into
knative:masterfrom
capri-xiyue:issue_2187

Conversation

@capri-xiyue
Copy link
Copy Markdown
Contributor

Fixes #2187

Proposed Changes

  • Standardize True/False/Unknown status throughout eventing by following these rules
  1. when the dependency exists, then the dependant status should be the dependency Ready status.
  2. when the dependency readiness cannot be established (the dependant couldn't get the dependency for various reason), the status should be Unknown
  3. when the dependency does not exist, the status should be False.

Release Note


@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Dec 26, 2019
@knative-prow-robot knative-prow-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Dec 26, 2019
@capri-xiyue capri-xiyue changed the title [WIPStandardize True/False/Unknown status throughout eventing [WIP]Standardize True/False/Unknown status throughout eventing Dec 26, 2019
@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 26, 2019
Comment thread Gopkg.toml Outdated
@capri-xiyue capri-xiyue assigned grantr and unassigned grantr Dec 26, 2019
Comment thread pkg/apis/eventing/v1alpha1/eventtype_lifecycle.go Outdated
Comment thread pkg/apis/eventing/v1alpha1/trigger_lifecycle.go Outdated
Comment thread pkg/apis/eventing/v1alpha1/trigger_lifecycle.go Outdated
Comment thread pkg/apis/eventing/v1alpha1/trigger_lifecycle.go Outdated
@n3wscott
Copy link
Copy Markdown
Contributor

This PR is much too large. I would recommend splitting it into one PR per resource.

@capri-xiyue capri-xiyue changed the title [WIP]Standardize True/False/Unknown status throughout eventing Standardize True/False/Unknown status throughout eventing Dec 27, 2019
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 27, 2019
@capri-xiyue
Copy link
Copy Markdown
Contributor Author

/hold

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 27, 2019
Copy link
Copy Markdown
Contributor

@grantr grantr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First batch of comments. Thanks @capri-xiyue for doing this consistency work!

Comment thread Gopkg.toml Outdated
Comment thread pkg/apis/eventing/v1alpha1/eventtype_lifecycle.go Outdated
if bc := brokerCondSet.Manage(bs).GetCondition(BrokerConditionReady); bc != nil {
msg = bc.Message
}
if bs.IsUnknown() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the logic that mark the Broker unknown when the status is invalid (the status is not one of Unknown,False, True)

Comment thread pkg/apis/eventing/v1alpha1/test_helper.go Outdated
Comment thread pkg/apis/eventing/v1alpha1/trigger_lifecycle.go Outdated
} 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")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this last parameter supposed to say unknown or false?

Copy link
Copy Markdown
Contributor Author

@capri-xiyue capri-xiyue Jan 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. The convention of the codebase is to use "Failed" instead of "False"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is only for batch type resources.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

Comment thread pkg/apis/messaging/v1alpha1/subscription_lifecycle.go Outdated
Comment thread pkg/apis/messaging/v1alpha1/subscription_lifecycle.go Outdated
Comment thread pkg/reconciler/inmemorychannel/controller/inmemorychannel_test.go
Comment thread pkg/reconciler/subscription/subscription.go Outdated
@knative-prow-robot knative-prow-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 6, 2020
@knative-prow-robot knative-prow-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 6, 2020
}

// GetTopLevelCondition returns the top level Condition.
func (bs *BrokerStatus) GetTopLevelCondition() *apis.Condition {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change needs to happen in Serving, Sample-Source and Sample-Controller now too right?

Copy link
Copy Markdown
Contributor Author

@capri-xiyue capri-xiyue Jan 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread pkg/apis/eventing/v1alpha1/trigger_lifecycle.go Outdated
Comment thread pkg/apis/eventing/v1alpha1/trigger_lifecycle.go Outdated
} 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")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is only for batch type resources.

Comment thread pkg/apis/messaging/v1alpha1/channel_lifecycle.go
// 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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you want to export this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this

sc := messagingv1alpha1.SubCondSet.Manage(ss).GetTopLevelCondition()
, I will need SubCondSet to get top level condition. Is there any disadvantage to export this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something could edit it and do unexpected things

@capri-xiyue
Copy link
Copy Markdown
Contributor Author

/unhold

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 6, 2020
@knative-metrics-robot
Copy link
Copy Markdown

The following is the coverage report on the affected files.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/eventing/v1alpha1/broker_lifecycle.go 100.0% 95.8% -4.2
pkg/apis/eventing/v1alpha1/eventtype_lifecycle.go 100.0% 65.0% -35.0
pkg/apis/eventing/v1alpha1/test_helper.go 82.4% 79.5% -2.8
pkg/apis/eventing/v1alpha1/trigger_lifecycle.go 67.7% 51.1% -16.6
pkg/apis/legacysources/v1alpha1/apiserver_lifecycle.go 55.0% 60.0% 5.0
pkg/apis/messaging/v1alpha1/channel_lifecycle.go 100.0% 89.3% -10.7
pkg/apis/messaging/v1alpha1/in_memory_channel_lifecycle.go 100.0% 80.6% -19.4
pkg/apis/messaging/v1alpha1/subscription_lifecycle.go 100.0% 84.6% -15.4
pkg/reconciler/eventtype/eventtype.go 87.0% 83.0% -4.0
pkg/reconciler/inmemorychannel/controller/inmemorychannel.go 81.1% 79.8% -1.3
pkg/reconciler/subscription/subscription.go 78.8% 77.9% -0.8

@n3wscott
Copy link
Copy Markdown
Contributor

n3wscott commented Jan 6, 2020

Thanks for the cleanup and using the case statements. Looks real nice!

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 6, 2020
@knative-prow-robot
Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 6, 2020
@knative-prow-robot knative-prow-robot merged commit b1ced4e into knative:master Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standardize True/False/Unknown status throughout eventing

7 participants