Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
pooknull committed Feb 7, 2024
1 parent 8573d5b commit 7b5a420
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
5 changes: 2 additions & 3 deletions pkg/controller/pxcrestore/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
12 changes: 4 additions & 8 deletions pkg/controller/pxcrestore/restorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 7b5a420

Please sign in to comment.