Skip to content

Commit 58e1f87

Browse files
authored
Merge branch 'main' into dependabot/go_modules/k8s.io/component-base-0.29.3
2 parents 229efe0 + 5483611 commit 58e1f87

File tree

7 files changed

+83
-66
lines changed

7 files changed

+83
-66
lines changed

api/v1beta1/tinkerbellmachine_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ type TinkerbellMachineSpec struct {
6161
ImageLookupOSVersion string `json:"imageLookupOSVersion,omitempty"`
6262

6363
// TemplateOverride overrides the default Tinkerbell template used by CAPT.
64-
// You can learn more about Tinkerbell templates here: https://docs.tinkerbell.org/templates/
64+
// You can learn more about Tinkerbell templates here: https://tinkerbell.org/docs/concepts/templates/
6565
// +optional
6666
TemplateOverride string `json:"templateOverride,omitempty"`
6767

config/crd/bases/infrastructure.cluster.x-k8s.io_tinkerbellmachines.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ spec:
236236
templateOverride:
237237
description: |-
238238
TemplateOverride overrides the default Tinkerbell template used by CAPT.
239-
You can learn more about Tinkerbell templates here: https://docs.tinkerbell.org/templates/
239+
You can learn more about Tinkerbell templates here: https://tinkerbell.org/docs/concepts/templates/
240240
type: string
241241
type: object
242242
status:

config/crd/bases/infrastructure.cluster.x-k8s.io_tinkerbellmachinetemplates.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ spec:
228228
templateOverride:
229229
description: |-
230230
TemplateOverride overrides the default Tinkerbell template used by CAPT.
231-
You can learn more about Tinkerbell templates here: https://docs.tinkerbell.org/templates/
231+
You can learn more about Tinkerbell templates here: https://tinkerbell.org/docs/concepts/templates/
232232
type: string
233233
type: object
234234
required:

controllers/machine_reconcile_scope.go

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"text/template"
2929

3030
"k8s.io/apimachinery/pkg/labels"
31+
"k8s.io/utils/ptr"
3132
"sigs.k8s.io/controller-runtime/pkg/client"
3233

3334
corev1 "k8s.io/api/core/v1"
@@ -49,8 +50,6 @@ import (
4950

5051
const (
5152
providerIDPlaceholder = "PROVIDER_ID"
52-
inUse = "in_use"
53-
provisioned = "provisioned"
5453
)
5554

5655
var (
@@ -107,7 +106,20 @@ func (scope *machineReconcileScope) addFinalizer() error {
107106
}
108107

109108
func isHardwareReady(hw *tinkv1.Hardware) bool {
110-
return hw.Spec.Metadata.State == inUse && hw.Spec.Metadata.Instance.State == provisioned
109+
// if allowpxe false for all interface, hardware ready
110+
if len(hw.Spec.Interfaces) == 0 {
111+
return false
112+
}
113+
114+
for _, ifc := range hw.Spec.Interfaces {
115+
if ifc.Netboot != nil {
116+
if *ifc.Netboot.AllowPXE {
117+
return false
118+
}
119+
}
120+
}
121+
122+
return true
111123
}
112124

113125
type errRequeueRequested struct{}
@@ -184,7 +196,7 @@ func (scope *machineReconcileScope) reconcile(hw *tinkv1.Hardware) error {
184196
return nil
185197
}
186198

187-
if err := scope.patchHardwareStates(hw, inUse, provisioned); err != nil {
199+
if err := scope.patchHardwareStates(hw, false); err != nil {
188200
return fmt.Errorf("failed to patch hardware: %w", err)
189201
}
190202

@@ -195,14 +207,17 @@ func (scope *machineReconcileScope) reconcile(hw *tinkv1.Hardware) error {
195207
}
196208

197209
// patchHardwareStates patches a hardware's metadata and instance states.
198-
func (scope *machineReconcileScope) patchHardwareStates(hw *tinkv1.Hardware, mdState, iState string) error {
210+
func (scope *machineReconcileScope) patchHardwareStates(hw *tinkv1.Hardware, allowpxe bool) error {
199211
patchHelper, err := patch.NewHelper(hw, scope.client)
200212
if err != nil {
201213
return fmt.Errorf("initializing patch helper for selected hardware: %w", err)
202214
}
203215

204-
hw.Spec.Metadata.State = mdState
205-
hw.Spec.Metadata.Instance.State = iState
216+
for _, ifc := range hw.Spec.Interfaces {
217+
if ifc.Netboot != nil {
218+
ifc.Netboot.AllowPXE = ptr.To(allowpxe)
219+
}
220+
}
206221

207222
if err := patchHelper.Patch(scope.ctx, hw); err != nil {
208223
return fmt.Errorf("patching Hardware object: %w", err)
@@ -716,12 +731,15 @@ func (scope *machineReconcileScope) releaseHardware(hardware *tinkv1.Hardware) e
716731

717732
delete(hardware.ObjectMeta.Labels, HardwareOwnerNameLabel)
718733
delete(hardware.ObjectMeta.Labels, HardwareOwnerNamespaceLabel)
719-
// setting these Metadata.State and Metadata.Instance.State = "" indicates to Boots
720-
// that this hardware should be allowed to netboot. FYI, this is not authoritative.
734+
// setting the AllowPXE=true indicates to Smee that this hardware should be allowed
735+
// to netboot. FYI, this is not authoritative.
721736
// Other hardware values can be set to prohibit netbooting of a machine.
722-
// See this Boots function for the logic around this: https://github.com/tinkerbell/boots/blob/main/job/dhcp.go#L115
723-
hardware.Spec.Metadata.State = ""
724-
hardware.Spec.Metadata.Instance.State = ""
737+
// See this Boots function for the logic around this: https://github.com/tinkerbell/smee/blob/main/internal/ipxe/script/ipxe.go#L112
738+
for _, ifc := range hardware.Spec.Interfaces {
739+
if ifc.Netboot != nil {
740+
ifc.Netboot.AllowPXE = ptr.To(true)
741+
}
742+
}
725743

726744
controllerutil.RemoveFinalizer(hardware, infrastructurev1.MachineFinalizer)
727745

controllers/tinkerbellmachine_controller_test.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ func validHardware(name, uuid, ip string, options ...testOptions) *tinkv1.Hardwa
190190
Address: ip,
191191
},
192192
},
193+
Netboot: &tinkv1.Netboot{
194+
AllowPXE: ptr.To(true),
195+
},
193196
},
194197
},
195198
Metadata: &tinkv1.HardwareMetadata{
@@ -417,7 +420,7 @@ func Test_Machine_reconciliation_with_available_hardware(t *testing.T) {
417420
g.Expect(updatedMachine.Status.Addresses).NotTo(BeEmpty(), "Machine status should be updated on every reconciliation")
418421
})
419422

420-
t.Run("in_use_states_are_not_set", func(t *testing.T) {
423+
t.Run("allowPXE_is_not_updated", func(t *testing.T) {
421424
t.Parallel()
422425
g := NewWithT(t)
423426

@@ -428,10 +431,7 @@ func Test_Machine_reconciliation_with_available_hardware(t *testing.T) {
428431

429432
updatedHardware := &tinkv1.Hardware{}
430433
g.Expect(client.Get(ctx, hardwareNamespacedName, updatedHardware)).To(Succeed())
431-
if diff := cmp.Diff(updatedHardware.Spec.Metadata.State, ""); diff != "" {
432-
t.Errorf(diff)
433-
}
434-
if diff := cmp.Diff(updatedHardware.Spec.Metadata.Instance.State, ""); diff != "" {
434+
if diff := cmp.Diff(updatedHardware.Spec.Interfaces[0].Netboot.AllowPXE, ptr.To(true)); diff != "" {
435435
t.Errorf(diff)
436436
}
437437
})
@@ -554,7 +554,7 @@ func Test_Machine_reconciliation_workflow_complete(t *testing.T) {
554554
g.Expect(updatedMachine.Status.Addresses).NotTo(BeEmpty(), "Machine status should be updated on every reconciliation")
555555
})
556556

557-
t.Run("in_use_states_are_set", func(t *testing.T) {
557+
t.Run("allowPXE_is_updated", func(t *testing.T) {
558558
t.Parallel()
559559
g := NewWithT(t)
560560

@@ -565,10 +565,7 @@ func Test_Machine_reconciliation_workflow_complete(t *testing.T) {
565565

566566
updatedHardware := &tinkv1.Hardware{}
567567
g.Expect(client.Get(ctx, hardwareNamespacedName, updatedHardware)).To(Succeed())
568-
if diff := cmp.Diff(updatedHardware.Spec.Metadata.State, "in_use"); diff != "" {
569-
t.Errorf(diff)
570-
}
571-
if diff := cmp.Diff(updatedHardware.Spec.Metadata.Instance.State, "provisioned"); diff != "" {
568+
if diff := cmp.Diff(updatedHardware.Spec.Interfaces[0].Netboot.AllowPXE, ptr.To(false)); diff != "" {
572569
t.Errorf(diff)
573570
}
574571
})

go.mod

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/tinkerbell/cluster-api-provider-tinkerbell
22

3-
go 1.21
3+
go 1.21.0
44

55
toolchain go1.21.2
66

@@ -10,7 +10,7 @@ require (
1010
github.com/google/go-cmp v0.6.0
1111
github.com/google/uuid v1.6.0
1212
github.com/onsi/ginkgo v1.16.5
13-
github.com/onsi/gomega v1.32.0
13+
github.com/onsi/gomega v1.33.1
1414
github.com/pkg/errors v0.9.1
1515
github.com/rs/zerolog v1.32.0
1616
github.com/spf13/pflag v1.0.5
@@ -24,7 +24,7 @@ require (
2424
k8s.io/utils v0.0.0-20231127182322-b307cd553661
2525
sigs.k8s.io/cluster-api v1.6.3
2626
sigs.k8s.io/controller-runtime v0.17.0
27-
sigs.k8s.io/kustomize/kustomize/v5 v5.3.0
27+
sigs.k8s.io/kustomize/kustomize/v5 v5.4.1
2828
sigs.k8s.io/yaml v1.4.0
2929
)
3030

@@ -70,17 +70,17 @@ require (
7070
github.com/xlab/treeprint v1.2.0 // indirect
7171
go.starlark.net v0.0.0-20231121155337-90ade8b19d09 // indirect
7272
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 // indirect
73-
golang.org/x/net v0.20.0 // indirect
73+
golang.org/x/net v0.24.0 // indirect
7474
golang.org/x/oauth2 v0.15.0 // indirect
75-
golang.org/x/sys v0.16.0 // indirect
76-
golang.org/x/term v0.16.0 // indirect
75+
golang.org/x/sys v0.19.0 // indirect
76+
golang.org/x/term v0.19.0 // indirect
7777
golang.org/x/text v0.14.0 // indirect
7878
golang.org/x/time v0.5.0 // indirect
79-
golang.org/x/tools v0.17.0 // indirect
79+
golang.org/x/tools v0.20.0 // indirect
8080
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
8181
google.golang.org/appengine v1.6.8 // indirect
8282
google.golang.org/protobuf v1.33.0 // indirect
83-
gopkg.in/evanphx/json-patch.v5 v5.7.0 // indirect
83+
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
8484
gopkg.in/inf.v0 v0.9.1 // indirect
8585
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
8686
gopkg.in/yaml.v2 v2.4.0 // indirect
@@ -89,8 +89,8 @@ require (
8989
k8s.io/cluster-bootstrap v0.29.0 // indirect
9090
k8s.io/kube-openapi v0.0.0-20231214164306-ab13479f8bf8 // indirect
9191
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
92-
sigs.k8s.io/kustomize/api v0.16.0 // indirect
93-
sigs.k8s.io/kustomize/cmd/config v0.13.0 // indirect
94-
sigs.k8s.io/kustomize/kyaml v0.16.0 // indirect
92+
sigs.k8s.io/kustomize/api v0.17.1 // indirect
93+
sigs.k8s.io/kustomize/cmd/config v0.14.0 // indirect
94+
sigs.k8s.io/kustomize/kyaml v0.17.0 // indirect
9595
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
9696
)

0 commit comments

Comments
 (0)