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
add Deprovision action to Bare Metal Hosts #3811
add Deprovision action to Bare Metal Hosts #3811
Conversation
fd0be3f
to
3fbf5db
Compare
/retest |
@@ -13,3 +17,22 @@ export const createBareMetalHost = async (bareMetalHost, secret) => [ | |||
await k8sCreate(SecretModel, secret), | |||
await k8sCreate(BareMetalHostModel, bareMetalHost), | |||
]; | |||
|
|||
export const deprovision = async (machine: MachineKind, machineSet: MachineSetKind) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
machineset is optional here:
If host's machine is managed by machineSet -> annotate the machine and scale down the machineset to trigger deprovisioning.
if host's machine is not managed by machineSet (e.g. master) -> just delete the machine to start deprovisioning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
I am still adding the annotation to distinguish the machines for hiding the deprovision action
1c6a7d6
to
b9cc608
Compare
/retest |
b9cc608
to
c51f8e0
Compare
#3810 merged, rebased |
new PatchBuilder('/metadata/annotations') | ||
.setObjectUpdate(DELETE_MACHINE_ANNOTATION, 'true', getAnnotations(machine)) | ||
.build(), | ||
]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should go inside (replicas > 0) {
block (Line 37) as it is needed only in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is safer to specify the intent of removing this machine in all cases (shouldn't hurt anything)
return { | ||
hidden: | ||
!machine || | ||
!!getAnnotations(machine, {})[DELETE_MACHINE_ANNOTATION] || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be ok to run deprovision action even when the annotation is already there (to for example cover the case when the machine was annotated but the machineset failed to scale down).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead, we should prevent re-triggering if host is already in 'deprovisioning' status. It seems that the machine is deleted only after the hosts image has been removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be a bug on the machineSet side. I think it is much safer to rely on the annotation because the status can take a while to get updated and the user might remove two machines by accident (will randomly kill next one).
I added a safety fallback to the request so the annotation doesn't get stuck when the machine set patch fails
hidden: | ||
!machine || | ||
!!getAnnotations(machine, {})[DELETE_MACHINE_ANNOTATION] || | ||
(getMachineMachineSetOwner(machine) && !machineSet), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The machineSet is only populated if it is the owner of the machine (in BareMetalHostsPage and menuActionsCreator), so this line should not be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but this line is here for the loading. So that the action will stay hidden until we load the machine set of a machine which should have one.
import { MachineSetModel } from '@console/internal/models'; | ||
import { getOwnerReferences } from '@console/shared/src'; | ||
|
||
export const getMachineMachineSetOwner = (machine: MachineKind) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be beetter to add into @console/shared/src/selectors/machine.ts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather move this in a followup once #4014 merges and make it more generic
kind: MachineSetModel.kind, | ||
} as any; | ||
return (getOwnerReferences(machine) || []).find((reference) => | ||
compareOwnerReference(desiredReference, reference, true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@console/metal3-plugin
nor @console/shared
should import from '@console/kubevirt-plugin'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right: #4014
import { K8sResourceCommon, K8sResourceKind } from '@console/internal/module/k8s'; | ||
import { FirehoseResult } from '@console/internal/components/utils'; | ||
|
||
export type OptionalFirehoseResult< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could be put somewhere near the FirehoseResult definition instead of metal3-plugin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c51f8e0
to
1c3bfe7
Compare
/retest |
1c3bfe7
to
79c5503
Compare
rebased and fixed |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jtomasek, suomiy 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 |
/test e2e-gcp-console |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest |
1 similar comment
/retest |
/hold |
/hold cancel |
/retest Please review the full test history for this PR and help us cut down flakes. |
1 similar comment
/retest Please review the full test history for this PR and help us cut down flakes. |
depends on