Skip to content

Create a common method for processing reconciliation on generic KRShaped#1284

Merged
knative-prow-robot merged 31 commits intoknative:masterfrom
whaught:and1
May 7, 2020
Merged

Create a common method for processing reconciliation on generic KRShaped#1284
knative-prow-robot merged 31 commits intoknative:masterfrom
whaught:and1

Conversation

@whaught
Copy link
Copy Markdown
Contributor

@whaught whaught commented May 4, 2020

Issue #1226

  • Creates a post-process function for reasoning generically about KRShaped resources
    • Automatically bumps ObservedGeneration
    • Sets Ready=Unknown if an error is encountered and the reconciler did not update conditions.

This is not yet invoked, the next PR will integrate this with genreconciler.

@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 4, 2020
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label May 4, 2020
@whaught
Copy link
Copy Markdown
Contributor Author

whaught commented May 4, 2020

/assign @grantr @n3wscott

Comment thread reconciler/reconcile_common.go Outdated
Comment thread reconciler/reconcile_common.go Outdated
Comment thread reconciler/reconcile_common_test.go Outdated
Comment thread reconciler/reconcile_common_test.go Outdated
@whaught
Copy link
Copy Markdown
Contributor Author

whaught commented May 5, 2020

/retest

Comment thread reconciler/reconcile_common.go Outdated
Comment thread reconciler/reconcile_common_test.go Outdated
Comment thread reconciler/reconcile_common.go Outdated
Comment thread reconciler/reconcile_common.go Outdated
Comment thread reconciler/reconcile_common_test.go Outdated
Comment thread reconciler/reconcile_common_test.go Outdated
Comment thread reconciler/reconcile_common.go Outdated
Comment thread reconciler/reconcile_common_test.go Outdated
@antoineco
Copy link
Copy Markdown
Contributor

A general question about this PR: why would we want to force the Ready condition to Unknown instead of letting the user decide what to do with it in case of error?

Comment thread reconciler/reconcile_common.go Outdated
Comment thread go.mod Outdated
Comment thread reconciler/reconcile_common.go Outdated
}

func getDefaultConditionSet(resource duckv1.KRShaped) (apis.ConditionSet, error) {
switch resource.GetTopLevelConditionType() {
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.

Why didn't we use the term Happy instead of TopLevel here? Not saying it's good or bad, but it's just the term condition sets use right now.

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.

@n3wscott on #1298 :

I would call this GetTopLevelConditionType

happy was a tongue and cheek joke for the internal code.

I myself am a bit indifferent. The first iteration had "GetHappyConditionType()"

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.

Alright, glad that Scott could confirm 👍

Comment thread reconciler/reconcile_common.go Outdated
Comment thread reconciler/reconcile_common_test.go Outdated
Comment thread vendor/modules.txt Outdated
Comment on lines +37 to +43
newStatus := resource.GetStatus()
if newStatus.ObservedGeneration != resource.GetObjectMeta().GetGeneration() {
// Reset ready to unknown. The reconciler is expected to overwrite this.
manager := condSet.Manage(newStatus)
manager.MarkUnknown(
manager.GetTopLevelCondition().Type, failedGenerationBump, "unsucessfully observed a new generation")
}
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.

Don't we want to also call InitializeConditions here?

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.

My fear was that I don't necessarily want to clobber all the conditions and I believe they should have been initialized in the admission webhook at this point?

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.

Controllers call that method usually, webhooks only initialize the spec if I'm not mistaken (not every type has an admission webhook, for some third-party types the OpenAPI schema present in the CRD is sufficient).

I'm OK leaving that as it is, I was just curious what you thought about it.

Copy link
Copy Markdown
Contributor Author

@whaught whaught May 6, 2020

Choose a reason for hiding this comment

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

This is also not a complete condition set (we don't make any assumptions about the dependant sub-conditions here)

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.

hmm maybe we will want the full conditionset so that we can do this and at some point have the preprocessing do all the init stuff. I may reconsider this as another PR?

Comment thread reconciler/reconcile_common.go Outdated
@antoineco
Copy link
Copy Markdown
Contributor

/lgtm

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

n3wscott commented May 6, 2020

This is great, nice work. I think this will blend well with our controllers and let us drop some easily forgotten copy/paste logic from the current reconcilers.

👏

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label May 6, 2020
Comment thread reconciler/reconcile_common_test.go Outdated
Comment thread reconciler/reconcile_common_test.go Outdated
Co-authored-by: Victor Agababov <vagababov@gmail.com>
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label May 7, 2020
Co-authored-by: Victor Agababov <vagababov@gmail.com>
Copy link
Copy Markdown
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

Copy link
Copy Markdown
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

Comment thread reconciler/reconcile_common_test.go Outdated
Co-authored-by: Matt Moore <mattmoor@vmware.com>
@knative-metrics-robot
Copy link
Copy Markdown

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

File Old Coverage New Coverage Delta
apis/condition_set.go 97.5% 96.7% -0.8
reconciler/reconcile_common.go Do not exist 91.7%

@vagababov
Copy link
Copy Markdown
Contributor

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label May 7, 2020
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.

Not sure why I'm an approver in reconciler/ and @n3wscott isn't...

/lgtm

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 7, 2020
@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: grantr, n3wscott, vagababov, whaught

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 merged commit c88f43e into knative:master May 7, 2020
@whaught whaught deleted the and1 branch May 7, 2020 00:17
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants