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

Handle non-existing annotation #460

Conversation

SaschaSchwarze0
Copy link
Member

I just noticed these output in the operator logs in a travis build https://travis-ci.org/github/shipwright-io/build/builds/740734332:

{"level":"info","ts":1604290243.6176696,"logger":"build.build-controller","msg":"the annotation build.build.dev/build-run-deletion was not properly defined, supported values are true or false","namespace":"default","name":"buildpacks-v3-ruby-x42q8"}
{"level":"info","ts":1604290243.617835,"logger":"build.build-controller","msg":"unexpected error during ownership reference validation","namespace":"default","name":"buildpacks-v3-ruby-x42q8","error":"the annotation build.build.dev/build-run-deletion was not properly defined, supported values are true or false"}

We forgot to handle the non-existing annotation in the same was as one with value false. I am correcting this.

@SaschaSchwarze0 SaschaSchwarze0 changed the title Handle empty non-existing annotation Handle non-existing annotation Nov 2, 2020
}
}
case "false":
case "", "false":
Copy link
Contributor

@qu1queee qu1queee Nov 2, 2020

Choose a reason for hiding this comment

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

Thanks, just to be very clear, the switch is not covering the scenario when build.AnnotationBuildRunDeletion annotation is not present. I think we should not cover this in this switch/case, mainly because there is no need to run the underlying logic when the annotation is not defined.

I think you can use this https://play.golang.org/p/HklUW5yVfas logic, to validate prior to the switch if the annotation key is defined or not.

Copy link
Member Author

@SaschaSchwarze0 SaschaSchwarze0 Nov 3, 2020

Choose a reason for hiding this comment

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

Hi @qu1queee, I think your proposal will mean the following behavior:

  • Create a build b1 without the annotation
  • Create a buildrun br1 which references b1 -> the buildrun has no owner, that's fine

--

  • Create a build b2 with annotation build.build.dev/build-run-deletion=true
  • Create a buildrun br2 which references b2 -> the buildrun br2 will be owned by the build b2
  • Update the build b2 to delete the annotation build.build.dev/build-run-deletion -> the buildrun br2 still has b2 as owner although b2 does not anymore express that buildrun deletion should happen

Based on that, handling "" in the same way as "false" is in my opinion accurate.

Copy link
Contributor

@qu1queee qu1queee Nov 3, 2020

Choose a reason for hiding this comment

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

I see, sorry it was not clear from the PR that this was the rational. I think the current code was a strict one, based on #409 (review) . I think this is ideal, but you will need to provide an integration test case for this flow. Use https://github.com/shipwright-io/build/blob/master/test/integration/build_to_buildruns_test.go#L344-L372 as a reference, where the patch part should be a removal of the annotation.

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.

Requesting test case for the flow when the annotation gets deleted, but previous ownerreferences still define.

@SaschaSchwarze0
Copy link
Member Author

/test 4.4-unit

@SaschaSchwarze0
Copy link
Member Author

Requesting test case for the flow when the annotation gets deleted, but previous ownerreferences still define.

Integration test added.

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.

Thanks, lgtm.

@qu1queee
Copy link
Contributor

qu1queee commented Nov 5, 2020

/approve

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 5, 2020
@zhangtbj
Copy link
Contributor

zhangtbj commented Nov 5, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 5, 2020
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qu1queee, zhangtbj

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-merge-robot openshift-merge-robot merged commit 5c4fccf into shipwright-io:master Nov 5, 2020
@SaschaSchwarze0 SaschaSchwarze0 deleted the sascha-empty-annotation branch November 23, 2020 09:06
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants