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 fbc9f58
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
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
22 changes: 20 additions & 2 deletions 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,25 @@ func TestRebootWithServicing(t *testing.T) {
VirtualizationEnabled: ptr.To(true),
}
host.Status.Provisioning.Image.URL = "foo"

r := newTestReconciler(host)
hup := &metal3api.HostUpdatePolicy{
TypeMeta: metav1.TypeMeta{
Kind: "HostUpdatePolicy",
APIVersion: "metal3.io/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: host.Name,
Namespace: namespace,
},
Spec: metal3api.HostUpdatePolicySpec{
FirmwareSettings: metal3api.HostUpdatePolicyOnReboot,
FirmwareUpdates: metal3api.HostUpdatePolicyOnReboot,
},
}
// hup.ResourceVersion = ""
r := newTestReconciler(host, hup)

Check failure on line 830 in controllers/metal3.io/baremetalhost_controller_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint / lint

commentedOutCode: may want to remove commented-out code (gocritic)
err := r.Update(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 fbc9f58

Please sign in to comment.