Skip to content

Commit 46fec9c

Browse files
authored
increase cache sync timeouts (#558)
1 parent 44fb959 commit 46fec9c

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

cmd/agent/kubernetes.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,18 +287,20 @@ func registerKubeReconcilersOrDie(
287287
setupLog.Error(err, "unable to create controller", "controller", "AgentConfiguration")
288288
}
289289
if err := (&controller.AgentRuntimeReconciler{
290-
Client: manager.GetClient(),
291-
Scheme: manager.GetScheme(),
292-
ConsoleClient: extConsoleClient,
290+
Client: manager.GetClient(),
291+
Scheme: manager.GetScheme(),
292+
ConsoleClient: extConsoleClient,
293+
CacheSyncTimeout: args.PollInterval() * 3,
293294
}).SetupWithManager(manager); err != nil {
294295
setupLog.Error(err, "unable to create controller", "controller", "AgentRuntime")
295296
}
296297
if err := (&controller.AgentRunReconciler{
297-
Client: manager.GetClient(),
298-
Scheme: manager.GetScheme(),
299-
ConsoleClient: extConsoleClient,
300-
ConsoleURL: consoleURL,
301-
DeployToken: deployToken,
298+
Client: manager.GetClient(),
299+
Scheme: manager.GetScheme(),
300+
ConsoleClient: extConsoleClient,
301+
ConsoleURL: consoleURL,
302+
DeployToken: deployToken,
303+
CacheSyncTimeout: args.PollInterval() * 3,
302304
}).SetupWithManager(manager); err != nil {
303305
setupLog.Error(err, "unable to create controller", "controller", "AgentRun")
304306
}

internal/controller/agentrun_controller.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,17 @@ const (
4646
// 3. Reporting status back to Console API
4747
type AgentRunReconciler struct {
4848
client.Client
49-
Scheme *runtime.Scheme
50-
ConsoleClient pluralclient.Client
51-
ConsoleURL string
52-
DeployToken string
49+
Scheme *runtime.Scheme
50+
ConsoleClient pluralclient.Client
51+
ConsoleURL string
52+
DeployToken string
53+
CacheSyncTimeout time.Duration
5354
}
5455

5556
// SetupWithManager configures the controller with the manager.
5657
func (r *AgentRunReconciler) SetupWithManager(mgr ctrl.Manager) error {
5758
return ctrl.NewControllerManagedBy(mgr).
58-
WithOptions(controller.Options{MaxConcurrentReconciles: 1}).
59+
WithOptions(controller.Options{MaxConcurrentReconciles: 1, CacheSyncTimeout: r.CacheSyncTimeout}).
5960
For(&v1alpha1.AgentRun{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
6061
Owns(&corev1.Pod{}).
6162
Complete(r)

internal/controller/agentruntime_controller.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ const (
3333
// AgentRuntimeReconciler reconciles a AgentRuntime object
3434
type AgentRuntimeReconciler struct {
3535
client.Client
36-
ConsoleClient consoleclient.Client
37-
Scheme *runtime.Scheme
36+
ConsoleClient consoleclient.Client
37+
Scheme *runtime.Scheme
38+
CacheSyncTimeout time.Duration
3839
}
3940

4041
//+kubebuilder:rbac:groups=deployments.plural.sh,resources=agentruntimes,verbs=get;list;watch;create;update;patch;delete
@@ -124,7 +125,7 @@ func (r *AgentRuntimeReconciler) Reconcile(ctx context.Context, req ctrl.Request
124125
// SetupWithManager sets up the controller with the Manager.
125126
func (r *AgentRuntimeReconciler) SetupWithManager(mgr ctrl.Manager) error {
126127
return ctrl.NewControllerManagedBy(mgr).
127-
WithOptions(controller.Options{MaxConcurrentReconciles: 1}).
128+
WithOptions(controller.Options{MaxConcurrentReconciles: 1, CacheSyncTimeout: r.CacheSyncTimeout}).
128129
For(&v1alpha1.AgentRuntime{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
129130
Complete(r)
130131
}

0 commit comments

Comments
 (0)