Skip to content

Commit 5a6c66a

Browse files
authored
Merge pull request kubernetes#72454 from rojkov/kubeadm-fallback-version
kubeadm: add final fallback to constants.CurrentKubernetesVersion
2 parents a8cbb22 + 9e25a00 commit 5a6c66a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

cmd/kubeadm/app/util/version.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
netutil "k8s.io/apimachinery/pkg/util/net"
3030
versionutil "k8s.io/apimachinery/pkg/util/version"
3131
"k8s.io/klog"
32+
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
3233
pkgversion "k8s.io/kubernetes/pkg/version"
3334
)
3435

@@ -92,13 +93,20 @@ func KubernetesReleaseVersion(version string) (string, error) {
9293
if body != "" {
9394
return "", err
9495
}
95-
// Handle air-gapped environments by falling back to the client version.
96-
klog.Infof("could not fetch a Kubernetes version from the internet: %v", err)
97-
klog.Infof("falling back to the local client version: %s", clientVersion)
98-
return KubernetesReleaseVersion(clientVersion)
96+
if clientVersionErr == nil {
97+
// Handle air-gapped environments by falling back to the client version.
98+
klog.Warningf("could not fetch a Kubernetes version from the internet: %v", err)
99+
klog.Warningf("falling back to the local client version: %s", clientVersion)
100+
return KubernetesReleaseVersion(clientVersion)
101+
}
99102
}
100103

101104
if clientVersionErr != nil {
105+
if err != nil {
106+
klog.Warningf("could not obtain neither client nor remote version; fall back to: %s", constants.CurrentKubernetesVersion)
107+
return KubernetesReleaseVersion(constants.CurrentKubernetesVersion.String())
108+
}
109+
102110
klog.Warningf("could not obtain client version; using remote version: %s", body)
103111
return KubernetesReleaseVersion(body)
104112
}

0 commit comments

Comments
 (0)