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

Add longhorn v2 provisioner #82

Closed

Conversation

Vicente-Cheng
Copy link
Collaborator

@Vicente-Cheng Vicente-Cheng commented Mar 3, 2024

Problem:
Add capability to provision Longhorn v2 engine backend disk

Solution:
Add capability to provision Longhorn v2 engine backend disk

Related Issue:
harvester/harvester#5274

Test plan:
TBD

Tasks:

  • add integration test

    - we add the provisioner to provision different type storage backend

Signed-off-by: Vicente Cheng <vicente.cheng@suse.com>
Signed-off-by: Vicente Cheng <vicente.cheng@suse.com>
Signed-off-by: Vicente Cheng <vicente.cheng@suse.com>
@Vicente-Cheng Vicente-Cheng requested review from tserong and bk201 March 3, 2024 15:13
Copy link
Contributor

@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. I note this PR is marked "draft" - are there more changes to come here?

@Vicente-Cheng
Copy link
Collaborator Author

Hi @tserong,

Thanks for the quick review.
After discussion, we might not make the longhorn v2 engine in v1.3.0.

So this change will still draft here until v1.3.0 release.
I will add the integration test, and maybe some minor change once I got any issue with integration test (CI).

Copy link

@innobead innobead left a comment

Choose a reason for hiding this comment

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

In general, LGTM. Just a few comments.

@@ -212,12 +213,16 @@ func (c *Controller) OnBlockDeviceChange(_ string, device *diskv1.BlockDevice) (
if devPath == "" {
return nil, fmt.Errorf("failed to resolve persistent dev path for block device %s", device.Name)
}
if device.Spec.Provisioner == "" {

Choose a reason for hiding this comment

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

nit: Do we have a mutator mechanism to add the default value? If yes, we can prevent this sort of non-biz code in controller.

Tags: device.Spec.Tags,

diskSpec := generateDiskSpec(device.Spec.Provisioner)
if device.Spec.Provisioner == defaultProvisioner {

Choose a reason for hiding this comment

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

nit: suggest handling each case explicitly to prevent using else for v2. Can use switch.

@@ -175,3 +176,14 @@ func CallerWithCondLock[T any](cond *sync.Cond, f func() T) T {
defer cond.L.Unlock()
return f()
}

// DoCommand executes a command and returns the stdout, stderr and error
func DoCommand(cmdString string) (string, string, error) {

Choose a reason for hiding this comment

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

Nit: This function is quite general. Not sure if there is an existing lib able to use or even we can add this to common lib for other repos to reuse later if appropriate.

Can extend it to pass io.Writer out and err instead of hard-coded bytes buffer here only.

If for testing only, why not just add this to a related test package folder?

@Vicente-Cheng
Copy link
Collaborator Author

we will have a new v2 engine provisioner later.

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.

3 participants