Skip to content
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

Merged

Conversation

alexander-demicev
Copy link
Contributor

Reconcile machine power state annotation

@alexander-demicev alexander-demicev changed the title Reconcile machine power state annotation Bug 1829408: Reconcile machine power state annotation Apr 30, 2020
@openshift-ci-robot openshift-ci-robot added bugzilla/severity-low Referenced Bugzilla bug's severity is low for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Apr 30, 2020
@openshift-ci-robot
Copy link
Contributor

@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
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1829408: Reconcile machine power state annotation

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.

@@ -333,6 +336,24 @@ func (r *Reconciler) reconcileNetwork(vm *virtualMachine) error {
return nil
}

func (r *Reconciler) reconcilePowerStateAnnontation(vm *virtualMachine) {
Copy link
Member

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?

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

powerState, err := vm.getPowerState()
if err != nil {
klog.V(3).Infof("%s: Failed to get power state: %v", r.machine.Name, err)
return
Copy link
Member

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"
Copy link
Member

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?

@alexander-demicev
Copy link
Contributor Author

@enxebre All fixed

@enxebre
Copy link
Member

enxebre commented May 7, 2020

/approve

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 7, 2020
Copy link
Contributor

@JoelSpeed JoelSpeed left a 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(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit

Suggested change
Context: context.TODO(),
Context: context.Background(),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@@ -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")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return errors.New("VM can't be nil")
return errors.New("provided VM is nil")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -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)
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

shouldn't we?

@openshift-ci-robot
Copy link
Contributor

@alexander-demichev: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-azure-operator 5c34c0a link /test e2e-azure-operator
ci/prow/e2e-azure 5c34c0a link /test e2e-azure

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.

@enxebre
Copy link
Member

enxebre commented May 12, 2020

/approve

@openshift-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 13, 2020
@openshift-merge-robot openshift-merge-robot merged commit bcc666e into openshift:master May 13, 2020
@openshift-ci-robot
Copy link
Contributor

@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:

Bug 1829408: Reconcile machine power state annotation

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.

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. bugzilla/severity-low Referenced Bugzilla bug's severity is low for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants