diff --git a/pkg/controller/pxcrestore/controller.go b/pkg/controller/pxcrestore/controller.go index 63a4a3586e..114e32117a 100644 --- a/pkg/controller/pxcrestore/controller.go +++ b/pkg/controller/pxcrestore/controller.go @@ -194,8 +194,7 @@ func (r *ReconcilePerconaXtraDBClusterRestore) Reconcile(ctx context.Context, re case api.RestoreStopCluster: err = stopCluster(ctx, r.client, cluster.DeepCopy()) if err != nil { - switch err { - case errWaitingPods, errWaitingPVC: + if errors.Is(err, errWaitingPods) || errors.Is(err, errWaitingPVC) { log.Info("waiting for cluster to stop", "cluster", cr.Spec.PXCCluster, "msg", err.Error()) return rr, nil } @@ -253,7 +252,7 @@ func (r *ReconcilePerconaXtraDBClusterRestore) Reconcile(ctx context.Context, re } return rr, nil } else { - if cluster.Status.ObservedGeneration == cluster.Generation && cluster.Status.PXC.Status == api.AppStateReady { + if cluster.Status.ObservedGeneration != cluster.Generation || cluster.Status.PXC.Status != api.AppStateReady { log.Info("Waiting for cluster to start", "cluster", cluster.Name) return rr, nil } diff --git a/pkg/controller/pxcrestore/restorer.go b/pkg/controller/pxcrestore/restorer.go index b3d89a6503..7eb0697623 100644 --- a/pkg/controller/pxcrestore/restorer.go +++ b/pkg/controller/pxcrestore/restorer.go @@ -141,16 +141,12 @@ func (s *pvc) Init(ctx context.Context) error { initInProcess := true - if err := s.k8sClient.Get(ctx, types.NamespacedName{Name: svc.Name, Namespace: svc.Namespace}, svc); err != nil { - if k8serrors.IsNotFound(err) { - initInProcess = false - } + if err := s.k8sClient.Get(ctx, types.NamespacedName{Name: svc.Name, Namespace: svc.Namespace}, svc); k8serrors.IsNotFound(err) { + initInProcess = false } - if err := s.k8sClient.Get(ctx, types.NamespacedName{Name: pod.Name, Namespace: svc.Namespace}, pod); err != nil { - if k8serrors.IsNotFound(err) { - initInProcess = false - } + if err := s.k8sClient.Get(ctx, types.NamespacedName{Name: pod.Name, Namespace: svc.Namespace}, pod); k8serrors.IsNotFound(err) { + initInProcess = false } if !initInProcess {