Add support for detached annotation #827
Conversation
|
WIP as I'd like to confirm we're happy with having both an Also needs tests/docs, and I'll refactor the new code into a function from the |
|
/cc @maelk @fmuyassarov - this leaves the existing 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 |
As long as |
41c1ba9 to
686e263
Compare
|
@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! |
|
|
||
| // 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" |
There was a problem hiding this comment.
I got out the thesaurus and here is some more suggestions in order of my preference:
- disengage
- dissociate
- detach
To put this in perspective, here are some other words I am not suggesting (you're welcome):
- sunder
- unloose
- disjoin
- uncouple
- dissever
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Changed to detached in the latest revision
There was a problem hiding this comment.
There was a problem hiding this comment.
that's probably not very likely, right?
rofl
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.
686e263 to
bc4f7b5
Compare
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
bc4f7b5 to
8de5130
Compare
|
/retitle Add support for detached annotation |
|
/test-integration |
bc54963 to
26dd0b1
Compare
|
/test-integration |
| // Note this doesn't change the current state, only the OperationalStatus | ||
| annotations := hsm.Host.GetAnnotations() | ||
| if annotations != nil { | ||
| if _, ok := annotations[metal3v1alpha1.DetachedAnnotation]; ok { |
There was a problem hiding this comment.
nit: a hasDetachedAnnotation() convenience function wouldn't hurt.
There was a problem hiding this comment.
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).
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
1fdd305 to
582d8ad
Compare
|
/test-integration |
|
/lgtm |
zaneb
left a comment
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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
582d8ad to
a21f536
Compare
a21f536 to
349fa01
Compare
349fa01 to
569c094
Compare
|
/lgtm |
|
/test-integration |
This allows a new annotation as discussed in metal3-io/metal3-docs#168
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)