Skip to content

Always call updateStatus after Reconcile.#1321

Merged
google-prow-robot merged 2 commits intoknative:masterfrom
mattmoor:update-status
Jun 22, 2018
Merged

Always call updateStatus after Reconcile.#1321
google-prow-robot merged 2 commits intoknative:masterfrom
mattmoor:update-status

Conversation

@mattmoor
Copy link
Copy Markdown
Member

This splits the main Reconcile methods of the controllers, so that regardless of whether they return an error we can call updateStatus with any changes made to the object being reconciled regardless of the success or failure of the reconciliation. This also removes all of the updateStatus calls from the various methods with the exception of the methods called directly by the informer.

Eventually when all of the actual reconciliation is performed by Reconcile, these should be the only calls to updateStatus and we could conceivably inline them (defensively to avoid people adding new calls in violation of this model.

Related: #1107

@google-prow-robot google-prow-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 22, 2018
Copy link
Copy Markdown
Member

@dprotaso dprotaso left a comment

Choose a reason for hiding this comment

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

Curious there's an opportunity to further refactor some updateStatus calls when we receive events about builds, deployments, endpoints etc. Essentially each controller's Sync* calls

// updates regardless of whether the reconciliation errored out.
err = c.reconcile(ctx, config)
if _, err := c.updateStatus(config); err != nil {
return err
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any reason why you removed logging when calling updateStatus fails

updateStatus function has no logging

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

Comment thread pkg/controller/revision/revision.go Outdated
// updates regardless of whether the reconciliation errored out.
err = c.reconcile(ctx, rev)
if _, err := c.updateStatus(rev); err != nil {
return err
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

likewise the revision's updateStatus doesn't log any errors

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

Comment thread pkg/controller/route/route.go Outdated
// updates regardless of whether the reconciliation errored out.
err = c.reconcile(ctx, route)
if _, err := c.updateStatus(ctx, route); err != nil {
return err
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

route's updateStatus has logging so this is great

}

// Reflect any status changes that occurred during reconciliation.
if _, err := c.updateStatus(config); err != nil {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Curious what you think about not splitting these methods but having this as a top level defer call

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I thought about this, but this felt clearer (less magical) to me. One thing that makes hard is returning an error on updateStatus (you need to use named return values).

LMK if you feel strongly (the naming could also be more original, but nothing else felt appreciably better).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't feel strongly - was just wondering if you considered it

Copy link
Copy Markdown
Member Author

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

Curious there's an opportunity to further refactor some updateStatus calls when we receive events about builds, deployments, endpoints etc. Essentially each controller's Sync* calls

Yes, but those are destined to be cleaned up in the move to more level-based reconciliation, so I'm more reluctant to change them.

Comment thread pkg/controller/revision/revision.go Outdated
// updates regardless of whether the reconciliation errored out.
err = c.reconcile(ctx, rev)
if _, err := c.updateStatus(rev); err != nil {
return err
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

// updates regardless of whether the reconciliation errored out.
err = c.reconcile(ctx, config)
if _, err := c.updateStatus(config); err != nil {
return err
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

This splits the main `Reconcile` methods of the controllers, so that regardless of whether they return an error we can call `updateStatus` with any changes made to the object being reconciled regardless of the success or failure of the reconciliation.  This also removes all of the `updateStatus` calls from the various methods with the exception of the methods called directly by the informer.

Related: knative/serving#1107
@mattmoor
Copy link
Copy Markdown
Member Author

Fixing failures due to merge conflicts...

@mattmoor
Copy link
Copy Markdown
Member Author

Ok, should be RFAL.

@knative-metrics-robot
Copy link
Copy Markdown

The following is the coverage report on pkg/. Say /test pull-knative-serving-go-coverage to run the coverage report again

File Old Coverage New Coverage Delta
pkg/controller/configuration/configuration.go 79.5% 80.4% 0.9
pkg/controller/service/service.go 84.1% 84.6% 0.5
pkg/controller/route/route.go 78.3% 79.1% 0.8
pkg/controller/revision/revision.go 78.6% 77.4% -1.3

*TestCoverage feature is being tested, do not rely on any info here yet

@mattmoor
Copy link
Copy Markdown
Member Author

/test pull-knative-serving-unit-tests

@dprotaso
Copy link
Copy Markdown
Member

/lgtm
/approve

@google-prow-robot google-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 22, 2018
@google-prow-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dprotaso, mattmoor

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

@google-prow-robot google-prow-robot merged commit 4bcdb6c into knative:master Jun 22, 2018
@mattmoor mattmoor deleted the update-status branch June 22, 2018 20:43
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. 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.

5 participants