Skip to content

Create and manage hostFirmwareSettings and firmwareSchema resources#938

Merged
metal3-io-bot merged 3 commits intometal3-io:masterfrom
bfournie:hostfirmwaresettingsandschema
Oct 6, 2021
Merged

Create and manage hostFirmwareSettings and firmwareSchema resources#938
metal3-io-bot merged 3 commits intometal3-io:masterfrom
bfournie:hostfirmwaresettingsandschema

Conversation

@bfournie
Copy link
Copy Markdown
Member

@bfournie bfournie commented Jul 13, 2021

After inspection the baremetalhost_controller retrieve BIOS settings from Ironic and will create the hostFirmwareSettings and firmwareSchema (if BIOS registry data is received) resources. In Preparing, any Spec settings that have been changed will be used to build clean_steps containing the BIOS settings. The changed values will be verified against the expected limits in the firmwareSchema, any failures will case an error in Preparing. The building of clean steps also uses the 3 BIOS settings that were added to the BMH CRD (#302).

The new hostfirmwarecontroller also does validation on the input values but only logs failures. As a follow-on PR, a validation webhook will be used to validate the input values.

See also metal3-io/metal3-docs#173

@metal3-io-bot metal3-io-bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 13, 2021
@bfournie bfournie changed the title Create and manage hostFirmwareSettings and firmwareSchema resources [WIP]Create and manage hostFirmwareSettings and firmwareSchema resources Jul 13, 2021
@metal3-io-bot metal3-io-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 13, 2021
@bfournie bfournie force-pushed the hostfirmwaresettingsandschema branch from 99046c3 to 4cc75d1 Compare July 13, 2021 19:49
@bfournie bfournie changed the title [WIP]Create and manage hostFirmwareSettings and firmwareSchema resources Create and manage hostFirmwareSettings and firmwareSchema resources Jul 13, 2021
@metal3-io-bot metal3-io-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 13, 2021
@bfournie
Copy link
Copy Markdown
Member Author

/test-integration

@bfournie bfournie force-pushed the hostfirmwaresettingsandschema branch from 4cc75d1 to f744f9f Compare July 13, 2021 22:11
@bfournie
Copy link
Copy Markdown
Member Author

/test-integration

@bfournie bfournie force-pushed the hostfirmwaresettingsandschema branch from f744f9f to b2e0b54 Compare July 14, 2021 20:27
@bfournie
Copy link
Copy Markdown
Member Author

/test-integration

@bfournie bfournie force-pushed the hostfirmwaresettingsandschema branch from b2e0b54 to 8a6033d Compare July 14, 2021 22:59
@bfournie
Copy link
Copy Markdown
Member Author

/test-integration

@bfournie bfournie force-pushed the hostfirmwaresettingsandschema branch 2 times, most recently from a31b9c2 to aa9509c Compare July 16, 2021 18:47
@bfournie
Copy link
Copy Markdown
Member Author

/test-integration

@bfournie bfournie force-pushed the hostfirmwaresettingsandschema branch from aa9509c to 0766e06 Compare July 16, 2021 18:58
@bfournie
Copy link
Copy Markdown
Member Author

/test-integration

Copy link
Copy Markdown
Member

@dtantsur dtantsur left a comment

Choose a reason for hiding this comment

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

I haven't finished the review, but here are some comments.

Comment thread apis/metal3.io/v1alpha1/firmwareschema_types.go Outdated
Comment thread apis/metal3.io/v1alpha1/firmwareschema_types.go Outdated
Comment thread apis/metal3.io/v1alpha1/firmwareschema_types.go Outdated
Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
Comment thread pkg/provisioner/ironic/ironic.go
Comment thread pkg/provisioner/ironic/ironic.go
@bfournie bfournie force-pushed the hostfirmwaresettingsandschema branch 5 times, most recently from cb2c990 to dfdf13f Compare July 25, 2021 21:10
@bfournie
Copy link
Copy Markdown
Member Author

/test-integration

@bfournie bfournie force-pushed the hostfirmwaresettingsandschema branch from dfdf13f to a206781 Compare July 26, 2021 20:40
@bfournie
Copy link
Copy Markdown
Member Author

/test-integration

Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
Comment thread controllers/metal3.io/baremetalhost_controller.go
Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
Comment thread pkg/provisioner/ironic/ironic.go
Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
@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 Aug 3, 2021
@bfournie
Copy link
Copy Markdown
Member Author

/test-integration

Comment thread apis/metal3.io/v1alpha1/firmwareschema_types.go Outdated
Comment thread apis/metal3.io/v1alpha1/firmwareschema_types.go Outdated
Comment thread pkg/provisioner/ironic/clients/client.go
Copy link
Copy Markdown
Member

@dtantsur dtantsur left a comment

Choose a reason for hiding this comment

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

I'm leaving a bunch of comments here. Most are nits except for two:

  1. A question/suggestion on API fields
  2. A concern about updating Spec automatically.

Comment thread apis/metal3.io/v1alpha1/firmwareschema_types.go Outdated
Comment thread apis/metal3.io/v1alpha1/firmwareschema_types.go Outdated
Comment thread apis/metal3.io/v1alpha1/firmwareschema_types.go Outdated
Comment thread apis/metal3.io/v1alpha1/firmwareschema_types.go Outdated
Comment thread apis/metal3.io/v1alpha1/firmwareschema_types.go Outdated
Comment thread controllers/metal3.io/hostfirmwaresettings_controller.go Outdated
Comment thread controllers/metal3.io/hostfirmwaresettings_controller.go Outdated
Comment thread controllers/metal3.io/hostfirmwaresettings_controller.go Outdated
Comment thread pkg/provisioner/ironic/ironic.go
Comment thread pkg/provisioner/ironic/ironic.go Outdated
@bfournie bfournie force-pushed the hostfirmwaresettingsandschema branch 2 times, most recently from 35f9dfc to 5265479 Compare September 23, 2021 15:32
Comment thread controllers/metal3.io/hostfirmwaresettings_controller.go
Comment thread controllers/metal3.io/hostfirmwaresettings_controller.go
Comment thread apis/metal3.io/v1alpha1/hostfirmwaresettings_types.go Outdated
@bfournie bfournie force-pushed the hostfirmwaresettingsandschema branch 2 times, most recently from 794bfa7 to b7a96e7 Compare September 28, 2021 11:11
Comment thread apis/metal3.io/v1alpha1/hostfirmwaresettings_types.go Outdated
Comment thread controllers/metal3.io/hostfirmwaresettings_controller.go
@bfournie bfournie force-pushed the hostfirmwaresettingsandschema branch from b7a96e7 to 3fa388b Compare September 28, 2021 21:57
@bfournie
Copy link
Copy Markdown
Member Author

/test-integration

@bfournie bfournie force-pushed the hostfirmwaresettingsandschema branch from 3fa388b to 23b89fb Compare September 29, 2021 16:48
@bfournie
Copy link
Copy Markdown
Member Author

/test-integration

@dtantsur
Copy link
Copy Markdown
Member

dtantsur commented Oct 4, 2021

/approve

Thanks!

@metal3-io-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dtantsur, elfosardo

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

The pull request process is described here

Details 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 Oct 4, 2021
@andfasano
Copy link
Copy Markdown
Member

Thanks for the effort @bfournie, it seems that all the points have been addressed.

/lgtm

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 6, 2021
@metal3-io-bot metal3-io-bot merged commit 3820040 into metal3-io:master Oct 6, 2021
@bfournie bfournie deleted the hostfirmwaresettingsandschema branch October 7, 2021 12:54
Copy link
Copy Markdown
Member

@zaneb zaneb left a comment

Choose a reason for hiding this comment

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

I don't see any code to move the state back to Preparing (from Ready) if the settings are out of date. We'll also need to watch the HostFirmwareSettings in the BMH controller so we'll see if the Spec changes while we're in the Ready state.

Re copying the Status fields to the Spec, I don't think ironic changing the fields is a problem because we were only going to do a copy if that field wasn't mentioned in the Spec, so it wouldn't overwrite an existing value. However, given that we're using a comparison of Spec and Status to determine when config has drifted, perhaps it's for the best if we only include values the user has specifically said they care about.

Comment thread controllers/metal3.io/baremetalhost_controller.go
Comment thread apis/metal3.io/v1alpha1/hostfirmwaresettings_types.go
Comment thread pkg/provisioner/ironic/ironic.go
Comment thread pkg/provisioner/ironic/ironic.go
if err = r.Get(ctx, req.NamespacedName, hfs); err != nil {
if k8serrors.IsNotFound(err) {
// A resource doesn't exist, create one
if err = r.newHostFirmwareSettings(info, req.NamespacedName); err != nil {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So this controller watches the BaremetalHost and automatically creates a HostFirmwareSettings object for it if it doesn't exist?

This is slightly unorthodox and will result in a lot of extra reconciles (every time the BMH changes we'll have to re-run this) but I guess it should be ok. We'll need to make doubly sure there are no unnecessary writes, otherwise we could get an infinite recursion between the two controllers.

Comment thread controllers/metal3.io/hostfirmwaresettings_controller.go
firmwareSchema = &metal3v1alpha1.FirmwareSchema{
ObjectMeta: metav1.ObjectMeta{
Name: schemaName,
Namespace: info.hfs.ObjectMeta.Namespace,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We talked about adding a CLI option to put these into a fixed namespace (regardless of which namespace the BMH is in) when the operator is running cluster-wide.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes that is still in plan as a follow on PR.

h.Write([]byte(fmt.Sprintf("%v", keys)))
hash := fmt.Sprintf("%x", h.Sum(nil))[:8]

return "schema-" + hash
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IIRC we decided to put the vendor and model in the name as well as the shortened hash. Did that turn out not to be feasible?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That ended up causing problems since the vendor and model come from introspection data and that may not have been retrieved yet when the resource is created. if its retrieved later the hashing will be incorrect.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I thought we wouldn't have the schema data available until after inspection either?
There is something to be said for not mixing data from two different sources though, since they could change independently.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There's not a dependency on inspection to get the schema data as we get the schema directly from the BMC while we get the inspection data from IPA. So yeah I don't we should use the vendor/model in the name.

func GetSchemaName(schema map[string]metal3v1alpha1.SettingSchema) string {

// Schemas from the same vendor and model should be identical for both keys and values.
// Hash the keys of the map to get a identifier unique to this schema.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not include the values as well? Just having the keys sounds like it would risk collisions between different firmware versions.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not sure if we would practically see differences in values but I'll add the values into the hash to prevent that happening.

Comment thread controllers/metal3.io/hostfirmwaresettings_controller.go
bfournie added a commit to bfournie/baremetal-operator that referenced this pull request Oct 14, 2021
Change to use the Preparing state end time as a trigger that cleaning
has just completed instead of relying on state difference. In addition,
the following changes were made to address follow-on comments in
metal3-io#938.
- added Preparing state to OperationalMetrics so its end time can be used for level-trigger
- split Status Settings into LocalData (ReadOnly or Unique fields) and writeable Settings
- changed name of condition `UpdateRequested` to `FirmwareSettingsChangeDetected`
- add each hostFirmwareSettings as owner of its FirmwareSchema so that garbage collection can be done
- Change the SetOwnerReference/SetControllerReference calls to before Create so the Update could be removed
- When building BIOS settings for cleaning make sure the hfs settings don't overwrite the vendor-agnostic settings
- When generating the hash for the firmwareSchema include the schema values in addition to the names in the hash
bfournie added a commit to bfournie/baremetal-operator that referenced this pull request Nov 8, 2021
Change to use the Preparing state end time as a trigger that cleaning
has just completed instead of relying on state difference. In addition,
the following changes were made to address follow-on comments in
metal3-io#938.
- added Preparing state to OperationalMetrics so its end time can be used for level-trigger
- split Status Settings into LocalData (ReadOnly or Unique fields) and writeable Settings
- changed name of condition `UpdateRequested` to `FirmwareSettingsChangeDetected`
- add each hostFirmwareSettings as owner of its FirmwareSchema so that garbage collection can be done
- Change the SetOwnerReference/SetControllerReference calls to before Create so the Update could be removed
- When building BIOS settings for cleaning make sure the hfs settings don't overwrite the vendor-agnostic settings
- When generating the hash for the firmwareSchema include the schema values in addition to the names in the hash
bfournie added a commit to bfournie/baremetal-operator that referenced this pull request Nov 19, 2021
Change to use the Preparing state end time as a trigger that cleaning
has just completed instead of relying on state difference. In addition,
the following changes were made to address follow-on comments in
metal3-io#938.
- added Preparing state to OperationalMetrics so its end time can be used for level-trigger
- split Status Settings into LocalData (ReadOnly or Unique fields) and writeable Settings
- changed name of condition `UpdateRequested` to `FirmwareSettingsChangeDetected`
- add each hostFirmwareSettings as owner of its FirmwareSchema so that garbage collection can be done
- Change the SetOwnerReference/SetControllerReference calls to before Create so the Update could be removed
- When building BIOS settings for cleaning make sure the hfs settings don't overwrite the vendor-agnostic settings
- When generating the hash for the firmwareSchema include the schema values in addition to the names in the hash
bfournie added a commit to bfournie/baremetal-operator that referenced this pull request Nov 19, 2021
Change to use the Preparing state end time as a trigger that cleaning
has just completed instead of relying on state difference. In addition,
the following changes were made to address follow-on comments in
metal3-io#938.
- added Preparing state to OperationalMetrics so its end time can be used for level-trigger
- split Status Settings into LocalData (ReadOnly or Unique fields) and writeable Settings
- changed name of condition `UpdateRequested` to `FirmwareSettingsChangeDetected`
- add each hostFirmwareSettings as owner of its FirmwareSchema so that garbage collection can be done
- Change the SetOwnerReference/SetControllerReference calls to before Create so the Update could be removed
- When building BIOS settings for cleaning make sure the hfs settings don't overwrite the vendor-agnostic settings
- When generating the hash for the firmwareSchema include the schema values in addition to the names in the hash
bfournie added a commit to bfournie/baremetal-operator that referenced this pull request Nov 22, 2021
Change to use the Preparing state end time as a trigger that cleaning
has just completed instead of relying on state difference. In addition,
the following changes were made to address follow-on comments in
metal3-io#938.
- added Preparing state to OperationalMetrics so its end time can be used for level-trigger
- split Status Settings into LocalData (ReadOnly or Unique fields) and writeable Settings
- changed name of condition `UpdateRequested` to `FirmwareSettingsChangeDetected`
- add each hostFirmwareSettings as owner of its FirmwareSchema so that garbage collection can be done
- Change the SetOwnerReference/SetControllerReference calls to before Create so the Update could be removed
- When building BIOS settings for cleaning make sure the hfs settings don't overwrite the vendor-agnostic settings
- When generating the hash for the firmwareSchema include the schema values in addition to the names in the hash
bfournie added a commit to bfournie/baremetal-operator that referenced this pull request Dec 2, 2021
Change to use the Preparing state end time as a trigger that cleaning
has just completed instead of relying on state difference. In addition,
the following changes were made to address follow-on comments in
metal3-io#938.
- added Preparing state to OperationalMetrics so its end time can be used for level-trigger
- split Status Settings into LocalData (ReadOnly or Unique fields) and writeable Settings
- changed name of condition `UpdateRequested` to `FirmwareSettingsChangeDetected`
- add each hostFirmwareSettings as owner of its FirmwareSchema so that garbage collection can be done
- Change the SetOwnerReference/SetControllerReference calls to before Create so the Update could be removed
- When building BIOS settings for cleaning make sure the hfs settings don't overwrite the vendor-agnostic settings
- When generating the hash for the firmwareSchema include the schema values in addition to the names in the hash
bfournie added a commit to bfournie/baremetal-operator that referenced this pull request Dec 8, 2021
Change to use the Preparing state end time as a trigger that cleaning
has just completed instead of relying on state difference. In addition,
the following changes were made to address follow-on comments in
metal3-io#938.
- added Preparing state to OperationalMetrics so its end time can be used for level-trigger
- split Status Settings into LocalData (ReadOnly or Unique fields) and writeable Settings
- changed name of condition `UpdateRequested` to `FirmwareSettingsChangeDetected`
- add each hostFirmwareSettings as owner of its FirmwareSchema so that garbage collection can be done
- Change the SetOwnerReference/SetControllerReference calls to before Create so the Update could be removed
- When building BIOS settings for cleaning make sure the hfs settings don't overwrite the vendor-agnostic settings
- When generating the hash for the firmwareSchema include the schema values in addition to the names in the hash
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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants