Skip to content

Commit ca26211

Browse files
committed
Implement a pause between zone updates
1 parent 651e3bd commit ca26211

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

api/operator/v1alpha1/vmdistributedcluster_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ type VMDistributedClusterSpec struct {
3636
// ReadyDeadline is the deadline for the VMCluster to be ready.
3737
// +optional
3838
ReadyDeadline *metav1.Duration `json:"readyDeadline,omitempty"`
39+
// ZoneUpdatePause is the time the operator should wait between zone updates to ensure a smooth transition.
40+
// +optional
41+
ZoneUpdatePause *metav1.Duration `json:"zoneUpdatePause,omitempty"`
3942
// VMAgent points to the VMAgent object for collecting metrics from multiple VMClusters
4043
VMAgent corev1.LocalObjectReference `json:"vmagent,omitempty"`
4144
// VMUsers is a list of VMUser objects controlling traffic distribution between multiple VMClusters

api/operator/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/overlay/crd.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15102,6 +15102,8 @@ spec:
1510215102
type: object
1510315103
x-kubernetes-map-type: atomic
1510415104
type: array
15105+
zoneUpdatePause:
15106+
type: string
1510515107
zones:
1510615108
properties:
1510715109
vmclusters:

internal/controller/operator/factory/vmdistributedcluster/vmdistributedcluster.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const (
5050

5151
var (
5252
defaultVMClusterWaitReadyDeadline = metav1.Duration{Duration: 5 * time.Minute}
53+
defaultZoneUpdatePause = metav1.Duration{Duration: 1 * time.Minute}
5354
)
5455

5556
// CreateOrUpdate handles VM deployment reconciliation.
@@ -79,10 +80,15 @@ func CreateOrUpdate(ctx context.Context, cr *vmv1alpha1.VMDistributedCluster, rc
7980
}
8081
}
8182

83+
// Setup deadlines and timeouts
8284
vmclusterWaitReadyDeadline := defaultVMClusterWaitReadyDeadline.Duration
8385
if cr.Spec.ReadyDeadline != nil {
8486
vmclusterWaitReadyDeadline = cr.Spec.ReadyDeadline.Duration
8587
}
88+
zoneUpdatePause := defaultZoneUpdatePause.Duration
89+
if cr.Spec.ZoneUpdatePause != nil {
90+
zoneUpdatePause = cr.Spec.ZoneUpdatePause.Duration
91+
}
8692

8793
// Fetch global vmagent
8894
vmAgentObj, err := fetchVMAgent(ctx, rclient, cr.Namespace, cr.Spec.VMAgent)
@@ -126,9 +132,6 @@ func CreateOrUpdate(ctx context.Context, cr *vmv1alpha1.VMDistributedCluster, rc
126132
return fmt.Errorf("unexpected generations or zones config change detected: %v", diff)
127133
}
128134

129-
// TODO[vrutkovs]: Mark all VMClusters as paused?
130-
// This would prevent other reconciliation loops from changing them
131-
132135
// Disable VMClusters one by one if overrideSpec needs to be applied
133136
httpClient := &http.Client{
134137
Timeout: httpTimeout,
@@ -196,6 +199,9 @@ func CreateOrUpdate(ctx context.Context, cr *vmv1alpha1.VMDistributedCluster, rc
196199
if err := setVMClusterStatusInVMUsers(ctx, rclient, cr, vmClusterObj, vmUserObjs, true); err != nil {
197200
return fmt.Errorf("failed to set VMCluster status in VMUsers: %w", err)
198201
}
202+
203+
// Sleep for zoneUpdatePause time between VMClusters updates
204+
time.Sleep(zoneUpdatePause)
199205
}
200206
return nil
201207
}

0 commit comments

Comments
 (0)