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

Remove compatability code to remove service account with -sa suffix #957

Conversation

SaschaSchwarze0
Copy link
Member

Changes

Fixes #892

This removes the compatibility code that removes a generated service account with the -sa suffix on BuildRun completion created by old releases. Should a user have a running old BuildRun or make a large version jump, then the owner reference will make sure the service account gets deleted on BuildRun deletion.

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

Removing compatibility code that deleted generated service accounts with the naming pattern from before v0.6

@SaschaSchwarze0 SaschaSchwarze0 added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Dec 8, 2021
@openshift-ci openshift-ci bot added the release-note Label for when a PR has specified a release note label Dec 8, 2021
@SaschaSchwarze0 SaschaSchwarze0 added this to the release-v0.7.0 milestone Dec 8, 2021
@gabemontero
Copy link
Member

/approve

should we have in previous PRs updated the doc for the generate SAs at https://github.com/shipwright-io/build/blob/main/docs/buildrun.md#defining-the-serviceaccount with some expectation of what the name of the generated service account is?

if so, perhaps we can address that with this one

WDYT @SaschaSchwarze0 ?

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 8, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gabemontero

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 openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 8, 2021
@SaschaSchwarze0
Copy link
Member Author

/approve

should we have in previous PRs updated the doc for the generate SAs at https://github.com/shipwright-io/build/blob/main/docs/buildrun.md#defining-the-serviceaccount with some expectation of what the name of the generated service account is?

if so, perhaps we can address that with this one

WDYT @SaschaSchwarze0 ?

Done @gabemontero.

Comment on lines 107 to 101
if apierrors.IsNotFound(err) {
serviceAccount.Name = GetHeritageGeneratedServiceAccountName(completedBuildRun)
ctxlog.Info(ctx, "deleting service account", namespace, completedBuildRun.Namespace, name, completedBuildRun.Name, "serviceAccount", serviceAccount.Name)
err = client.Delete(ctx, serviceAccount)
}

if err != nil && !apierrors.IsNotFound(err) {
if !apierrors.IsNotFound(err) {
Copy link
Member

@shahulsonhal shahulsonhal Dec 9, 2021

Choose a reason for hiding this comment

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

I think it would be nice if we remove the nested if and use the &&

if err := client.Delete(ctx, serviceAccount); err != nil && !apierrors.IsNotFound(err) {
		return err
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, done @shahulsonhal.

Copy link
Member

@shahulsonhal shahulsonhal left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 9, 2021
@openshift-merge-robot openshift-merge-robot merged commit ee77adb into shipwright-io:main Dec 9, 2021
@SaschaSchwarze0 SaschaSchwarze0 deleted the sascha-remove-compat-code branch December 9, 2021 19:48
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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. 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.

Remove compatibility code for generated service accounts
4 participants