Skip to content

Refactor vgmanager #59

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

Merged
merged 3 commits into from
Jan 13, 2022
Merged

Refactor vgmanager #59

merged 3 commits into from
Jan 13, 2022

Conversation

sp98
Copy link
Contributor

@sp98 sp98 commented Jan 5, 2022

  • add Executor interface to run os/exec commands. Helps to write unit tests using mocks.
  • Update block device utility to use Executor interface and json response for easy parsing.
  • Update vgmanager controller to use Executor interface and json response for easy parsing

Tested changes on SNO-2:

$  oc get pods -n lvm-operator-system 
NAME                                  READY   STATUS    RESTARTS      AGE
controller-manager-664bc69459-89xx8   2/2     Running   0             18m
topo-test-6df5cf5457-sp692            1/1     Running   0             7m52s
topolvm-controller-58c8f86445-z2v4b   4/4     Running   0             15m
topolvm-node-lzcx7                    4/4     Running   8 (14m ago)   15m
vg-manager-mb985                      1/1     Running   0             15m

# sapillai @ localhost in ~/go/src/github.com/red-hat-storage/lvm-operator on git:refactor-vgmanager o [19:48:20] 
$ oc get pv                                             
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                      STORAGECLASS              REASON   AGE
pvc-3e72f055-8e1d-4bec-b3e8-e31565943978   20Gi       RWO            Delete           Bound    lvm-operator-system/pvc1   topolvm-provisioner-vg1            7m58s

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 5, 2022
@sp98 sp98 force-pushed the refactor-vgmanager branch 2 times, most recently from ad0706a to 4462f14 Compare January 6, 2022 11:43
@sp98 sp98 marked this pull request as ready for review January 6, 2022 11:44
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 6, 2022
@sp98 sp98 requested review from nbalacha and leelavg January 6, 2022 11:44
Copy link
Contributor

@nbalacha nbalacha left a comment

Choose a reason for hiding this comment

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

First round of review. I'll do one more round tomorrow.

@@ -177,6 +175,46 @@ func (r *VGReconciler) reconcile(ctx context.Context, req ctrl.Request) (ctrl.Re
return ctrl.Result{RequeueAfter: requeueAfter}, nil
}

func (r *VGReconciler) addDevicesToVG(vgName string, devices []internal.BlockDevice) error {
if len(devices) < 1 {
return fmt.Errorf("can't create vg with 0 devices")
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add the vgname to this error.

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.

if err != nil {
return nil, err
return nil, fmt.Errorf("failed to unmarhsal volume group response. %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: "unmarshal"

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

}

var cmd string
args := []string{vgName}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do this after checking if the volume group is already present.

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.

@sp98 sp98 force-pushed the refactor-vgmanager branch 2 times, most recently from 542764d to 5a6ceec Compare January 12, 2022 14:17
@sp98 sp98 requested a review from nbalacha January 12, 2022 14:18
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 12, 2022
@nbalacha
Copy link
Contributor

Please correct the commit messages (formats)

sp98 added 3 commits January 12, 2022 22:15
- Executor interface and its implementation helps to run os/exec
  commands

Signed-off-by: Santosh Pillai <[email protected]>
- Use `json` response for easy parsing of lsblk output
- use executor interface implementation

Signed-off-by: Santosh Pillai <[email protected]>
- use `json` response for easy parsing.
- use executor interface implementation

Signed-off-by: Santosh Pillai <[email protected]>
@sp98 sp98 force-pushed the refactor-vgmanager branch from 5a6ceec to 85a75d6 Compare January 12, 2022 16:46
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 12, 2022
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 13, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 13, 2022

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nbalacha, sp98

The full list of commands accepted by this bot can be found 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

@nbalacha nbalacha merged commit 07b79b3 into openshift:main Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants