Skip to content

Commit 6748852

Browse files
author
lamai93
committed
If server is terminated before drained, declare it as cleaned out and replace it with a new one.
1 parent 4d8d37d commit 6748852

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pkg/deployment/resources/pod_finalizers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (r *Resources) inspectFinalizerPodDrainDBServer(ctx context.Context, log ze
123123
}
124124

125125
// If this DBServer is cleaned out, we need to remove the PVC.
126-
if memberStatus.Conditions.IsTrue(api.ConditionTypeCleanedOut) {
126+
if memberStatus.Conditions.IsTrue(api.ConditionTypeCleanedOut) || memberStatus.Phase == api.MemberPhaseDrain {
127127
pvcs := r.context.GetKubeCli().CoreV1().PersistentVolumeClaims(r.context.GetNamespace())
128128
if err := pvcs.Delete(memberStatus.PersistentVolumeClaimName, &metav1.DeleteOptions{}); err != nil && !k8sutil.IsNotFound(err) {
129129
log.Warn().Err(err).Msg("Failed to delete PVC for member")

pkg/deployment/resources/pod_termination.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,15 @@ func (r *Resources) prepareDBServerPodTermination(ctx context.Context, log zerol
189189
// Not cleaned out yet, check member status
190190
if memberStatus.Conditions.IsTrue(api.ConditionTypeTerminated) || (memberStatus.Phase == api.MemberPhaseCreated && !k8sutil.IsPodReady(p)) {
191191
log.Warn().Msg("Member is already terminated before it could be cleaned out. Not good, but removing dbserver pod because we cannot do anything further")
192+
// At this point we have to set CleanedOut to true,
193+
// because we can no longer reason about the state in the agency and
194+
// bringing back the dbserver again may result in an cleaned out server without us knowing
195+
memberStatus.Conditions.Update(api.ConditionTypeCleanedOut, true, "Draining server failed", "")
196+
memberStatus.Phase = api.MemberPhaseCreated
197+
memberStatus.CleanoutJobID = ""
198+
if err := updateMember(memberStatus); err != nil {
199+
return maskAny(err)
200+
}
192201
return nil
193202
}
194203
if memberStatus.Phase == api.MemberPhaseCreated {

0 commit comments

Comments
 (0)