Merge pull request #88482 from rajansandeep/fixunsupported

[kubeadm]: Fix the CoreDNS preflight check for unsupported plugins
This commit is contained in:
Kubernetes Prow Robot 2020-02-26 19:39:33 -08:00 committed by GitHub
commit e61a878e6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 9 deletions

View File

@ -408,7 +408,7 @@ func migrateCoreDNSCorefile(client clientset.Interface, cm *v1.ConfigMap, corefi
}, metav1.UpdateOptions{}); err != nil {
return errors.Wrap(err, "unable to update the CoreDNS ConfigMap")
}
fmt.Println("[addons]: Migrating CoreDNS Corefile")
fmt.Println("[addons] Migrating CoreDNS Corefile")
changes, err := migration.Deprecated(currentInstalledCoreDNSVersion, kubeadmconstants.CoreDNSVersion, corefile)
if err != nil {
return errors.Wrap(err, "unable to get list of changes to the configuration.")

View File

@ -17,6 +17,7 @@ limitations under the License.
package upgrade
import (
"fmt"
"os"
"github.com/coredns/corefile-migration/migration"
@ -80,20 +81,21 @@ func checkUnsupportedPlugins(client clientset.Interface) error {
if err != nil {
return err
}
unsupportedCoreDNS, err := migration.Unsupported(currentInstalledCoreDNSversion, kubeadmconstants.CoreDNSVersion, corefile)
unsupportedCoreDNS, err := migration.Unsupported(currentInstalledCoreDNSversion, currentInstalledCoreDNSversion, corefile)
if err != nil {
return err
}
if unsupportedCoreDNS != nil {
var UnsupportedPlugins, UnsupportedVersion string
var UnsupportedPlugins []string
for _, unsup := range unsupportedCoreDNS {
UnsupportedPlugins = unsup.Plugin
UnsupportedVersion = unsup.Version
}
if UnsupportedPlugins != "" || UnsupportedVersion != "" {
return errors.New("there are unsupported plugins in the CoreDNS Corefile")
UnsupportedPlugins = append(UnsupportedPlugins, unsup.ToString())
}
fmt.Println("[preflight] The corefile contains plugins that kubeadm/CoreDNS does not know how to migrate. " +
"Each plugin listed should be manually verified for compatibility with the newer version of CoreDNS. " +
"Once ready, the upgrade can be initiated by skipping the preflight check. During the upgrade, " +
"kubeadm will migrate the configuration while leaving the listed plugin configs untouched, " +
"but cannot guarantee that they will work with the newer version of CoreDNS.")
return errors.Errorf("CoreDNS cannot migrate the following plugins:\n%s", UnsupportedPlugins)
}
return nil
}