Skip to content

Commit 969e237

Browse files
authored
Merge pull request #206 from acekingke/fix_bug_infinite_loop
api,cluster,sidecar: fix the bug for infinite loop #201, #219
2 parents b46225b + 99a1ff7 commit 969e237

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

api/v1alpha1/backup_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type BackupSpec struct {
3131

3232
// To specify the image that will be used for sidecar container.
3333
// +optional
34-
// +kubebuilder:default:="radondb/mysql-sidecar:0.1.88"
34+
// +kubebuilder:default:="radondb/mysql-sidecar:latest"
3535
Image string `json:"image"`
3636

3737
// HostName represents the host for which to take backup

cluster/syncer/statefulset.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,13 @@ func (s *StatefulSetSyncer) applyNWait(ctx context.Context, pod *corev1.Pod) err
510510
return true, nil
511511
}
512512

513+
// fix issue#219. When 2->5 rolling update, Because of PDB, minAvaliable 50%, if Spec Replicas is 5, sfs Spec first be set to 3, then to be set 5
514+
// pod healthy is yes,but controller-revision-hash will never correct, it must return,otherwise wait for 2 hours.
515+
// https://kubernetes.io/zh/docs/tasks/run-application/configure-pdb/
516+
if pod.ObjectMeta.Labels["healthy"] == "yes" &&
517+
pod.ObjectMeta.Labels["controller-revision-hash"] != s.sfs.Status.UpdateRevision {
518+
return false, fmt.Errorf("pod %s is ready, wait next schedule", pod.Name)
519+
}
513520
return false, nil
514521
})
515522
}

sidecar/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,15 +459,15 @@ done
459459
i=0
460460
while [ $i -lt %d ]; do
461461
if [ $i -ne %d ]; then
462-
while true; do
462+
for k in $(seq 12); do
463463
res=$(curl -i -X POST -d '{"address": "%s-'$i'.%s.%s:%d"}' -u root:%s http://%s:%d/v1/cluster/add)
464464
code=$(echo $res|grep "HTTP"|awk '{print $2}')
465465
if [ "$code" -eq "200" ]; then
466466
break
467467
fi
468468
done
469469
470-
while true; do
470+
for k in $(seq 12); do
471471
res=$(curl -i -X POST -d '{"address": "%s:%d"}' -u root:%s http://%s-$i.%s.%s:%d/v1/cluster/add)
472472
code=$(echo $res|grep "HTTP"|awk '{print $2}')
473473
if [ "$code" -eq "200" ]; then

0 commit comments

Comments
 (0)