Skip to content

Commit

Permalink
api,cluster,sidecar: fix the bug for infinite loop radondb#201,radond…
Browse files Browse the repository at this point in the history
  • Loading branch information
acekingke committed Sep 16, 2021
1 parent 64eb02b commit 8037a99
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha1/backup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type BackupSpec struct {

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

// HostName represents the host for which to take backup
Expand Down
7 changes: 7 additions & 0 deletions cluster/syncer/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,13 @@ func (s *StatefulSetSyncer) applyNWait(ctx context.Context, pod *corev1.Pod) err
return true, nil
}

// Because of PDB, minAvaliable 50%, if Spec Replicas is 5, sfs Spec first be set to 3, then to be set 5
// pod healthy is yes,but controller-revision-hash will never correct, it must return,otherwise wait for 2 hours.
// https://kubernetes.io/zh/docs/tasks/run-application/configure-pdb/
if pod.ObjectMeta.Labels["healthy"] == "yes" &&
pod.ObjectMeta.Labels["controller-revision-hash"] != s.sfs.Status.UpdateRevision {
return false, fmt.Errorf("pod %s is ready, wait next schedule", pod.Name)
}
return false, nil
})
}
Expand Down
4 changes: 2 additions & 2 deletions sidecar/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,15 +459,15 @@ done
i=0
while [ $i -lt %d ]; do
if [ $i -ne %d ]; then
while true; do
for k in $(seq 12); do
res=$(curl -i -X POST -d '{"address": "%s-'$i'.%s.%s:%d"}' -u root:%s http://%s:%d/v1/cluster/add)
code=$(echo $res|grep "HTTP"|awk '{print $2}')
if [ "$code" -eq "200" ]; then
break
fi
done
while true; do
for k in $(seq 12); do
res=$(curl -i -X POST -d '{"address": "%s:%d"}' -u root:%s http://%s-$i.%s.%s:%d/v1/cluster/add)
code=$(echo $res|grep "HTTP"|awk '{print $2}')
if [ "$code" -eq "200" ]; then
Expand Down

0 comments on commit 8037a99

Please sign in to comment.