diff --git a/internal/controller/tortoise_controller.go b/internal/controller/tortoise_controller.go index 3afbcc4..db7afd1 100644 --- a/internal/controller/tortoise_controller.go +++ b/internal/controller/tortoise_controller.go @@ -242,7 +242,7 @@ func (r *TortoiseReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ } scalingActive, err := r.HpaService.CheckHpaMetricStatus(ctx, hpa) if err != nil { - if tortoise.Status.TortoisePhase == autoscalingv1beta3.TortoisePhaseWorking && hpaCreated == false { + if tortoise.Status.TortoisePhase == autoscalingv1beta3.TortoisePhaseWorking && !hpaCreated { logger.Error(err, "HPA status abnormal", "tortoise", req.NamespacedName) return ctrl.Result{}, err } diff --git a/pkg/tortoise/tortoise_test.go b/pkg/tortoise/tortoise_test.go index ef41637..d9609af 100644 --- a/pkg/tortoise/tortoise_test.go +++ b/pkg/tortoise/tortoise_test.go @@ -4706,7 +4706,10 @@ func TestService_UpdateTortoisePhaseIfHPAIsUnhealthy(t *testing.T) { lastTimeUpdateTortoise: make(map[client.ObjectKey]time.Time), } - s.UpdateTortoisePhaseIfHPAIsUnhealthy(context.Background(), tt.args.scalingActive, tt.args.t) + tt.args.t, err := s.UpdateTortoisePhaseIfHPAIsUnhealthy(context.Background(), tt.args.scalingActive, tt.args.t) + if err != nil { + t.Fatalf("failed to update tortoise phase: %v", err) + } if d := cmp.Diff(tt.args.t, tt.wantTortoise); d != "" { t.Errorf("UpdateTortoiseStatus() diff = %v", d) }