Skip to content

Add support for detached annotation #827

Merged
metal3-io-bot merged 4 commits intometal3-io:masterfrom
hardys:unmanaged_annotation
Apr 7, 2021
Merged

Add support for detached annotation #827
metal3-io-bot merged 4 commits intometal3-io:masterfrom
hardys:unmanaged_annotation

Conversation

@hardys
Copy link
Copy Markdown
Member

@hardys hardys commented Mar 23, 2021

This allows a new annotation as discussed in metal3-io/metal3-docs#168

baremetalhost.metal3.io/unmanaged

EDIT1 this has now been renamed to "deregistered" for both the annotation and OperationalStatus - I'll update the docs PR and this description when we've reached consensus on that new name.

EDIT2 ...then renamed again to "detached"

When set this puts the BMH OperationalStatus into a "unmanaged",
which removes the host from the underlying provisioner (without
deprovisioning)

When the annotation removed the BMH can resume management without
any disruptive actions (the previous Provisioning State is maintained)

@metal3-io-bot metal3-io-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 23, 2021
@hardys
Copy link
Copy Markdown
Member Author

hardys commented Mar 23, 2021

/cc @zaneb @dhellmann @andfasano

@hardys
Copy link
Copy Markdown
Member Author

hardys commented Mar 23, 2021

WIP as I'd like to confirm we're happy with having both an Unmanaged ProvisioningState, and an unmanaged OperationalStatus - initially I was thinking this may be confusing, but the behavior is quite similar (in both cases we skip management by the provisioner), the main difference is the OperationalStatus is independent of the provisioning state, which I think is what we want?

Also needs tests/docs, and I'll refactor the new code into a function from the Reconcile()

@hardys
Copy link
Copy Markdown
Member Author

hardys commented Mar 23, 2021

/cc @maelk @fmuyassarov - this leaves the existing paused annotation behavior intact, and allows for a pivot where the BMH resources remain as inventory on the parent cluster.

In the community meeting we discussed the CAPI pivot process, can you confirm if this approach will be acceptable from that perspective since it's not impacting any existing APIs?

Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
@fmuyassarov
Copy link
Copy Markdown
Member

/cc @maelk @fmuyassarov - this leaves the existing paused annotation behavior intact, and allows for a pivot where the BMH resources remain as inventory on the parent cluster.

In the community meeting we discussed the CAPI pivot process, can you confirm if this approach will be acceptable from that perspective since it's not impacting any existing APIs?

I believe it is okay, since this patch is not touching the pause annotation and logic in Reconcile().
/cc @kashifest

@metal3-io-bot metal3-io-bot requested a review from kashifest March 24, 2021 12:02
@kashifest
Copy link
Copy Markdown
Member

/cc @maelk @fmuyassarov - this leaves the existing paused annotation behavior intact, and allows for a pivot where the BMH resources remain as inventory on the parent cluster.

In the community meeting we discussed the CAPI pivot process, can you confirm if this approach will be acceptable from that perspective since it's not impacting any existing APIs?

As long as paused and status Annotation behavior is intact, CAPI pivot process should be good IMO.

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 apis/metal3.io/v1alpha1/baremetalhost_types.go Outdated
Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
@hardys hardys force-pushed the unmanaged_annotation branch from 41c1ba9 to 686e263 Compare March 25, 2021 20:09
@hardys hardys changed the title WIP: Add support for unmanaged annotation WIP: Add support for deregistered annotation Mar 25, 2021
@hardys
Copy link
Copy Markdown
Member Author

hardys commented Mar 25, 2021

@zaneb @andfasano I reworked this to the state machine as suggested, the new provisioner API (and docs/tests) are still TODO.

PTAL, if you're happy with this revised approach I'll proceed with the remaining pieces - thanks!

Comment thread controllers/metal3.io/action_result.go Outdated
Comment thread controllers/metal3.io/host_state_machine.go Outdated

// Deregistered is the annotation which stops provisioner management of the host
// unlike in the paused case, the host status may be updated
DeregisteredAnnotation = "baremetalhost.metal3.io/deregistered"
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 got out the thesaurus and here is some more suggestions in order of my preference:

  1. disengage
  2. dissociate
  3. detach

