@@ -24,6 +24,7 @@ import (
24
24
25
25
apierrors "k8s.io/apimachinery/pkg/api/errors"
26
26
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27
+ "k8s.io/apimachinery/pkg/fields"
27
28
errorsutil "k8s.io/apimachinery/pkg/util/errors"
28
29
"k8s.io/apimachinery/pkg/util/version"
29
30
clientset "k8s.io/client-go/kubernetes"
@@ -119,8 +120,15 @@ func removeOldDNSDeploymentIfAnotherDNSIsUsed(cfg *kubeadmapi.ClusterConfigurati
119
120
deploymentToDelete = kubeadmconstants .KubeDNSDeploymentName
120
121
}
121
122
122
- // If we're dry-running, we don't need to wait for the new DNS addon to become ready
123
- if ! dryRun {
123
+ nodes , err := client .CoreV1 ().Nodes ().List (context .TODO (), metav1.ListOptions {
124
+ FieldSelector : fields.Set {"spec.unschedulable" : "false" }.AsSelector ().String (),
125
+ })
126
+ if err != nil {
127
+ return err
128
+ }
129
+
130
+ // If we're dry-running or there are no scheduable nodes available, we don't need to wait for the new DNS addon to become ready
131
+ if ! dryRun && len (nodes .Items ) != 0 {
124
132
dnsDeployment , err := client .AppsV1 ().Deployments (metav1 .NamespaceSystem ).Get (context .TODO (), installedDeploymentName , metav1.GetOptions {})
125
133
if err != nil {
126
134
return err
@@ -132,7 +140,7 @@ func removeOldDNSDeploymentIfAnotherDNSIsUsed(cfg *kubeadmapi.ClusterConfigurati
132
140
133
141
// We don't want to wait for the DNS deployment above to become ready when dryrunning (as it never will)
134
142
// but here we should execute the DELETE command against the dryrun clientset, as it will only be logged
135
- err : = apiclient .DeleteDeploymentForeground (client , metav1 .NamespaceSystem , deploymentToDelete )
143
+ err = apiclient .DeleteDeploymentForeground (client , metav1 .NamespaceSystem , deploymentToDelete )
136
144
if err != nil && ! apierrors .IsNotFound (err ) {
137
145
return err
138
146
}
0 commit comments