Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubeadm: add final fallback to constants.CurrentKubernetesVersion #72454

Merged
merged 1 commit into from Mar 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions cmd/kubeadm/app/util/version.go
Expand Up @@ -29,6 +29,7 @@ import (
netutil "k8s.io/apimachinery/pkg/util/net"
versionutil "k8s.io/apimachinery/pkg/util/version"
"k8s.io/klog"
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
pkgversion "k8s.io/kubernetes/pkg/version"
)

Expand Down Expand Up @@ -92,13 +93,20 @@ func KubernetesReleaseVersion(version string) (string, error) {
if body != "" {
return "", err
}
// Handle air-gapped environments by falling back to the client version.
klog.Infof("could not fetch a Kubernetes version from the internet: %v", err)
klog.Infof("falling back to the local client version: %s", clientVersion)
return KubernetesReleaseVersion(clientVersion)
if clientVersionErr == nil {
// Handle air-gapped environments by falling back to the client version.
klog.Warningf("could not fetch a Kubernetes version from the internet: %v", err)
klog.Warningf("falling back to the local client version: %s", clientVersion)
return KubernetesReleaseVersion(clientVersion)
}
}

if clientVersionErr != nil {
if err != nil {
klog.Warningf("could not obtain neither client nor remote version; fall back to: %s", constants.CurrentKubernetesVersion)
return KubernetesReleaseVersion(constants.CurrentKubernetesVersion.String())
}

klog.Warningf("could not obtain client version; using remote version: %s", body)
return KubernetesReleaseVersion(body)
}
Expand Down