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

misc improvement #5

Merged
merged 17 commits into from
Sep 18, 2024
Merged

misc improvement #5

merged 17 commits into from
Sep 18, 2024

Conversation

Vicente-Cheng
Copy link
Collaborator

@Vicente-Cheng Vicente-Cheng commented Jul 10, 2024

Mainly changes for this PR as below:

  • support vgName from SC
  • remove vgName/devicePattern
  • drop csi ephemeral volume support
  • support generic ephemeral volume
  • remove redundant code
  • use new executor
  • fix the volume expand
  • support snapshot create/delete
  • support clone
  • support dm-thin
  • enable CGO, move to Debian for cross-compile (binary part)
  • Update ReadME and CRDs

Related issue: harvester/harvester#5724

    - Also, remove unused variables

Signed-off-by: Vicente Cheng <[email protected]>
@Vicente-Cheng Vicente-Cheng requested review from tserong and bk201 July 10, 2024 11:47
    - We need to use the command executor from go-common

Signed-off-by: Vicente Cheng <[email protected]>
    - use the executor to get an accurate command output
    - Improve the delete lv that can delete lv w/o vg name

Signed-off-by: Vicente Cheng <[email protected]>
    - Now we use the user-define volume group on the StorageClass.
      That will give more flexibility for creating lv with different vg

Signed-off-by: Vicente Cheng <[email protected]>
    - After we support user-defined vg name, we could drop the vgname
      and device pattern.
    - Now we support generic ephemeral volume and drop the csi ephemeral
      volume support.

Signed-off-by: Vicente Cheng <[email protected]>
Signed-off-by: Vicente Cheng <[email protected]>
    - Execute lvextend multiple times will get EIO if
      size not change. We need to add pre-check for
      avoiding that.

Signed-off-by: Vicente Cheng <[email protected]>
@Vicente-Cheng Vicente-Cheng marked this pull request as draft July 15, 2024 16:05
@Vicente-Cheng Vicente-Cheng force-pushed the misc-improvement branch 5 times, most recently from 1509a84 to 6b2de1d Compare July 23, 2024 03:18
@Vicente-Cheng Vicente-Cheng marked this pull request as ready for review July 23, 2024 07:16
@Vicente-Cheng
Copy link
Collaborator Author

Vicente-Cheng commented Jul 23, 2024

Hi @tserong, @bk201,
Please refer to the new README on this PR to know how to install. Then, update the lvm.conf as OS2 PR (harvester/os2#121)

You also need to build the image from this PR to test manually.

@Vicente-Cheng
Copy link
Collaborator Author

Vicente-Cheng commented Jul 25, 2024

Just a reminder, we need to wait harvester/go-common#17 to merge and update the go.mod
updated

Copy link
Member

@bk201 bk201 left a comment

Choose a reason for hiding this comment

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

LGTM, function works great.
Please help coordinate with the GUI team to fix the "undefined" string in the storage class.
截圖 2024-09-09 中午12 35 42

pkg/lvm/controllerserver.go Outdated Show resolved Hide resolved
examples/pvc-clone.yaml Outdated Show resolved Hide resolved
Copy link
Member

@WebberHuang1118 WebberHuang1118 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the PR, there is one point I want to double-confirm:

https://github.com/Vicente-Cheng/csi-driver-lvm/blob/b226de6de5f2d6a66ec4cd25a4f6075cc8acb18b/cmd/provisioner/clonelv.go#L102-L104

As creating a new LV from a snapshot, the actual logic here is to create a device and copy the data from the snapshot LV to it.

However, for dm-thin, there is a way to make the original device and new device (which is created from a snapshot) share underlying blocks until one of them receives write, and the break-sharing will be triggered, this introduces better space efficiency. We can have this with dmsetup:

//creating a new source dm-thin device
sudo dmsetup message /dev/mapper/thin-pool 0 "create_thin 0"
sudo dmsetup create thin-device --table "0 20971520 thin /dev/mapper/thin-pool 0"

//taking a snapshot for the source device
sudo dmsetup message /dev/mapper/thin-pool 0 "create_snap 0 1"

//creating a new dm-thin device from the snapshot
sudo dmsetup create thin-device-snap --table "0 20971520 thin /dev/mapper/thin-pool 1"

After some searching on LVM, it seems LVM doesn't provide such a mechanism, only dmsetup does. Do you have any thoughts on this?

Update: we can use LVM to have this

//creating thin-pool
sudo lvcreate --size 10G --thinpool vg_thin/pool_thin

// creating dm-thin LV
sudo lvcreate --thin --name thin_lv1 --virtualsize 5G vg_thin/pool_thin

//taking snapshot for the LV
sudo lvcreate --snapshot --name thin_lv1_snap /dev/vg_thin/thin_lv1

//activating a dm-thin LV from the snapshot
sudo lvchange -ay -K vg_thin/thin_lv1_snap

Copy link

@tserong tserong left a comment

Choose a reason for hiding this comment

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

LGTM in general, just a couple of questions

@@ -1,11 +1,11 @@

FROM registry.suse.com/bci/golang:1.22
FROM golang:1.22-bookworm
Copy link

Choose a reason for hiding this comment

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

Why change this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

bci/golang:1.22 image lacks some cross-platform packages. I need these packages to build the cross-platform binary.

So I changed to Bookworm, that is, to have all cross-platform packages to build.

@@ -116,7 +116,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
}

