Skip to content

Commit

Permalink
[v13] Fix tsh kube login when creds are expired or doesn't exist
Browse files Browse the repository at this point in the history
Backports #31418 to branch/v13.

This PR uses `client.RetryWithRelogin` helper to deal with cases where user's
credentials don't exist or are already expired.
  • Loading branch information
tigrato authored and GavinFrazar committed Sep 19, 2023
1 parent 8b3a123 commit eb51705
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tool/tsh/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -1233,8 +1233,13 @@ func (c *kubeLoginCommand) run(cf *CLIConf) error {
return trace.Wrap(err)
}

// Check that this kube cluster exists.
kubeStatus, err := fetchKubeStatus(cf.Context, tc)
var kubeStatus *kubernetesStatus
err = client.RetryWithRelogin(cf.Context, tc, func() error {
// Check that this kube cluster exists.
var err error
kubeStatus, err = fetchKubeStatus(cf.Context, tc)
return trace.Wrap(err)
})
if err != nil {
return trace.Wrap(err)
}
Expand Down

0 comments on commit eb51705

Please sign in to comment.