Skip to content

Commit

Permalink
Merge pull request #647 from qu1queee/qu1queee/remove_generated_sec_t…
Browse files Browse the repository at this point in the history
…oken

Ensure we dont mount generated serviceAccount token secret in pods
  • Loading branch information
openshift-merge-robot authored Mar 8, 2021
2 parents e725c2e + c802ca3 commit 830d278
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/reconciler/buildrun/resources/service_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ func RetrieveServiceAccount(ctx context.Context, client client.Client, build *bu
serviceAccount.Name = serviceAccountName
serviceAccount.Namespace = buildRun.Namespace

// when generating a ServiceAccount on the fly, it will generate a corresponding ServiceAccount
// token Secret to allow API access. Avoid mounting this at the pod level while it is
// not used and might bring more problems during mounting.
mountSAToken := false

// Create the service account, use CreateOrUpdate as it might exist already from a previous reconciliation that
// succeeded to create the service account but failed to update the build run that references it
ctxlog.Info(ctx, "create or update serviceAccount for BuildRun", namespace, buildRun.Namespace, name, serviceAccountName, "BuildRun", buildRun.Name)
Expand All @@ -58,7 +63,7 @@ func RetrieveServiceAccount(ctx context.Context, client client.Client, build *bu

ownerReference := metav1.NewControllerRef(buildRun, buildv1alpha1.SchemeGroupVersion.WithKind("BuildRun"))
serviceAccount.SetOwnerReferences([]metav1.OwnerReference{*ownerReference})

serviceAccount.AutomountServiceAccountToken = &mountSAToken
ApplyCredentials(ctx, build, serviceAccount)

return nil
Expand Down

0 comments on commit 830d278

Please sign in to comment.