Skip to content

Commit 76045d1

Browse files
committed
OCPBUGS-21777: baremetal: populate customDeploy in advance
Currently, we do not populate any deployment fields when creating BareMetalHosts, relying on the Machine API to do it instead. However, not setting customDeploy makes the BMH controller think that we're doing an image-based deployment and configure its resources accordingly. If MAPI is slow enough, the hosts become provisioned before customDeploy is set, and the controller enters a loop trying and failing to switch away from the image-based deployment. TL;DR just set customDeploy on creation.
1 parent 6b79ceb commit 76045d1

File tree

2 files changed

+38
-24
lines changed

2 files changed

+38
-24
lines changed

pkg/asset/machines/baremetal/hosts.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ func Hosts(config *types.InstallConfig, machines []machineapi.Machine) (*HostSet
141141
// with a machine without triggering provisioning. We only
142142
// want to do that for control plane hosts.
143143
newHost.Spec.ExternallyProvisioned = true
144+
// Setting CustomDeploy early ensures that the
145+
// corresponding Ironic node gets correctly configured
146+
// from the beginning.
147+
newHost.Spec.CustomDeploy = &baremetalhost.CustomDeploy{
148+
Method: "install_coreos",
149+
}
144150
// Pause reconciliation until we can annotate with the initial
145151
// status containing the HardwareDetails
146152
newHost.ObjectMeta.Annotations = map[string]string{"baremetalhost.metal3.io/paused": ""}

pkg/asset/machines/baremetal/hosts_test.go

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ routes:
6161

6262
ExpectedSetting: settings().
6363
secrets(secret("master-0-bmc-secret").creds("usr0", "pwd0")).
64-
hosts(host("master-0").consumerRef("machine-0").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned()).build(),
64+
hosts(host("master-0").consumerRef("machine-0").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy()).build(),
6565
},
6666
{
6767
Scenario: "default-norole",
@@ -70,7 +70,7 @@ routes:
7070

7171
ExpectedSetting: settings().
7272
secrets(secret("master-0-bmc-secret").creds("usr0", "pwd0")).
73-
hosts(host("master-0").consumerRef("machine-0").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned()).build(),
73+
hosts(host("master-0").consumerRef("machine-0").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy()).build(),
7474
},
7575
{
7676
Scenario: "network-config",
@@ -88,7 +88,8 @@ routes:
8888
consumerRef("machine-0").
8989
annotation("baremetalhost.metal3.io/paused", "").
9090
preprovisioningNetworkDataName("master-0-network-config-secret").
91-
externallyProvisioned()).build(),
91+
externallyProvisioned().
92+
customDeploy()).build(),
9293
},
9394
{
9495
Scenario: "3-hosts-3-machines-norole-all",
@@ -107,9 +108,9 @@ routes:
107108
secret("master-1-bmc-secret").creds("usr1", "pwd1"),
108109
secret("master-2-bmc-secret").creds("usr2", "pwd2")).
109110
hosts(
110-
host("master-0").consumerRef("machine-0").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned(),
111-
host("master-1").consumerRef("machine-1").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned(),
112-
host("master-2").consumerRef("machine-2").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned()).build(),
111+
host("master-0").consumerRef("machine-0").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy(),
112+
host("master-1").consumerRef("machine-1").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy(),
113+
host("master-2").consumerRef("machine-2").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy()).build(),
113114
},
114115
{
115116
Scenario: "4-hosts-3-machines",
@@ -130,9 +131,9 @@ routes:
130131
secret("master-2-bmc-secret").creds("usr2", "pwd2"),
131132
secret("master-3-bmc-secret").creds("usr3", "pwd3")).
132133
hosts(
133-
host("master-0").consumerRef("machine-0").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned(),
134-
host("master-1").consumerRef("machine-1").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned(),
135-
host("master-2").consumerRef("machine-2").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned(),
134+
host("master-0").consumerRef("machine-0").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy(),
135+
host("master-1").consumerRef("machine-1").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy(),
136+
host("master-2").consumerRef("machine-2").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy(),
136137
host("master-3")).build(),
137138
},
138139
{
@@ -154,9 +155,9 @@ routes:
154155
secret("master-2-bmc-secret").creds("usr2", "pwd2"),
155156
secret("worker-0-bmc-secret").creds("wrk0", "pwd0")).
156157
hosts(
157-
host("master-0").consumerRef("machine-0").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned(),
158-
host("master-1").consumerRef("machine-1").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned(),
159-
host("master-2").consumerRef("machine-2").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned(),
158+
host("master-0").consumerRef("machine-0").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy(),
159+
host("master-1").consumerRef("machine-1").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy(),
160+
host("master-2").consumerRef("machine-2").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy(),
160161
host("worker-0")).build(),
161162
},
162163
{
@@ -180,9 +181,9 @@ routes:
180181
secret("worker-0-bmc-secret").creds("wrk0", "pwd0"),
181182
secret("worker-1-bmc-secret").creds("wrk1", "pwd1")).
182183
hosts(
183-
host("master-0").consumerRef("machine-0").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned(),
184-
host("master-1").consumerRef("machine-1").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned(),
185-
host("master-2").consumerRef("machine-2").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned(),
184+
host("master-0").consumerRef("machine-0").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy(),
185+
host("master-1").consumerRef("machine-1").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy(),
186+
host("master-2").consumerRef("machine-2").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy(),
186187
host("worker-0"),
187188
host("worker-1")).build(),
188189
},
@@ -207,11 +208,11 @@ routes:
207208
secret("master-0-bmc-secret").creds("usr0", "pwd0"),
208209
secret("master-2-bmc-secret").creds("usr2", "pwd2")).
209210
hosts(
210-
host("master-1").consumerRef("machine-0").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned(),
211+
host("master-1").consumerRef("machine-0").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy(),
211212
host("worker-0"),
212213
host("worker-1"),
213-
host("master-0").consumerRef("machine-1").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned(),
214-
host("master-2").consumerRef("machine-2").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned()).build(),
214+
host("master-0").consumerRef("machine-1").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy(),
215+
host("master-2").consumerRef("machine-2").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy()).build(),
215216
},
216217
{
217218
Scenario: "4-hosts-3-machines-norole-master",
@@ -233,9 +234,9 @@ routes:
233234
secret("master-2-bmc-secret").creds("usr2", "pwd2")).
234235
hosts(
235236
host("worker-0"),
236-
host("master-0").consumerRef("machine-0").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned(),
237-
host("master-1").consumerRef("machine-1").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned(),
238-
host("master-2").consumerRef("machine-2").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned()).build(),
237+
host("master-0").consumerRef("machine-0").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy(),
238+
host("master-1").consumerRef("machine-1").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy(),
239+
host("master-2").consumerRef("machine-2").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy()).build(),
239240
},
240241
{
241242
Scenario: "4-hosts-3-machines-norole-worker",
@@ -256,9 +257,9 @@ routes:
256257
secret("master-2-bmc-secret").creds("usr2", "pwd2"),
257258
secret("worker-0-bmc-secret").creds("wrk0", "pwd0")).
258259
hosts(
259-
host("master-0").consumerRef("machine-0").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned(),
260-
host("master-1").consumerRef("machine-1").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned(),
261-
host("master-2").consumerRef("machine-2").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned(),
260+
host("master-0").consumerRef("machine-0").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy(),
261+
host("master-1").consumerRef("machine-1").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy(),
262+
host("master-2").consumerRef("machine-2").annotation("baremetalhost.metal3.io/paused", "").externallyProvisioned().customDeploy(),
262263
host("worker-0")).build(),
263264
},
264265
}
@@ -430,6 +431,13 @@ func (hb *hostBuilder) externallyProvisioned() *hostBuilder {
430431
return hb
431432
}
432433

434+
func (hb *hostBuilder) customDeploy() *hostBuilder {
435+
hb.Spec.CustomDeploy = &baremetalhost.CustomDeploy{
436+
Method: "install_coreos",
437+
}
438+
return hb
439+
}
440+
433441
func (hb *hostBuilder) annotation(key, value string) *hostBuilder {
434442
if hb.Annotations == nil {
435443
hb.Annotations = map[string]string{}

0 commit comments

Comments
 (0)