Skip to content

Commit 7074f28

Browse files
committed
retain corefile when migration fails
1 parent badcd4a commit 7074f28

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

cmd/kubeadm/app/phases/addons/dns/dns.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,12 @@ func createCoreDNSAddon(deploymentBytes, serviceBytes, configBytes []byte, clien
238238
}
239239
if IsCoreDNSConfigMapMigrationRequired(corefile) {
240240
if err := migrateCoreDNSCorefile(client, coreDNSConfigMap, corefile, currentInstalledCoreDNSVersion); err != nil {
241-
return err
241+
// Errors in Corefile Migration is verified during preflight checks. This part will be executed when a user has chosen
242+
// to ignore preflight check errors.
243+
klog.Warningf("the CoreDNS Configuration was not migrated: %v. The existing CoreDNS Corefile configuration has been retained.", err)
244+
if err := apiclient.CreateOrRetainConfigMap(client, coreDNSConfigMap, kubeadmconstants.CoreDNSConfigMap); err != nil {
245+
return err
246+
}
242247
}
243248
} else {
244249
if err := apiclient.CreateOrUpdateConfigMap(client, coreDNSConfigMap); err != nil {

cmd/kubeadm/app/phases/upgrade/preflight.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func checkMigration(client clientset.Interface) error {
108108

109109
_, err = migration.Migrate(currentInstalledCoreDNSversion, kubeadmconstants.CoreDNSVersion, corefile, false)
110110
if err != nil {
111-
return err
111+
return errors.Wrap(err, "the CoreDNS configuration will not be migrated, and may be incompatible with the upgraded version of CoreDNS")
112112
}
113113
return nil
114114
}

0 commit comments

Comments
 (0)