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

Delete git-clone basic-auth secret when deleting a pipelinerun #1341

Conversation

chmouel
Copy link
Member

@chmouel chmouel commented Jun 29, 2023

When deleting a pipelinerun, the git-clone basic-auth secret should be deleted
as well, but in some cases of conflicts and the ownerRef not being set, the
secret is not deleted and we need to delete it manually.

Fixes #1297

When deleting a pipelinerun, the git-clone basic-auth secret should be deleted
as well, but in some cases of conflicts and the ownerRef not being set, the
secret is not deleted and we need to delete it manually.

Fixes openshift-pipelines#1297
@pipelines-as-code
Copy link

pipelines-as-code bot commented Jun 29, 2023

Golang test coverage difference report

Coverage unchanged. 🥈

Package report
package                                                                            before    after    delta
-------                                                                           -------  -------  -------
pkg/acl                                                                           100.00%  100.00%         
pkg/action                                                                         76.19%   76.19%         
pkg/adapter                                                                        72.41%   72.41%         
pkg/apis/features                                                                 100.00%  100.00%         
pkg/cli/info                                                                       88.23%   88.23%         
pkg/cli/prompt                                                                     74.46%   74.46%         
pkg/cli/status                                                                     95.23%   95.23%         
pkg/cli/webhook                                                                    59.36%   59.36%         
pkg/cmd/tknpac/bootstrap                                                            5.72%    5.72%         
pkg/cmd/tknpac/completion                                                          50.00%   50.00%         
pkg/cmd/tknpac/create                                                              43.36%   43.36%         
pkg/cmd/tknpac/describe                                                            46.31%   46.31%         
pkg/cmd/tknpac/generate                                                            62.20%   62.20%         
pkg/cmd/tknpac/info                                                                62.50%   62.50%         
pkg/cmd/tknpac/list                                                                46.47%   46.47%         
pkg/cmd/tknpac/resolve                                                             74.67%   74.67%         
pkg/cmd/tknpac/webhook                                                             52.47%   52.47%         
pkg/consoleui                                                                      84.12%   84.12%         
pkg/customparams                                                                   94.11%   94.11%         
pkg/events                                                                         73.33%   73.33%         
pkg/formatting                                                                     98.73%   98.73%         
pkg/git                                                                            84.84%   84.84%         
pkg/hub                                                                            90.62%   90.62%         
pkg/kubeinteraction                                                                54.76%   54.76%         
pkg/kubeinteraction/status                                                         77.27%   77.27%         
pkg/matcher                                                                        86.47%   86.47%         
pkg/params/clients                                                                 14.86%   14.86%         
pkg/params/settings                                                                79.48%   79.48%         
pkg/pipelineascode                                                                 80.90%   80.90%         
pkg/provider                                                                       76.19%   76.19%         
pkg/provider/bitbucketcloud                                                        87.16%   87.16%         
pkg/provider/bitbucketserver                                                       88.32%   88.32%         
pkg/provider/gitea                                                                 32.66%   32.66%         
pkg/provider/gitea/structs                                                         22.68%   22.68%         
pkg/provider/github                                                                83.03%   83.03%         
pkg/provider/github/app                                                            78.33%   78.33%         
pkg/provider/gitlab                                                                86.49%   86.49%         
pkg/random                                                                        100.00%  100.00%         
pkg/reconciler                                                                     46.10%   46.10%         
pkg/resolve                                                                        87.93%   87.93%         
pkg/secrets                                                                        93.02%   93.02%         
pkg/sort                                                                           51.20%   51.20%         
pkg/sync                                                                           91.13%   91.13%         
pkg/templates                                                                     100.00%  100.00%         
pkg/webhook                                                                        22.22%   22.22%         
                                                                          total:   67.25%   67.25%   +0.00%

// Try to Delete the secret created for git-clone basic-auth, it should have been created with a owneref on the pipelinerun and due being deleted when the pipelinerun is deleted
// but in some cases of conflicts and the ownerRef not being set, the secret is not deleted and we need to delete it manually.
if secretName, ok := pr.GetAnnotations()[keys.GitAuthSecret]; ok {
_ = k.Run.Clients.Kube.CoreV1().Secrets(repo.GetNamespace()).Delete(ctx, secretName, metav1.DeleteOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

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

we do have kubeinteraction pkg dealing with secret create and update
may be we wanna move this there??!!

and some refactoring along the way. I separated the commits to make it
easier to review from the implementation.
@piyush-garg
Copy link
Member

/lgtm

@savitaashture savitaashture merged commit 43320b2 into openshift-pipelines:main Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Delete gitauth secret along pipelinerun cleanup
4 participants