Log when the validation eventually succeeds.

Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
Matt Moyer 2021-03-05 16:59:43 -06:00
parent 4750d7d7d2
commit 73419313ee
No known key found for this signature in database
GPG Key ID: EAE88AD172C5AE2D

View File

@ -598,16 +598,19 @@ func validateKubeconfig(ctx context.Context, flags getKubeconfigParams, kubeconf
log.Info("could not immediately connect to the cluster but it may be initializing, will retry until timeout") log.Info("could not immediately connect to the cluster but it may be initializing, will retry until timeout")
deadline, _ := ctx.Deadline() deadline, _ := ctx.Deadline()
attempts := 0
for { for {
select { select {
case <-ctx.Done(): case <-ctx.Done():
return ctx.Err() return ctx.Err()
case <-ticker.C: case <-ticker.C:
attempts++
err := pingCluster() err := pingCluster()
if err == nil { if err == nil {
log.Info("validated connection to the cluster", "attempts", attempts)
return nil return nil
} }
log.Error(err, "could not connect to cluster, retrying...", "remaining", time.Until(deadline).Round(time.Second).String()) log.Error(err, "could not connect to cluster, retrying...", "attempts", attempts, "remaining", time.Until(deadline).Round(time.Second).String())
} }
} }
} }