To put this in perspective, here are some other words I am not suggesting (you're welcome):

  • sunder
  • unloose
  • disjoin
  • uncouple
  • dissever

Copy link
Copy Markdown
Member Author

@hardys hardys Mar 26, 2021

Choose a reason for hiding this comment

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

Argh! If only Unmanaged and paused weren't already in use! 😆

After thinking about the name I reached the conclusion that deregistered reflects the internal state quite well (and it was definitely confusing having a State and OperationalStatus both called unmanaged after I moved the code into the same file).

Then it seemed weird to dislocate that naming convention at the annotation level, so I just renamed it, and personally I think deregistered is an OK name - given that the two most obvious alternatives are already in use?

With the benefit of hindsight we should perhaps have called the paused annotation frozen or something, but ultimately we just have to pick a name then document what it does.

I don't want to burn a bunch more cycles on the naming, but does anyone else have strong opinions on this?

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.

Not a strong one, my inclination would be more on detach rather then deregister - just because we already have a Registering state, and to me sounds as something related. detach gives me more the idea of a BMH still alive but "detached" from an Ironic node.

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.

BTW I intended "disengage" in the sense of a gearbox. We're basically putting it in neutral so you can attach another engine for a bit. It's quite a nice analogy, at least if you get a chance to explain it to the user ;D
My only concern with "detach", and why I listed it in 3rd place, is that it is more prone to conflicts with other things like networks or volumes (i.e. it risks repeating the same mistake we have made with "paused" and "unmanaged"). I still prefer it to "deregister" though.
"Deregister" makes sense if you understand the inside baseball (i.e. that there's a separate volatile data store, that existence of an entry in this datastore means that the power state will be continuously monitored, and that when this data store is cleared we silently re-register existing hosts in it.) However, to a user looking in from the outside and seeing only the API, I think it makes little sense at best, and at worst is actively misleading by implying that it resets the state back to the time before "registration".

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.

Ugh. Naming is hard 😞

@dhellmann @maelk @fmuyassarov - any preference before I rename this again?

FWIW my vote is for detached - I take the point about potential overlap with networking/storage things @zaneb but in the context of the BMH resource that's probably not very likely, right?

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.

Changed to detached in the latest revision

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.

that's probably not very likely, right?

🤣

metal3-io/metal3-docs#132

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's probably not very likely, right?

rofl

metal3-io/metal3-docs#132

Thanks I missed that - and it adds a ports API to the BMH spec - I'm not sure that's a good idea, I was thinking any such additions would have new CRDs, and thus not overlap with BMH things, but it seems I've been wildly optimistic there.

Comment thread controllers/metal3.io/host_state_machine.go Outdated
Comment thread controllers/metal3.io/host_state_machine.go Outdated
Comment thread controllers/metal3.io/host_state_machine.go Outdated
Comment thread controllers/metal3.io/host_state_machine.go Outdated
Comment thread controllers/metal3.io/host_state_machine.go Outdated
Comment thread controllers/metal3.io/host_state_machine.go Outdated
@hardys hardys force-pushed the unmanaged_annotation branch from 686e263 to bc4f7b5 Compare March 29, 2021 16:47
hardys pushed a commit to hardys/baremetal-operator that referenced this pull request Mar 30, 2021
This currently does the same as Delete but as mentioned in
review of metal3-io#827 semantically this is a different action and
should have a separate API call in the Provisioner interface
@hardys hardys force-pushed the unmanaged_annotation branch from bc4f7b5 to 8de5130 Compare March 30, 2021 15:21
@metal3-io-bot metal3-io-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 30, 2021
@hardys hardys changed the title WIP: Add support for deregistered annotation WIP: Add support for detached annotation Mar 31, 2021
@hardys
Copy link
Copy Markdown
Member Author

hardys commented Mar 31, 2021

/retitle Add support for detached annotation

@metal3-io-bot metal3-io-bot changed the title WIP: Add support for detached annotation Add support for detached annotation Mar 31, 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 Mar 31, 2021
@hardys
Copy link
Copy Markdown
Member Author

hardys commented Mar 31, 2021

/test-integration

@hardys hardys force-pushed the unmanaged_annotation branch 2 times, most recently from bc54963 to 26dd0b1 Compare April 6, 2021 09:27
Comment thread controllers/metal3.io/host_state_machine.go
@hardys
Copy link
Copy Markdown
Member Author

hardys commented Apr 6, 2021

/test-integration

Comment thread controllers/metal3.io/host_state_machine.go
Comment thread controllers/metal3.io/baremetalhost_controller.go
Comment thread controllers/metal3.io/host_state_machine.go
Comment thread controllers/metal3.io/host_state_machine.go Outdated
Comment thread controllers/metal3.io/host_state_machine.go
// Note this doesn't change the current state, only the OperationalStatus
annotations := hsm.Host.GetAnnotations()
if annotations != nil {
if _, ok := annotations[metal3v1alpha1.DetachedAnnotation]; ok {
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.

nit: a hasDetachedAnnotation() convenience function wouldn't hurt.

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.

Done, I added a local function for now, but this seems to be a recurring pattern, so perhaps we can refactor to add a shared host.HasAnnotation() in future (I didn't attempt it here because it means moving some annotation constants which feels outside the scope of this series).

Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
Comment thread controllers/metal3.io/host_state_machine_test.go
Comment thread controllers/metal3.io/baremetalhost_controller.go
Comment thread controllers/metal3.io/host_state_machine_test.go Outdated
Comment thread controllers/metal3.io/host_state_machine_test.go
Comment thread controllers/metal3.io/host_state_machine_test.go Outdated
Comment thread controllers/metal3.io/host_state_machine_test.go Outdated
Comment thread controllers/metal3.io/host_state_machine_test.go Outdated
hardys pushed a commit to hardys/baremetal-operator that referenced this pull request Apr 7, 2021
This currently does the same as Delete but as mentioned in
review of metal3-io#827 semantically this is a different action and
should have a separate API call in the Provisioner interface
@hardys hardys force-pushed the unmanaged_annotation branch 2 times, most recently from 1fdd305 to 582d8ad Compare April 7, 2021 11:10
@hardys
Copy link
Copy Markdown
Member Author

hardys commented Apr 7, 2021

/test-integration

@andfasano
Copy link
Copy Markdown
Member

/lgtm
/hold
to allow @zaneb a final pass

@metal3-io-bot metal3-io-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Apr 7, 2021
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 have a couple of comments inline about the error handling. It would be nice if we could address those (particularly since it means we can undo the refactoring of clearError(), but given that both the Detach errors and Power Management errors are an entirely theoretical concept today, I also don't see any obstacle to merging this and fixing it in a follow-up.
/approve

if hasDetachedAnnotation(hsm.Host) {
// Only allow detaching hosts in Provisioned/ExternallyProvisioned states
switch info.host.Status.Provisioning.State {
case metal3v1alpha1.StateProvisioned, metal3v1alpha1.StateExternallyProvisioned:
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.

There's probably a case to be made for allowing this in the Ready/Available state, but I'm fine with leaving it until someone actually has a requirement for it.

Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
@metal3-io-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hardys, zaneb

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

Steven Hardy added 2 commits April 7, 2021 17:07
Define a new annotation and operational status to describe the case
where a BMH is detached
This currently does the same as Delete but as mentioned in
review of metal3-io#827 semantically this is a different action and
should have a separate API call in the Provisioner interface
@hardys hardys force-pushed the unmanaged_annotation branch from 582d8ad to a21f536 Compare April 7, 2021 16:15
@metal3-io-bot metal3-io-bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 7, 2021
@hardys hardys force-pushed the unmanaged_annotation branch from a21f536 to 349fa01 Compare April 7, 2021 16:19
@hardys hardys force-pushed the unmanaged_annotation branch from 349fa01 to 569c094 Compare April 7, 2021 16:21
@zaneb
Copy link
Copy Markdown
Member

zaneb commented Apr 7, 2021

/lgtm
/hold cancel

@metal3-io-bot metal3-io-bot added lgtm Indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Apr 7, 2021
@zaneb
Copy link
Copy Markdown
Member

zaneb commented Apr 7, 2021

/test-integration

@metal3-io-bot metal3-io-bot merged commit adbd5df into metal3-io:master Apr 7, 2021
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants