Repository navigation
feat(etcdclusters): Option to preserve etcdmembers on sleep #382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -317,7 +317,11 @@ func (r *EtcdClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) | |
| return r.scaleUp(ctx, cluster, active) | ||
| } | ||
| if current > desired { | ||
| log.Info("scaling down", "current", current, "desired", desired) | ||
| if desired == 0 && (current == 1 || cluster.Spec.PreserveMembersOnSleep) { | ||
| log.Info("Putting etcdmember to sleep", "current", current, "desired", desired) | ||
| } else { | ||
| log.Info("scaling down", "current", current, "desired", desired) | ||
| } | ||
| return r.scaleDown(ctx, cluster, running) | ||
| } | ||
|
|
||
|
|
@@ -1294,6 +1298,7 @@ func isAuthFailedErr(err error) bool { | |
| // scaleUp by Patching Spec.Dormant back to false. The CR is never | ||
| // deleted across the pause cycle, so no name lookup / Create-by-fixed- | ||
| // name / PVC reparenting is needed. | ||
| // Same logic applies to X→0 transistion when PreserveMembersOnSleep is true | ||
| func (r *EtcdClusterReconciler) scaleDown( | ||
| ctx context.Context, | ||
| cluster *lll.EtcdCluster, | ||
|
|
@@ -1315,7 +1320,8 @@ func (r *EtcdClusterReconciler) scaleDown( | |
| // false. Keeping the CR across the pause means no Create-by-fixed- | ||
| // name on resume, no PVC reparenting, no cross-resource annotation | ||
| // dance, and no stale status field to sweep. | ||
| if cluster.Status.Observed != nil && cluster.Status.Observed.Replicas == 0 && len(members) == 1 { | ||
| // Same logic applies to X→0 transistion when PreserveMembersOnSleep is true | ||
| if cluster.Status.Observed != nil && cluster.Status.Observed.Replicas == 0 && (len(members) == 1 || cluster.Spec.PreserveMembersOnSleep) { | ||
|
Comment on lines
+1323
to
+1324
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if !victim.Spec.Dormant { | ||
| original := victim.DeepCopy() | ||
| victim.Spec.Dormant = true | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: cozystack/etcd-operator
Length of output: 12322
Script executed:
Repository: cozystack/etcd-operator
Length of output: 20256
Script executed:
Repository: cozystack/etcd-operator
Length of output: 39029
Script executed:
Repository: cozystack/etcd-operator
Length of output: 16774
Latch
PreserveMembersOnSleepinStatus.Observed.During a 3→0 transition, a true-to-false edit after one member becomes dormant can make
scaleDowndelete another member and its PVC. This violates the locked-target behavior; documenting the live read would not prevent the deletion.Add the flag to the observed snapshot and comparison, and use the observed value throughout the transition.