Skip to content

Commit

Permalink
clean up old certificate leases (#15420)
Browse files Browse the repository at this point in the history
  • Loading branch information
skonto committed Jul 30, 2024
1 parent 8ab2768 commit 9a7409c
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 9a7409c

Please sign in to comment.