Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct and optimize reconciliation on deletion #622

Conversation

SaschaSchwarze0
Copy link
Member

Changes

While testing something, I noticed that deleting a build caused a reconciliation on the build:

Feb 24 13:55:02 build-operator-dbbb6b95-272vf build-operator debug {"level":"debug","ts":1614171301.8459392,"logger":"build.build-controller","msg":"start reconciling Build","namespace":"default","name":"test-kaniko-xlarge-97"}
Feb 24 13:55:02 build-operator-dbbb6b95-272vf build-operator debug {"level":"debug","ts":1614171301.8459957,"logger":"build.build-controller","msg":"finish reconciling build. build was not found","namespace":"default","name":"test-kaniko-xlarge-97"}

That caused me to look into the reconciliations on delete. For Builds, I simply always return false in the predicate function because there is nothing we need to do when a Build is deleted since we do not have any finalizers.

The same applies for BuildRuns.

For TaskRuns, I am fixing a bug. When a TaskRun got deleted, we unconditionally changed the BuildRun to Failed state stating that the TaskRun doesn't exist. This imo makes sense as long as the TaskRun is not completed, but if the TaskRun is completed, then we also updated the BuildRun to a (final) Success or Failed state already for the Update event. I am therefore only reconciling on TaskRun deletion when the CompletionTime is nil. Also added integration tests.

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Set a kind label on this PR
  • Release notes block has been filled in, or marked NONE

Release Notes

Fixing the predicate functions for delete operations so that unnecessary reconciliations are omitted and a completed BuildRun does not get updated if the TaskRun gets deleted.

@SaschaSchwarze0 SaschaSchwarze0 added the kind/bug Categorizes issue or PR as related to a bug. label Feb 25, 2021
@openshift-ci-robot openshift-ci-robot added the release-note Label for when a PR has specified a release note label Feb 25, 2021
@SaschaSchwarze0
Copy link
Member Author

/test 4.4-unit

@SaschaSchwarze0 SaschaSchwarze0 force-pushed the sascha-reconcile-on-delete branch 2 times, most recently from 956be45 to dd1d812 Compare February 25, 2021 07:52
@qu1queee qu1queee requested review from qu1queee and removed request for zhangtbj February 25, 2021 09:12
Copy link
Contributor

@qu1queee qu1queee left a comment

Choose a reason for hiding this comment

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

Nice findings, code looks good, test cases can be better, asking for a change in one test spec.

pkg/reconciler/build/controller.go Show resolved Hide resolved
test/integration/utils/buildruns.go Outdated Show resolved Hide resolved
test/integration/buildruns_to_taskruns_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@qu1queee qu1queee left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 25, 2021
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qu1queee

The full list of commands accepted by this bot can be found here.

The pull request process is described here

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 25, 2021
@openshift-merge-robot openshift-merge-robot merged commit a5efeed into shipwright-io:master Feb 25, 2021
@SaschaSchwarze0 SaschaSchwarze0 deleted the sascha-reconcile-on-delete branch March 3, 2021 15:22
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. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note Label for when a PR has specified a release note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants