Skip to content

Commit

Permalink
Adjust controller lock to be based on controller name
Browse files Browse the repository at this point in the history
  • Loading branch information
mallardduck committed Jan 16, 2025
1 parent da5fb89 commit 7a8ca5c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/controllers/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controllers

import (
"context"
"strings"
"time"

"github.com/k3s-io/helm-controller/pkg/controllers/chart"
Expand Down Expand Up @@ -106,7 +107,13 @@ func Register(ctx context.Context, systemNamespace, controllerName string, cfg c
klog.Infof("Starting helm controller in namespace %s", systemNamespace)
}

leader.RunOrDie(ctx, systemNamespace, "helm-controller-lock", appCtx.K8s, func(ctx context.Context) {
controllerLockName := "helm-controller-lock"
if controllerName != "helm-controller" {
klog.Infof("Starting helm controller using alias `%s`", controllerName)
controllerLockName = strings.Join([]string{controllerName, controllerLockName}, "-")
}

leader.RunOrDie(ctx, systemNamespace, controllerLockName, appCtx.K8s, func(ctx context.Context) {
if err := appCtx.start(ctx); err != nil {
klog.Fatal(err)
}
Expand Down

0 comments on commit 7a8ca5c

Please sign in to comment.