mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #72454 from rojkov/kubeadm-fallback-version
kubeadm: add final fallback to constants.CurrentKubernetesVersion
This commit is contained in:
commit
5a6c66a729
@ -29,6 +29,7 @@ import (
|
|||||||
netutil "k8s.io/apimachinery/pkg/util/net"
|
netutil "k8s.io/apimachinery/pkg/util/net"
|
||||||
versionutil "k8s.io/apimachinery/pkg/util/version"
|
versionutil "k8s.io/apimachinery/pkg/util/version"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
|
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
pkgversion "k8s.io/kubernetes/pkg/version"
|
pkgversion "k8s.io/kubernetes/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -92,13 +93,20 @@ func KubernetesReleaseVersion(version string) (string, error) {
|
|||||||
if body != "" {
|
if body != "" {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
// Handle air-gapped environments by falling back to the client version.
|
if clientVersionErr == nil {
|
||||||
klog.Infof("could not fetch a Kubernetes version from the internet: %v", err)
|
// Handle air-gapped environments by falling back to the client version.
|
||||||
klog.Infof("falling back to the local client version: %s", clientVersion)
|
klog.Warningf("could not fetch a Kubernetes version from the internet: %v", err)
|
||||||
return KubernetesReleaseVersion(clientVersion)
|
klog.Warningf("falling back to the local client version: %s", clientVersion)
|
||||||
|
return KubernetesReleaseVersion(clientVersion)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if clientVersionErr != nil {
|
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)
|
klog.Warningf("could not obtain client version; using remote version: %s", body)
|
||||||
return KubernetesReleaseVersion(body)
|
return KubernetesReleaseVersion(body)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user