Skip to content

Commit 8ae7bb8

Browse files
authored
Merge pull request #305 from erikgb/fix-dynamic-cert-runnable
fix: dynamic cert runnable must NOT be leader election aware
2 parents 353810d + 00ef58d commit 8ae7bb8

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

pkg/internal/cmd/cmd.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ func NewCommand(ctx context.Context) *cobra.Command {
100100
return fmt.Errorf("unable to create controller manager: %w", err)
101101
}
102102

103-
if err := mgr.Add(manager.RunnableFunc(func(ctx context.Context) error {
104-
return certificateSource.Run(ctx)
105-
})); err != nil {
103+
if err := mgr.Add(&dynamicCertRunnable{source: certificateSource}); err != nil {
106104
return err
107105
}
108106

@@ -143,3 +141,19 @@ func NewCommand(ctx context.Context) *cobra.Command {
143141

144142
return cmd
145143
}
144+
145+
type dynamicCertRunnable struct {
146+
source *servertls.DynamicSource
147+
}
148+
149+
func (c *dynamicCertRunnable) Start(ctx context.Context) error {
150+
return c.source.Run(ctx)
151+
}
152+
153+
func (c *dynamicCertRunnable) NeedLeaderElection() bool {
154+
// By default, a runnable in c/r is leader election aware.
155+
// Since we need certs for all replicas, this runnable must NOT be leader election aware.
156+
return false
157+
}
158+
159+
var _ manager.LeaderElectionRunnable = &dynamicCertRunnable{}

0 commit comments

Comments
 (0)