Skip to content

Commit

Permalink
increase lease duration
Browse files Browse the repository at this point in the history
  • Loading branch information
alexei-led committed Mar 28, 2024
1 parent c14eaf5 commit 2064af2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func assignAddress(c context.Context, log *logrus.Entry, client kubernetes.Inter
defer ticker.Stop()

// create new cluster wide lock
lock := lease.NewKubeLeaseLock(client, kubeipLockName, "default", node.Name, cfg.LeaseDuration)
lock := lease.NewKubeLeaseLock(client, kubeipLockName, "default", node.Instance, cfg.LeaseDuration)

for retryCounter := 0; retryCounter <= cfg.RetryAttempts; retryCounter++ {
log.WithFields(logrus.Fields{
Expand All @@ -105,7 +105,11 @@ func assignAddress(c context.Context, log *logrus.Entry, client kubernetes.Inter
if err := lock.Lock(ctx); err != nil {
return errors.Wrap(err, "failed to acquire lock")
}
defer lock.Unlock(ctx) //nolint:errcheck
log.Debug("lock acquired")
defer func() {
lock.Unlock(ctx) //nolint:errcheck
log.Debug("lock released")
}()
if err := assigner.Assign(ctx, node.Instance, node.Zone, cfg.Filter, cfg.OrderBy); err != nil {
return err //nolint:wrapcheck
}
Expand Down
4 changes: 4 additions & 0 deletions examples/gcp/gke.tf
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ resource "kubernetes_daemonset" "kubeip_daemonset" {
name = "LOG_JSON"
value = "true"
}
env {
name = "LEASE_DURATION"
value = "20"
}
resources {
requests = {
cpu = "100m"
Expand Down

0 comments on commit 2064af2

Please sign in to comment.