Skip to content

Commit

Permalink
Add extra logs and increase verbosity of upgrade command for e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
panktishah26 committed Oct 3, 2023
1 parent bdd7a99 commit 774397b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions pkg/cluster/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Check failure on line 14 in pkg/cluster/wait.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with -s standard,default,prefix(github.com/aws/eks-anywhere) (gci)
)

// 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)
Expand All @@ -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{}

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cluster/wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 774397b

Please sign in to comment.