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

Implement vgmanager #27

Merged
merged 5 commits into from
Dec 22, 2021
Merged

Implement vgmanager #27

merged 5 commits into from
Dec 22, 2021

Conversation

sp98
Copy link
Contributor

@sp98 sp98 commented Dec 19, 2021

This PR is based on the Rohan's PR

  • Creates VgManager Image
  • Adds utility for reading block devices
  • Implements controller for vgManager to create vgs.

Testing on SNO cluster:

VgManager Image used : quay.io/sp1098/vgmanager:latest 

$ oc version
Client Version: 4.9.0
Server Version: 4.9.0
Kubernetes Version: v1.22.0-rc.0+894a78b

# sapillai @ localhost in ~ [10:52:00]
$ oc get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM          STORAGECLASS              REASON   AGE
pvc-481b5016-6126-4ed1-a42f-5be48f6d132f   10Gi       RWO            Delete           Bound    default/pvc1   topolvm-provisioner-vg1            74s

# sapillai @ localhost in ~ [10:52:03]
$ oc get pods -n lvm-operator-system
NAME                                  READY   STATUS    RESTARTS      AGE
controller-manager-54c78c8df6-mvzkl   2/2     Running   0             42m
topolvm-controller-58c8f86445-brq4x   4/4     Running   0             41m
topolvm-node-md28g                    4/4     Running   8 (40m ago)   41m
vg-manager-bcklj                      1/1     Running   0             41m

# sapillai @ localhost in ~ [10:52:30]
$ oc get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM          STORAGECLASS              REASON   AGE
pvc-481b5016-6126-4ed1-a42f-5be48f6d132f   10Gi       RWO            Delete           Bound    default/pvc1   topolvm-provisioner-vg1            112s

# sapillai @ localhost in ~ [10:52:41]
$ oc get pvc
NAME   STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS              AGE
pvc1   Bound    pvc-481b5016-6126-4ed1-a42f-5be48f6d132f   10Gi       RWO            topolvm-provisioner-vg1   118s

# sapillai @ localhost in ~ [10:52:46]
$ oc get pods
NAME                                READY   STATUS    RESTARTS   AGE
rhocs-bm5labengblrredhatcom-debug   1/1     Running   0          50m
topo-test-6df5cf5457-m8gnz          1/1     Running   0          2m5s

TODO (in follow up PRs)

  • Revisit controller implementation of the vgManager daemoset.
  • Update ListBlockDevice method to read devices using --json flag

@sp98 sp98 changed the title Implement vgmanager [DNM]Implement vgmanager Dec 20, 2021
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 20, 2021
@sp98 sp98 force-pushed the implement-vgmanager branch from bba2432 to 596a924 Compare December 21, 2021 11:59
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 21, 2021
@sp98 sp98 changed the title [DNM]Implement vgmanager Implement vgmanager Dec 21, 2021
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.

Initial comment: please reorder commits as follows:

  1. blockutil
  2. vgmanager implementation (includes main.go changes from current build commit)
  3. build (only makefile and dockerfile changes)
  4. go mod tidy

@sp98 sp98 force-pushed the implement-vgmanager branch from e53a2a7 to 248ca01 Compare December 21, 2021 13:15
@sp98 sp98 requested a review from nbalacha December 21, 2021 13:16
COPY controllers/ controllers/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o vgmanager cmd/vgmanager/main.go
Copy link
Contributor

Choose a reason for hiding this comment

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

We will need to build for multiple archs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how about we do it in a new PR since we have to do it for the operator image as well ?

cmd/vgmanager/main.go Outdated Show resolved Hide resolved
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
opts := zap.Options{
Development: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

This will need to be set to false in the future. This is fine for now.

pkg/internal/blockutil.go Outdated Show resolved Hide resolved
}