lvmType := req.GetParameters()["type"]
if !(lvmType == "linear" || lvmType == "mirror" || lvmType == "striped") {
Copy link

Choose a reason for hiding this comment

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

Why drop the "linear" and "mirror" types?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because we thought the linear was similar to dm-thin and the mirror would not use too much, we removed these two and focused on the striped and dm-thin.

REF: https://github.com/harvester/harvester/pull/5956/files#diff-f23f9e440c95647f9799f80493d04ea4e5c2ecc2a2165945f52a390d105288dbR63

Copy link

Choose a reason for hiding this comment

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

Got it, thanks.

@WebberHuang1118
Copy link
Member

Hi @Vicente-Cheng
Even though we already discussed about how to handle dm-thin-pool expansion, can you explain here to have a record, or have the related comments somewhere?

@Vicente-Cheng
Copy link
Collaborator Author

LGTM, thanks for the PR, there is one point I want to double-confirm:

https://github.com/Vicente-Cheng/csi-driver-lvm/blob/b226de6de5f2d6a66ec4cd25a4f6075cc8acb18b/cmd/provisioner/clonelv.go#L102-L104

As creating a new LV from a snapshot, the actual logic here is to create a device and copy the data from the snapshot LV to it.

However, for dm-thin, there is a way to make the original device and new device (which is created from a snapshot) share underlying blocks until one of them receives write, and the break-sharing will be triggered, this introduces better space efficiency. We can have this with dmsetup:

//creating a new source dm-thin device
sudo dmsetup message /dev/mapper/thin-pool 0 "create_thin 0"
sudo dmsetup create thin-device --table "0 20971520 thin /dev/mapper/thin-pool 0"

//taking a snapshot for the source device
sudo dmsetup message /dev/mapper/thin-pool 0 "create_snap 0 1"

//creating a new dm-thin device from the snapshot
sudo dmsetup create thin-device-snap --table "0 20971520 thin /dev/mapper/thin-pool 1"

After some searching on LVM, it seems LVM doesn't provide such a mechanism, only dmsetup does. Do you have any thoughts on this?

Update: we can use LVM to have this

//creating thin-pool
sudo lvcreate --size 10G --thinpool vg_thin/pool_thin

// creating dm-thin LV
sudo lvcreate --thin --name thin_lv1 --virtualsize 5G vg_thin/pool_thin

//taking snapshot for the LV
sudo lvcreate --snapshot --name thin_lv1_snap /dev/vg_thin/thin_lv1

//activating a dm-thin LV from the snapshot
sudo lvchange -ay -K vg_thin/thin_lv1_snap

Thanks for the reminder!

After discussed with @WebberHuang1118, the new clone from snapshot would utilize the dm-thin pros.
That is, use lvm command to create another snapshot based on the above snapshot.
Thus, we could reuse the previous snapshot, and we could also utilize the dm-thin pros.

e.g. (like above example, we already create a snapshot)

//creating thin-pool
$ lvcreate --size 10G --thinpool vg_thin/pool_thin

// creating dm-thin LV
$ lvcreate --thin --name thin_lv1 --virtualsize 5G vg_thin/pool_thin
 
//taking snapshot for the LV
$ lvcreate --snapshot --name thin_lv1_snap /dev/vg_thin/thin_lv1

// taking another snapshot for the above snapshot (that is clone, we will active this snapshot to use)
$ lvcreate --snapshot -name <target pvc name> vg_thin/thin_lv1_snap

That is the new behavior for the dm-thin snapshot clone.
For others, we keep the device copy mechanism.

Thanks!

@Vicente-Cheng Vicente-Cheng force-pushed the misc-improvement branch 2 times, most recently from d3824a8 to 57ed509 Compare September 17, 2024 16:32
Copy link

@tserong tserong left a comment

Choose a reason for hiding this comment

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

I found a few small naming discrepancies in command line arguments. Otherwise LGTM in general (note: I haven't tried testing the snapshot functionality myself)

cmd/provisioner/createsnap.go Outdated Show resolved Hide resolved
cmd/provisioner/createsnap.go Outdated Show resolved Hide resolved
cmd/provisioner/deletesnap.go Outdated Show resolved Hide resolved
cmd/provisioner/createsnap.go Show resolved Hide resolved
cmd/provisioner/deletesnap.go Outdated Show resolved Hide resolved
pkg/lvm/controllerserver.go Outdated Show resolved Hide resolved
    - fix volume expansaion
    - update deploy/charts for snapshot

Signed-off-by: Vicente Cheng <[email protected]>
    - support clone from PVC or Snapshot
    - remove resource limit because clone pod need more memory

Signed-off-by: Vicente Cheng <[email protected]>
    - also bump google.golang.org/grpc v1.64.1

Signed-off-by: Vicente Cheng <[email protected]>
    - also drop linear/mirror

Signed-off-by: Vicente Cheng <[email protected]>
    - also correct the description of command

Signed-off-by: Vicente Cheng <[email protected]>
@Vicente-Cheng
Copy link
Collaborator Author

The commit 4e3dacd of this PR also related to harvester/harvester#6568

Copy link
Member

@WebberHuang1118 WebberHuang1118 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the PR.

@bk201 bk201 merged commit f14e909 into harvester:main Sep 18, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants