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

feat(lvm vol describe): Add feature to describe lvm volumes #74

Merged
merged 4 commits into from
Aug 12, 2021

Conversation

Abhinandan-Purkait
Copy link
Member

@Abhinandan-Purkait Abhinandan-Purkait commented Aug 11, 2021

What does this PR do?

  • This PR adds support to describe a LVM volume.
  • This adds an utility to maintain one name for a cas.
  • This adds unit tests for this feature.
  • Some refactors

Usage and Output

❯ kubectl openebs describe vol pvc-868e92a5-16ce-4919-91c2-a12a7210202f

pvc-868e92a5-16ce-4919-91c2-a12a7210202f Details :
------------------
Name            : pvc-868e92a5-16ce-4919-91c2-a12a7210202f
Namespace       : openebs
AccessMode      : ReadWriteOnce 
CSIDriver       : local.csi.openebs.io
Capacity        : 4Gi
PVC             : csi-lvmpv
VolumePhase     : Released
StorageClass    : openebs-lvmpv
Version         : 0.6.0
Status          : Ready
VolumeGroup     : lvmvg
Shared          : no
ThinProvisioned : no
NodeID          : node1-virtual-machine   

Signed-off-by: Abhinandan-Purkait <abhinandan.purkait@mayadata.io>
Signed-off-by: Abhinandan-Purkait <abhinandan.purkait@mayadata.io>
@Abhinandan-Purkait Abhinandan-Purkait marked this pull request as ready for review August 11, 2021 10:08
@Abhinandan-Purkait Abhinandan-Purkait self-assigned this Aug 11, 2021
@Abhinandan-Purkait Abhinandan-Purkait linked an issue Aug 11, 2021 that may be closed by this pull request
6 tasks
Copy link
Member

@vharsh vharsh left a comment

Choose a reason for hiding this comment

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

minor suggestions

// LVMLocalPV is the cas type name for LocalPV-LVM
LVMLocalPV = "lvmlocalpv"
// LVMCasType cas type name
LVMCasType = "lvmlocalpv"
Copy link
Member

Choose a reason for hiding this comment

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

We can change the flag name and avoid the normalize function, as this is an alpha product now, we can make such name changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changing the flag name surely helps. I did this way because the zfs is called as zfslocalpv thus to make things similar and avoid confusion.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about the exact naming of it too, I created it as lvmlocalpv to avoid having a hyphen in the name.

pkg/util/constant.go Outdated Show resolved Hide resolved
pkg/util/util.go Outdated
@@ -171,3 +171,14 @@ func ColorStringOnStatus(stringToColor string) string {
return ColorText(stringToColor, Red)
}
}

// NormalizeCas is used to maintain one version of cas name
func NormalizeCas(casType string) string {
Copy link
Member

Choose a reason for hiding this comment

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

Lets get rid of this function if the flag value strings won't have trouble getting a - in the flag value, i.e. if kubectl openebs get storage --cas-type=localpv-lvm passes the cas-type to programs correctly we can rename the lvmlocalpv to localpv-lvm.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we can but to maintain uniformity this has been added. Also normalizing stuffs would give users to give any thing and still get an output at an overhead of this matching and all.

I was thinking of making the normalize recognize the cas-name from any string, viz localpv-lvm, lvmlocalpv, lvm whatever user enters by having some regex matching in here, does that sounds good to? 😅

Copy link
Member

Choose a reason for hiding this comment

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

It sounds okay-ish, I don't know the exact name too 😓

@shubham14bajpai @prateekpandey14 some naming help please

Copy link
Member Author

@Abhinandan-Purkait Abhinandan-Purkait Aug 11, 2021

Choose a reason for hiding this comment

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

https://github.com/openebs/zfs-localpv/blob/95d5d3a8d33763add6df81a5829ba7800e71a132/pkg/zfs/volume.go#L64

https://github.com/openebs/lvm-localpv/blob/929ae4439f2da71a2d6ee5bda6a33dd2f7d424fc/pkg/lvm/volume.go#L59

Okay, I had added a hypen seperated name in both the repos. So I thing we should keep these in our code as well and get rid of the normalize method. If this sounds good.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, the localpv-lvm & localpv-zfs names seem better for the flags & internally.

On a nitpick side, things are a bit different in different places, but it'd likely converge to a single set of names sooner or later, I don't like having a normalize function everywhere.

(node-disk-manager) $ git grep StorageEngine

blockdevice/blockdevice.go:413: UsedBy StorageEngine
blockdevice/blockdevice.go:416:// StorageEngine is a typed string for the storage engine
blockdevice/blockdevice.go:417:type StorageEngine string
blockdevice/blockdevice.go:421: CStor StorageEngine = "cstor"
blockdevice/blockdevice.go:424: ZFSLocalPV StorageEngine = "zfs-localpv"
blockdevice/blockdevice.go:427: Mayastor StorageEngine = "mayastor"
blockdevice/blockdevice.go:430: LocalPV StorageEngine = "localpv"
blockdevice/blockdevice.go:433: Jiva StorageEngine = "jiva"

pkg/volume/lvmlocalpv.go Outdated Show resolved Hide resolved
pkg/volume/volume.go Show resolved Hide resolved
Signed-off-by: Abhinandan-Purkait <abhinandan.purkait@mayadata.io>
Signed-off-by: Abhinandan-Purkait <abhinandan.purkait@mayadata.io>
@vharsh vharsh merged commit fcb6d60 into openebs:develop Aug 12, 2021
@vharsh vharsh deleted the feat-lvm branch August 12, 2021 06:55
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.

Add support for LVM LocalPV
2 participants