@@ -2,7 +2,6 @@ package ps
22
33import (
44 "context"
5- "k8s.io/apimachinery/pkg/util/wait"
65 "time"
76
87 "github.com/pkg/errors"
@@ -11,6 +10,7 @@ import (
1110 k8serrors "k8s.io/apimachinery/pkg/api/errors"
1211 "k8s.io/apimachinery/pkg/labels"
1312 "k8s.io/apimachinery/pkg/types"
13+ "k8s.io/apimachinery/pkg/util/wait"
1414 k8sretry "k8s.io/client-go/util/retry"
1515 "sigs.k8s.io/controller-runtime/pkg/client"
1616 logf "sigs.k8s.io/controller-runtime/pkg/log"
@@ -33,6 +33,9 @@ func (r *PerconaServerMySQLReconciler) smartUpdate(ctx context.Context, sts *app
3333 Namespace : sts .Namespace ,
3434 }, currentSet )
3535 if err != nil {
36+ if k8serrors .IsNotFound (err ) {
37+ return nil
38+ }
3639 return errors .Wrap (err , "failed to get current sts" )
3740 }
3841
@@ -133,7 +136,6 @@ func (r *PerconaServerMySQLReconciler) smartUpdate(ctx context.Context, sts *app
133136 }
134137 return nil
135138 })
136-
137139 if err != nil {
138140 log .Info ("smart update of primary pod did not finish correctly after 5 retries" )
139141 return err
@@ -142,7 +144,6 @@ func (r *PerconaServerMySQLReconciler) smartUpdate(ctx context.Context, sts *app
142144 log .Info ("primary pod updated" , "pod" , primPod .Name )
143145 log .Info ("smart update finished" )
144146 return nil
145-
146147}
147148
148149func stsChanged (sts * appsv1.StatefulSet , pods []corev1.Pod ) bool {
@@ -151,7 +152,6 @@ func stsChanged(sts *appsv1.StatefulSet, pods []corev1.Pod) bool {
151152 for _ , pod := range pods {
152153 if pod .ObjectMeta .Labels ["controller-revision-hash" ] != sts .Status .UpdateRevision {
153154 return true
154-
155155 }
156156 }
157157
@@ -207,7 +207,6 @@ func deletePod(ctx context.Context, cli client.Client, pod *corev1.Pod, sts *app
207207
208208 if s .Status .ReadyReplicas == s .Status .Replicas {
209209 return errors .New ("sts.Status.readyReplicas not updated" )
210-
211210 }
212211
213212 return nil
0 commit comments