Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix Status logic for HostFirmwareComponents #1695

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

iurygregory
Copy link
Member

  • Make Updates and Components optional in HostFirmwareComponentsStatus, so we don't get errors when they are empty.
  • The UpdatedAt field for FirmwareComponentStatus can be nil, this caused runtime error in the BMO. Now we check the field before adding it.

What this PR does / why we need it: metal3-io/metal3-docs#364

@metal3-io-bot metal3-io-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 23, 2024
@iurygregory
Copy link
Member Author

/assign @dtantsur @honza

@iurygregory
Copy link
Member Author

/test metal3-bmo-e2e-test-pull

@iurygregory
Copy link
Member Author

/test metal3-centos-e2e-integration-test-main

@dtantsur
Copy link
Member

/approve

@metal3-io-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dtantsur

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@metal3-io-bot metal3-io-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 23, 2024
@iurygregory
Copy link
Member Author

/test metal3-bmo-e2e-test-pull

@iurygregory
Copy link
Member Author

/test metal3-centos-e2e-integration-test-main

@iurygregory
Copy link
Member Author

/test metal3-bmo-e2e-test-pull

@honza
Copy link
Member

honza commented Apr 23, 2024

/lgtm

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 23, 2024
@honza
Copy link
Member

honza commented Apr 23, 2024

/ok-to-test

@metal3-io-bot metal3-io-bot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Apr 23, 2024
@metal3-io-bot metal3-io-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 23, 2024
@iurygregory
Copy link
Member Author

/test metal3-centos-e2e-integration-test-main
/test metal3-bmo-e2e-test-pull

@iurygregory
Copy link
Member Author

The panic in the BMO log seems valid but the fact it shows L161 (which is a comment is a bit weird)...

github.com/metal3-io/baremetal-operator/pkg/provisioner/ironic.(*ironicProvisioner).GetFirmwareComponents(0xc000478200)
	/workspace/pkg/provisioner/ironic/ironic.go:1171 +0x222
github.com/metal3-io/baremetal-operator/controllers/metal3%2eio.(*HostFirmwareComponentsReconciler).Reconcile(0xc0001d6f40, {0x1bb6050?, 0xc0008588d0}, {{{0xc0007e6760, 0x6}, {0xc0007e6756, 0x6}}})
	/workspace/controllers/metal3.io/hostfirmwarecomponents_controller.go:161 +0x90c

/test metal3-centos-e2e-integration-test-main

apis/metal3.io/v1alpha1/hostfirmwarecomponents_types.go Outdated Show resolved Hide resolved
controllers/metal3.io/hostfirmwarecomponents_controller.go Outdated Show resolved Hide resolved
@@ -1162,21 +1162,21 @@ func (p *ironicProvisioner) GetFirmwareComponents() ([]metal3api.FirmwareCompone
if !p.availableFeatures.HasFirmwareUpdates() {
return nil, fmt.Errorf("current ironic version does not support firmware updates")
}

// Setting to 2 since we only support bmc and bios
componentsInfo := make([]metal3api.FirmwareComponentStatus, 0, 2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inefficiency of writing the simpler componentsInfo := []metal3api.FirmwareComponentsStatus{} (or var componentsInfo []metal3api.FirmwareComponentsStatus) here is dwarfed by the inefficiency of storing wholes structs instead of pointers in the array, so all the data has to be copied every time it is passed around.

pkg/provisioner/ironic/ironic.go Show resolved Hide resolved
controllers/metal3.io/hostfirmwarecomponents_controller.go Outdated Show resolved Hide resolved
pkg/provisioner/ironic/ironic.go Outdated Show resolved Hide resolved
@iurygregory
Copy link
Member Author

/test metal3-centos-e2e-integration-test-main
/test metal3-bmo-e2e-test-pull

@iurygregory
Copy link
Member Author

/test metal3-centos-e2e-integration-test-main
/test metal3-bmo-e2e-test-pull

@iurygregory
Copy link
Member Author

/test metal3-centos-e2e-integration-test-main
/test metal3-bmo-e2e-test-pull

@iurygregory
Copy link
Member Author

/test metal3-centos-e2e-integration-test-main

Make Updates and Components optional in HostFirmwareComponentsStatus,
so we don't get errors when they are empty.

The UpdatedAt field for FirmwareComponentStatus can be nil, this
caused runtime error in the BMO.

Change logic in GetFirmwareComponents, so we fail earlier in case
is not supported, now we raise a specific error
ErrFirmwareUpdateUnsupported.

Simplify the logic in the Controller, so we handle conditions in only
one function

Signed-off-by: Iury Gregory Melo Ferreira <imelofer@redhat.com>
@iurygregory
Copy link
Member Author

/test metal3-centos-e2e-integration-test-main
/test metal3-bmo-e2e-test-pull

@elfosardo
Copy link
Member

/lgtm

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 29, 2024
@metal3-io-bot metal3-io-bot merged commit 9af9c80 into metal3-io:main Apr 29, 2024
17 checks passed
@tuminoid
Copy link
Member

/cherry-pick release-0.6

As agreed @kashifest and @dtantsur

@metal3-io-bot
Copy link
Contributor

@tuminoid: new pull request created: #1749

In response to this:

/cherry-pick release-0.6

As agreed @kashifest and @dtantsur

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants