Skip to content

Commit

Permalink
bootstrap: add support for data secret
Browse files Browse the repository at this point in the history
We can configure bootstrap by setting `ConfigRef` or `DataSecretName`.
Here, we correct the logic that determines if bootstrapping is ready to
allow the data secret method as well as `ConfigRef`.

Signed-off-by: Honza Pokorny <[email protected]>
  • Loading branch information
honza committed Nov 12, 2024
1 parent 2073b84 commit 85179ba
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 5 additions & 1 deletion baremetal/metal3machine_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ func (m *MachineManager) IsProvisioned() bool {

// IsBootstrapReady checks if the machine is given Bootstrap data.
func (m *MachineManager) IsBootstrapReady() bool {
return m.Machine.Status.BootstrapReady
if m.Machine.Spec.Bootstrap.ConfigRef != nil {
return m.Machine.Status.BootstrapReady
}

return m.Machine.Spec.Bootstrap.DataSecretName != nil
}

// isControlPlane returns true if the machine is a control plane.
Expand Down
17 changes: 17 additions & 0 deletions baremetal/metal3machine_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ var _ = Describe("Metal3Machine manager", func() {
ExpectTrue bool
}

testCaseBootstrapReadySecretName := "secret"

DescribeTable("Test BootstrapReady",
func(tc testCaseBootstrapReady) {
machineMgr, err := NewMachineManager(nil, nil, nil, &tc.Machine, nil,
Expand All @@ -442,6 +444,11 @@ var _ = Describe("Metal3Machine manager", func() {
},
Entry("ready", testCaseBootstrapReady{
Machine: clusterv1.Machine{
Spec: clusterv1.MachineSpec{
Bootstrap: clusterv1.Bootstrap{
ConfigRef: &corev1.ObjectReference{},
},
},
Status: clusterv1.MachineStatus{
BootstrapReady: true,
},
Expand All @@ -452,6 +459,16 @@ var _ = Describe("Metal3Machine manager", func() {
Machine: clusterv1.Machine{},
ExpectTrue: false,
}),
Entry("ready data secret", testCaseBootstrapReady{
Machine: clusterv1.Machine{
Spec: clusterv1.MachineSpec{
Bootstrap: clusterv1.Bootstrap{
DataSecretName: &testCaseBootstrapReadySecretName,
},
},
},
ExpectTrue: true,
}),
)

DescribeTable("Test setting errors",
Expand Down

0 comments on commit 85179ba

Please sign in to comment.