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
Bug 1829408: Reconcile machine power state annotation #578
Bug 1829408: Reconcile machine power state annotation #578
Conversation
@alexander-demichev: This pull request references Bugzilla bug 1829408, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
In response to this:
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. |
pkg/controller/vsphere/reconciler.go
Outdated
@@ -333,6 +336,24 @@ func (r *Reconciler) reconcileNetwork(vm *virtualMachine) error { | |||
return nil | |||
} | |||
|
|||
func (r *Reconciler) reconcilePowerStateAnnontation(vm *virtualMachine) { |
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.
can we please have a unit for this func?
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.
+1, would be good to see a couple of tests exercising this explicitly
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.
done
3fe06c0
to
ebfe75a
Compare
pkg/controller/vsphere/reconciler.go
Outdated
powerState, err := vm.getPowerState() | ||
if err != nil { | ||
klog.V(3).Infof("%s: Failed to get power state: %v", r.machine.Name, err) | ||
return |
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.
why are we ignoring errors here?
we should return error, then is up to the consumer what to do with it, e.g log and ignore it if there's a reason to do so
t.Errorf("Expected providerId: %s, got: %s", expectedProviderID, *reconciler.machine.Spec.ProviderID) | ||
} | ||
|
||
expectedPowerState := "poweredOn" |
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.
should this be a constant?
ebfe75a
to
0632565
Compare
@enxebre All fixed |
/approve |
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.
Provided a couple of suggestions for potential rewording of some of this, WDYT?
} | ||
|
||
vm := &virtualMachine{ | ||
Context: context.TODO(), |
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.
Nit
Context: context.TODO(), | |
Context: context.Background(), |
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.
👍
pkg/controller/vsphere/reconciler.go
Outdated
@@ -333,6 +338,25 @@ func (r *Reconciler) reconcileNetwork(vm *virtualMachine) error { | |||
return nil | |||
} | |||
|
|||
func (r *Reconciler) reconcilePowerStateAnnontation(vm *virtualMachine) error { | |||
if vm == nil { | |||
return errors.New("VM can't be nil") |
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.
return errors.New("VM can't be nil") | |
return errors.New("provided VM is nil") |
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.
done
pkg/controller/vsphere/reconciler.go
Outdated
@@ -233,6 +233,11 @@ func (r *Reconciler) reconcileMachineWithCloudState(vm *virtualMachine, taskRef | |||
return err | |||
} | |||
|
|||
klog.V(3).Infof("%v: reconciling powerstate annotation", r.machine.GetName()) | |||
if err := r.reconcilePowerStateAnnontation(vm); err != nil { | |||
klog.V(3).Infof("%s: Failed to get power state, machine can be in process of deletion: %v", r.machine.Name, err) |
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.
klog.V(3).Infof("%s: Failed to get power state, machine can be in process of deletion: %v", r.machine.Name, err) | |
klog.V(3).Infof("%s: Failed to get power state (machine may be being deleted): %v", r.machine.Name, err) |
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.
done
0632565
to
3f52adc
Compare
pkg/controller/vsphere/reconciler.go
Outdated
@@ -233,6 +233,11 @@ func (r *Reconciler) reconcileMachineWithCloudState(vm *virtualMachine, taskRef | |||
return err | |||
} | |||
|
|||
klog.V(3).Infof("%v: reconciling powerstate annotation", r.machine.GetName()) | |||
if err := r.reconcilePowerStateAnnontation(vm); err != nil { | |||
klog.V(3).Infof("%s: Failed to get power state (machine may be being deleted): %v", r.machine.Name, err) |
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.
why are we ignoring the error here? we should return an error.
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.
shouldn't we?
3f52adc
to
5c34c0a
Compare
@alexander-demichev: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: enxebre 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 |
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.
/lgtm
@alexander-demichev: All pull requests linked via external trackers have merged: openshift/machine-api-operator#578. Bugzilla bug 1829408 has been moved to the MODIFIED state. In response to this:
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. |
Reconcile machine power state annotation