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

Clean up old certificate leases #15420

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Member

Choose a reason for hiding this comment

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

is this the full name or why do we have HasPrefix below?

Copy link
Member

Choose a reason for hiding this comment

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

"controller" is the component - while the rest of the string is the package name & type

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
Loading