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

Do not encode empty hardwareRAIDVolumes #962

Closed
wants to merge 1 commit into from

Conversation

levsha
Copy link
Contributor

@levsha levsha commented Sep 1, 2021

hardwareRAIDVolumes is nil in some cases (probably when the platform of a host supports hardware raid but does not have any volumes configured). This translates to "null" in json representation and causes validation error because 'nil' and '[]' is not the same in Go:

Reconciler error,reconciler group:metal3.io,reconciler kind:BareMetalHost,name:sch05,namespace:cluster-sch,error:failed to save host status after "preparing": BareMetalHost.metal3.io "sch05" is invalid: status.provisioning.raid.hardwareRAIDVolumes: Invalid value: "null": status.provisioning.raid.hardwareRAIDVolumes in body must be of type array: "null",errorVerbose:BareMetalHost.metal3.io "sch05" is invalid: status.provisioning.raid.hardwareRAIDVolumes: Invalid value: "null": status.provisioning.raid.hardwareRAIDVolumes in body must be of type array: "null"
 failed to save host status after "preparing"
 github.com/metal3-io/baremetal-operator/controllers/metal3%2eio.(*BareMetalHostReconciler).Reconcile
 	/workspace/controllers/metal3.io/baremetalhost_controller.go:259
 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
 	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.9.0/pkg/internal/controller/controller.go:298
 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
 	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.9.0/pkg/internal/controller/controller.go:253
 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
 	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.9.0/pkg/internal/controller/controller.go:214
 runtime.goexit
 	/usr/local/go/src/runtime/asm_amd64.s:1371,stacktrace:sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
 	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.9.0/pkg/internal/controller/controller.go:253
 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
 	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.9.0/pkg/internal/controller/controller.go:214

Omitting empty values fixes this error.
The field had "omitempty" previously, but it was removed in https://github.com/metal3-io/baremetal-operator/pull/908/files#diff-0f3e356f6156566888fdbc0e7c0fa713ee054933106059fc29f702f8d1a554f2L289

@metal3-io-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign hardys after the PR has been reviewed.
You can assign the PR to them by writing /assign @hardys in a comment when ready.

The full list of commands accepted by this bot can be found 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 1, 2021
@metal3-io-bot
Copy link
Contributor

Hi @levsha. Thanks for your PR.

I'm waiting for a metal3-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@metal3-io-bot metal3-io-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 1, 2021
@s3rj1k
Copy link
Member

s3rj1k commented Sep 1, 2021

/ok-to-test

@levsha Seems that PR could be rebased to include single commit

@metal3-io-bot metal3-io-bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 1, 2021
@metal3-io-bot metal3-io-bot added needs-rebase Indicates that a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 1, 2021
'nil' becomes 'null' after encoding and this does not pass the schema
validation that allows arrays only.
@metal3-io-bot metal3-io-bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed needs-rebase Indicates that a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 1, 2021
@s3rj1k
Copy link
Member

s3rj1k commented Sep 1, 2021

/test-integration

@levsha
Copy link
Contributor Author

levsha commented Sep 1, 2021

/ok-to-test

@levsha Seems that PR could be rebased to include single commit

Done. Thanks for pointing out!

@zaneb zaneb requested a review from Hellcatlk September 2, 2021 16:28
@zaneb
Copy link
Member

zaneb commented Sep 2, 2021

It was removed for a reason though. @Hellcatlk is there any code that is relying on distinguishing between null/missing and []? If so we may have to change this to a pointer-to-slice (i.e. *[]HardwareRAIDVolume)

Also there's no reason to think that the SoftwareRAIDVolume wouldn't have the same issue.

/hold

@metal3-io-bot metal3-io-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 2, 2021
@jplimack
Copy link

jplimack commented Sep 2, 2021

@zaneb yes, it does also effect the softwareRAIDvolume. setting that to an empty array in the bmh spec gets around it. its also effecting the status field

Invalid value: \"null\": status.provisioning.raid.softwareRAIDVolumes in body must be of type array: \"null\"\nfailed to save host status after \"deprovisioning\"

@Hellcatlk
Copy link
Member

@Hellcatlk is there any code that is relying on distinguishing between null/missing and []?

BuildRAIDCleanSteps and saveHostProvisioningSettings rely on distinguishing between empty/missing and [].

@zaneb
Copy link
Member

zaneb commented Sep 3, 2021

Thanks, that's what I thought. This won't work then. I think the only solution is to add a comment like:

// +nullable

to each field. This will cause a change to the CRD.

@levsha
Copy link
Contributor Author

levsha commented Sep 5, 2021

I can confirm that marking both fields as 'nullable' helps (and that 'omitempty' does not help - the original error disappears but then BMH just switches between 'ready' <-> 'preparing' forever, never goes to 'provisioning').

@levsha
Copy link
Contributor Author

levsha commented Sep 5, 2021

#966

@zaneb
Copy link
Member

zaneb commented Sep 8, 2021

/close
in favour of #966

@metal3-io-bot
Copy link
Contributor

@zaneb: Closed this PR.

In response to this:

/close
in favour of #966

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.

@metal3-io-bot
Copy link
Contributor

@levsha: PR needs rebase.

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.

@metal3-io-bot metal3-io-bot added the needs-rebase Indicates that a PR cannot be merged because it has merge conflicts with HEAD. label Sep 8, 2021
@levsha levsha deleted the allow-empty-hw-raid-volumes branch September 9, 2021 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates that a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants