Skip to content

Commit

Permalink
Minor tweaks, first attempt of fixing the test.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhjanders committed Oct 16, 2024
1 parent 7eda476 commit 206eb33
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
Binary file not shown.
7 changes: 4 additions & 3 deletions controllers/metal3.io/baremetalhost_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1365,15 +1365,16 @@ func (r *BareMetalHostReconciler) checkServicing(prov provisioner.Provisioner, i
// (NOTE)janders: since Servicing is an opt-in feature that requires HostUpdatePolicy to be created and set to onReboot
// set below booleans to false by default and change to true based on policy settings

servicingData.LiveFirmwareSettingsAllowed = false
var LiveFirmwareSettingsAllowed bool
LiveFirmwareSettingsAllowed = false

if hup != nil {
if hup.Spec.FirmwareSettings == metal3api.HostUpdatePolicyOnReboot {
servicingData.LiveFirmwareSettingsAllowed = true
LiveFirmwareSettingsAllowed = true
}
}

if servicingData.LiveFirmwareSettingsAllowed {
if LiveFirmwareSettingsAllowed {
var hfs *metal3api.HostFirmwareSettings
var err error
dirty, hfs, err = r.getHostFirmwareSettings(info)
Expand Down
17 changes: 16 additions & 1 deletion controllers/metal3.io/baremetalhost_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/event"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"github.com/stretchr/testify/require"
)

const (
Expand Down Expand Up @@ -811,8 +812,22 @@ func TestRebootWithServicing(t *testing.T) {
VirtualizationEnabled: ptr.To(true),
}
host.Status.Provisioning.Image.URL = "foo"
hup := &metal3api.HostUpdatePolicy{
ObjectMeta: metav1.ObjectMeta{
Name: host.Name,
Namespace: namespace,
},
Spec: metal3api.HostUpdatePolicySpec{
FirmwareSettings: metal3api.HostUpdatePolicyOnReboot,
FirmwareUpdates: metal3api.HostUpdatePolicyOnReboot,
},
}

r := newTestReconciler(host)
r := newTestReconciler(host, hup)

err := r.Create(context.TODO(), hup)
require.NoError(t, err)
fmt.Printf("janders-hup-debug: HostUpdatePolicy object (no helper used): %+v", hup)

tryReconcile(t, r, host,
func(host *metal3api.BareMetalHost, result reconcile.Result) bool {
Expand Down
8 changes: 3 additions & 5 deletions pkg/provisioner/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,9 @@ type PrepareData struct {
}

type ServicingData struct {
FirmwareConfig *metal3api.FirmwareConfig
TargetFirmwareSettings metal3api.DesiredSettingsMap
ActualFirmwareSettings metal3api.SettingsMap
LiveFirmwareUpdateAllowed bool
LiveFirmwareSettingsAllowed bool
FirmwareConfig *metal3api.FirmwareConfig
TargetFirmwareSettings metal3api.DesiredSettingsMap
ActualFirmwareSettings metal3api.SettingsMap
// TargetFirmwareComponents []metal3api.FirmwareUpdate
}

Expand Down

0 comments on commit 206eb33

Please sign in to comment.