diff --git a/pkg/cluster/wait.go b/pkg/cluster/wait.go index d127fb9c85978..62181516a9a20 100644 --- a/pkg/cluster/wait.go +++ b/pkg/cluster/wait.go @@ -10,15 +10,15 @@ import ( anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1" "github.com/aws/eks-anywhere/pkg/clients/kubernetes" "github.com/aws/eks-anywhere/pkg/constants" - "github.com/aws/eks-anywhere/pkg/logger" "github.com/aws/eks-anywhere/pkg/retrier" + "github.com/go-logr/logr" ) // WaitForCondition blocks until either the cluster has this condition as True // or the retrier timeouts. If observedGeneration is not equal to generation, // the condition is considered false regardless of the status value. -func WaitForCondition(ctx context.Context, client kubernetes.Reader, cluster *anywherev1.Cluster, retrier *retrier.Retrier, conditionType anywherev1.ConditionType) error { - return WaitFor(ctx, client, cluster, retrier, func(c *anywherev1.Cluster) error { +func WaitForCondition(ctx context.Context, log logr.Logger, client kubernetes.Reader, cluster *anywherev1.Cluster, retrier *retrier.Retrier, conditionType anywherev1.ConditionType) error { + return WaitFor(ctx, log, client, cluster, retrier, func(c *anywherev1.Cluster) error { condition := conditions.Get(c, conditionType) if condition == nil { return fmt.Errorf("cluster doesn't yet have condition %s", conditionType) @@ -37,7 +37,7 @@ type Matcher func(*anywherev1.Cluster) error // WaitFor gets the cluster object from the client // checks for generation and observedGeneration condition // matches condition and returns error if the condition is not met. -func WaitFor(ctx context.Context, client kubernetes.Reader, cluster *anywherev1.Cluster, retrier *retrier.Retrier, matcher Matcher) error { +func WaitFor(ctx context.Context, log logr.Logger, client kubernetes.Reader, cluster *anywherev1.Cluster, retrier *retrier.Retrier, matcher Matcher) error { return retrier.Retry(func() error { c := &anywherev1.Cluster{} @@ -53,8 +53,7 @@ func WaitFor(ctx context.Context, client kubernetes.Reader, cluster *anywherev1. observedGeneration := c.Status.ObservedGeneration generation := c.Generation - log := logger.Get() - log.V(9).Info("cluster generation is %s and observedGeneration is %s", generation, observedGeneration) + log.V(9).Info("cluster generation and observedGeneration", "Generation", generation, "ObservedGeneration", observedGeneration) if observedGeneration != generation { return fmt.Errorf("cluster generation (%d) and observedGeneration (%d) differ", generation, observedGeneration) diff --git a/pkg/cluster/wait_test.go b/pkg/cluster/wait_test.go index fa1532f9767c7..9274686211369 100644 --- a/pkg/cluster/wait_test.go +++ b/pkg/cluster/wait_test.go @@ -145,7 +145,7 @@ func TestWaitForCondition(t *testing.T) { g := NewWithT(t) client := test.NewFakeKubeClient(tt.currentCluster) - gotErr := cluster.WaitForCondition(ctx, client, tt.clusterInput, tt.retrier, tt.condition) + gotErr := cluster.WaitForCondition(ctx, test.NewNullLogger(), client, tt.clusterInput, tt.retrier, tt.condition) if tt.wantErr != "" { g.Expect(gotErr).To(MatchError(tt.wantErr)) } else { @@ -254,7 +254,7 @@ func TestWaitFor(t *testing.T) { g := NewWithT(t) client := test.NewFakeKubeClient(tt.currentCluster) - gotErr := cluster.WaitFor(ctx, client, tt.clusterInput, tt.retrier, tt.matcher) + gotErr := cluster.WaitFor(ctx, test.NewNullLogger(), client, tt.clusterInput, tt.retrier, tt.matcher) if tt.wantErr != "" { g.Expect(gotErr).To(MatchError(tt.wantErr)) } else {