// GetSize as int64
func (b BlockDevice) GetSize() (int64, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not uint64?

pkg/internal/blockutil.go Show resolved Hide resolved
pkg/internal/blockutil.go Show resolved Hide resolved
pkg/vgmanager/vgmanager_controller.go Outdated Show resolved Hide resolved
if err != nil {
r.Log.Error(err, "reconcile error")
}
r.Log.V(1).Info("reconcile complete", "result", res)
Copy link
Contributor

Choose a reason for hiding this comment

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

What is r.Log.V(1)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure. Looks like different verbosity levels. I'll remove it.

pkg/vgmanager/vgmanager_controller.go Outdated Show resolved Hide resolved
// filterMatchingDevices returns unmatched and matched blockdevices
func filterMatchingDevices(blockDevices []internal.BlockDevice, lvmCluster lvmv1alpha1.DeviceClass) ([]internal.BlockDevice, []internal.BlockDevice, error) {
// currently just match all devices
return []internal.BlockDevice{}, blockDevices, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this skip the installation disk?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. Right now there is no filter. we just return all the devices back.

Copy link
Contributor Author

@sp98 sp98 Dec 22, 2021

Choose a reason for hiding this comment

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

I spoke too soon. Yes there is a check. There is a filter called noBiosBootInPartLabel. It checks for bios or boot in the disk part label. Based on our experience with LSO so far, it might not be enough cover all the cases.

pkg/vgmanager/lvm.go Outdated Show resolved Hide resolved
@sp98 sp98 force-pushed the implement-vgmanager branch from 248ca01 to b4cecca Compare December 21, 2021 14:51
@sp98 sp98 requested a review from nbalacha December 21, 2021 15:14
@@ -33,12 +33,12 @@ var (
DevDirVolName = "device-dir"
SysVolName = "sys"

LVMdDir = "/mnt/lvmd/"
LVMdDir = "/etc/topolvm"
Copy link
Contributor

Choose a reason for hiding this comment

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

if this is the directory where the lvmd config file is stored, then this can cause problems, because we already have another constant with the complete file path. So in case of change, everybody must know that we need to change this other constant.
I suggest to use only the "LvmdConfigFile" constant , and if it is needed extract the base path from the constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I would like to take this up in a follow up PR.

FSType string `json:"fsType"`
Size string `json:"size"`
// Children []BlockDevice `json:"children,omitempty"`
Rotational string `json:"rota"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Having a different names (struct/json) only can drive to confusion. I would suggest to use the same names in both parts... so instead of "rota" use "rotational" , ro/readonly, rm/removable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would take this is up in a follow up PR while working on this comment

@sp98 sp98 force-pushed the implement-vgmanager branch from b4cecca to e4558eb Compare December 22, 2021 05:45

// load lvmd config
lvmdConfig := &lvmdCMD.Config{
SocketName: topolvm.DefaultLVMdSocket,
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sp98 and others added 2 commits December 22, 2021 15:49
Read block devices properties using lsblk

Co-authored-by: Rohan CJ <[email protected]>
Signed-off-by: Santosh Pillai <[email protected]>
@sp98 sp98 force-pushed the implement-vgmanager branch 2 times, most recently from 9e10c23 to 6fccbdd Compare December 22, 2021 11:32

// load lvmd config
lvmdConfig := &lvmdCMD.Config{
SocketName: topolvm.DefaultLVMdSocket,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please replace this with controllers.LVMdSocketPath

sp98 and others added 3 commits December 22, 2021 17:47
Co-authored-by: Rohan CJ <[email protected]>
Signed-off-by: Santosh Pillai <[email protected]>
Co-authored-by: Rohan CJ <[email protected]>
Signed-off-by: Santosh Pillai <[email protected]>
@sp98 sp98 force-pushed the implement-vgmanager branch from 6fccbdd to d787cc0 Compare December 22, 2021 12:17
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 22, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 22, 2021

[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 929e2e0 into openshift:main Dec 22, 2021
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.

4 participants