@@ -29,6 +29,7 @@ import (
29
29
netutil "k8s.io/apimachinery/pkg/util/net"
30
30
versionutil "k8s.io/apimachinery/pkg/util/version"
31
31
"k8s.io/klog"
32
+ "k8s.io/kubernetes/cmd/kubeadm/app/constants"
32
33
pkgversion "k8s.io/kubernetes/pkg/version"
33
34
)
34
35
@@ -92,13 +93,20 @@ func KubernetesReleaseVersion(version string) (string, error) {
92
93
if body != "" {
93
94
return "" , err
94
95
}
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
+ }
99
102
}
100
103
101
104
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
+
102
110
klog .Warningf ("could not obtain client version; using remote version: %s" , body )
103
111
return KubernetesReleaseVersion (body )
104
112
}
0 commit comments