Skip to content

Commit

Permalink
clean up old certificate leases (#15424)
Browse files Browse the repository at this point in the history
Co-authored-by: Stavros Kontopoulos <st.kontopoulos@gmail.com>
  • Loading branch information
knative-prow-robot and skonto authored Jul 30, 2024
1 parent 4f73244 commit 0abee66
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/cleanup/cmd/cleanup/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ import (
"knative.dev/pkg/system"
)

const (
networkingCertificatesReconcilerLease = "controller.knative.dev.networking.pkg.certificates.reconciler.reconciler"
controlProtocolCertificatesReconcilerLease = "controller.knative.dev.control-protocol.pkg.certificates.reconciler.reconciler"
)

func main() {
logger := setupLogger()
defer logger.Sync()
Expand Down Expand Up @@ -60,8 +65,11 @@ func main() {
if err != nil {
logger.Fatal("failed to fetch leases: ", err)
}

for _, lease := range leases.Items {
if strings.HasPrefix(lease.Name, "domainmapping") || strings.HasPrefix(lease.Name, "net-certmanager") {
if strings.HasPrefix(lease.Name, "domainmapping") ||
strings.HasPrefix(lease.Name, "net-certmanager") ||
strings.HasPrefix(lease.Name, networkingCertificatesReconcilerLease) || strings.HasPrefix(lease.Name, controlProtocolCertificatesReconcilerLease) {
if err = client.CoordinationV1().Leases(system.Namespace()).Delete(context.Background(), lease.Name, metav1.DeleteOptions{}); err != nil && !apierrs.IsNotFound(err) {
logger.Fatalf("failed to delete lease %s: %v", lease.Name, err)
}
Expand Down

0 comments on commit 0abee66

Please sign in to comment.