kubeadm: trim leading "v" when running CoreDNS migration preflight

During upgrade the coredns migration library seems to require
that the input version doesn't have the "v" prefix".

Fixes a bug where the user cannot run commands such as
"kubeadm upgrade plan" if they have `v1.8.0` installed.

Assuming this is caused by the fact that previously the image didn't
have a "v" prefix.
This commit is contained in:
Lubomir I. Ivanov
2021-01-11 18:17:50 +02:00
parent 94a623a45a
commit 3b5e698cb2
2 changed files with 4 additions and 0 deletions

View File

@@ -382,6 +382,7 @@ func isCoreDNSConfigMapMigrationRequired(corefile, currentInstalledCoreDNSVersio
if currentInstalledCoreDNSVersion == "" {
return isMigrationRequired, nil
}
currentInstalledCoreDNSVersion = strings.TrimLeft(currentInstalledCoreDNSVersion, "v")
deprecated, err := migration.Deprecated(currentInstalledCoreDNSVersion, strings.TrimLeft(kubeadmconstants.CoreDNSVersion, "v"), corefile)
if err != nil {
return isMigrationRequired, errors.Wrap(err, "unable to get list of changes to the configuration.")

View File

@@ -90,6 +90,8 @@ func checkUnsupportedPlugins(client clientset.Interface) error {
if err != nil {
return err
}
currentInstalledCoreDNSversion = strings.TrimLeft(currentInstalledCoreDNSversion, "v")
unsupportedCoreDNS, err := migration.Unsupported(currentInstalledCoreDNSversion, currentInstalledCoreDNSversion, corefile)
if err != nil {
return err
@@ -117,6 +119,7 @@ func checkMigration(client clientset.Interface) error {
return err
}
currentInstalledCoreDNSversion = strings.TrimLeft(currentInstalledCoreDNSversion, "v")
_, err = migration.Migrate(currentInstalledCoreDNSversion, strings.TrimLeft(kubeadmconstants.CoreDNSVersion, "v"), corefile, false)
if err != nil {
return errors.Wrap(err, "CoreDNS will not be upgraded")