Skip to content

Commit 4257581

Browse files
committed
Feature: Make Retry Period configurable
1 parent cf09cc6 commit 4257581

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

cmd/machine-controller-manager/app/controllermanager.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
mcmcontroller "github.com/gardener/machine-controller-manager/pkg/controller"
3838
corecontroller "github.com/gardener/machine-controller-manager/pkg/util/clientbuilder/core"
3939
machinecontroller "github.com/gardener/machine-controller-manager/pkg/util/clientbuilder/machine"
40+
"github.com/gardener/machine-controller-manager/pkg/util/provider/machineutils"
4041
kubernetesinformers "k8s.io/client-go/informers"
4142
kubescheme "k8s.io/client-go/kubernetes/scheme"
4243

@@ -218,6 +219,14 @@ func StartControllers(s *options.MCMServer,
218219
recorder record.EventRecorder,
219220
stop <-chan struct{}) error {
220221

222+
if s.LongRetryOverride != "" {
223+
d, err := time.ParseDuration(s.LongRetryOverride)
224+
if err != nil {
225+
return fmt.Errorf("invalid --long-retry %q: %w", s.LongRetryOverride, err)
226+
}
227+
machineutils.LongRetry = machineutils.RetryPeriod(d)
228+
}
229+
klog.V(4).Infof("Configured LongRetry=%s", time.Duration(machineutils.LongRetry))
221230
klog.V(4).Info("Getting available resources")
222231
availableResources, err := getAvailableResources(controlCoreClientBuilder)
223232
if err != nil {

cmd/machine-controller-manager/app/options/options.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type MCMServer struct {
4646

4747
ControlKubeconfig string
4848
TargetKubeconfig string
49+
LongRetryOverride string
4950
}
5051

5152
// NewMCMServer creates a new MCMServer with a default config.
@@ -101,6 +102,8 @@ func (s *MCMServer) AddFlags(fs *pflag.FlagSet) {
101102

102103
fs.BoolVar(&s.AutoscalerScaleDownAnnotationDuringRollout, "autoscaler-scaledown-annotation-during-rollout", true, "Add cluster autoscaler scale-down disabled annotation during roll-out.")
103104

105+
fs.StringVar(&s.LongRetryOverride, "long-retry", "", "Override machineutils.LongRetry.")
106+
104107
logs.AddFlags(fs) // Here `logs` is `k8s.io/component-base/logs`.
105108

106109
leaderelectionconfig.BindFlags(&s.LeaderElection, fs)

pkg/util/provider/machineutils/utils.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,11 @@ const (
9595
// MediumRetry tells the controller to retry after a medium duration - 3 minutes
9696
MediumRetry RetryPeriod = RetryPeriod(3 * time.Minute)
9797
// LongRetry tells the controller to retry after a long duration - 10 minutes
98-
LongRetry RetryPeriod = RetryPeriod(10 * time.Minute)
98+
DefaultLongRetry RetryPeriod = RetryPeriod(10 * time.Minute)
9999
)
100100

101+
var LongRetry RetryPeriod = DefaultLongRetry
102+
101103
// EssentialTaints are taints on node object which if added/removed, require an immediate reconcile by machine controller
102104
// TODO: update this when taints for ALT updation and PostCreate operations is introduced.
103105
var EssentialTaints = []string{TaintNodeCriticalComponentsNotReady}

0 commit comments

Comments
 (0)