Skip to content

Commit

Permalink
Be more resilient on failures
Browse files Browse the repository at this point in the history
Always fall back to use the most recent version of kubectl downloaded
when it's not possible to get the version of the remote kubernetes
server. No matter what happens.
  • Loading branch information
flavio committed May 24, 2020
1 parent 7cd66fc commit 6c3d6f0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions internal/versioner/versioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ func NewVersioner() *Versioner {
// and acts accordingly.
func (v *Versioner) KubectlVersionToUse() (semver.Version, error) {
version, err := v.apiServer.Version()
if err != nil && isTimeout(err) {
// the remote server is unreachable, let's get
// the latest version of kubectl that is available on the system
klog.Info("Remote kubernetes server unreachable")
if err != nil {
if isTimeout(err) {
// the remote server is unreachable, let's get
// the latest version of kubectl that is available on the system
klog.Info("Remote kubernetes server unreachable")
} else {
klog.Info(err)
}
version, err = v.MostRecentKubectlDownloaded()
if err != nil && isNoVersionFound(err) {
klog.Info("No local kubectl binary found, fetching latest stable release version")
Expand Down

0 comments on commit 6c3d6f0

Please sign in to comment.