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

Thin pool creation #131

Merged
merged 4 commits into from
Apr 18, 2022
Merged

Thin pool creation #131

merged 4 commits into from
Apr 18, 2022

Conversation

sp98
Copy link
Contributor

@sp98 sp98 commented Mar 21, 2022

Create thin pool via VG Manager.

Testing:

CR:

apiVersion: lvm.topolvm.io/v1alpha1
kind: LVMCluster
metadata:
  name: lvmcluster-sample
spec:
  storage:
    deviceClasses:
    - name: vg1
      thinPoolConfig:
        name: mytp1
        sizePercent: 50
        overprovisionRatio: 50
sh-4.4# vgs
  VG  #PV #LV #SN Attr   VSize  VFree
  vg1   3   1   0 wz--n- <4.37t 2.18t
sh-4.4# lvs
  LV    VG  Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  mytp1 vg1 twi-a-tz-- 2.18t             0.00   6.13
sh-4.4#


sh-4.4# cat lvmd.yaml
device-classes:
- default: true
  lvcreate-options: null
  name: vg2
  spare-gb: null
  stripe: null
  stripe-size: ""
  thin-pool:
    name: mytp2
    overprovision-ratio: 30
  type: thin
  volume-group: vg2
socket-name: /run/lvmd/lvmd.sock

Apps using thin volumes:

  VG  #PV #LV #SN Attr   VSize  VFree
  vg2   3   3   0 wz--n- <4.37t 2.18t
sh-4.4# lvs
  LV                                   VG  Attr       LSize  Pool  Origin Data%  Meta%  Move Log Cpy%Sync Convert
  76e79637-5cc8-4795-8644-4298d8db3d1b vg2 Vwi-aotz--  5.00g mytp2        0.29
  c293d9ab-04dc-4b6d-8d9c-b3bf368a091c vg2 Vwi-aotz-- 40.00g mytp2        0.07
  mytp2                                vg2 twi-aotz--  2.18t              0.01   6.13
sh-4.4#

@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 Mar 21, 2022
@sp98 sp98 force-pushed the thin-pool branch 4 times, most recently from 67ebf50 to be11c69 Compare March 23, 2022 06:41
@sp98 sp98 changed the title [WIP] Thin pool creation Thin pool creation Mar 23, 2022
@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 Mar 23, 2022
@sp98 sp98 force-pushed the thin-pool branch 2 times, most recently from 8ac50ec to 3051678 Compare March 24, 2022 04:52
@sp98 sp98 requested review from nbalacha and leelavg March 24, 2022 04:54
@sp98 sp98 force-pushed the thin-pool branch 4 times, most recently from a75ed2c to 063de1c Compare March 30, 2022 09:19
@sp98 sp98 force-pushed the thin-pool branch 2 times, most recently from 18790fc to 530a9c0 Compare March 31, 2022 09:36
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 31, 2022
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 5, 2022
Copy link
Contributor

@leelavg leelavg 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, we don't have any validation of CR yet, better we start adding validation code with this CR or mark mandatory fields as required in CRD via kubebuilder?

@sp98 sp98 force-pushed the thin-pool branch 3 times, most recently from 053d951 to 4634436 Compare April 7, 2022 06:55
@sp98
Copy link
Contributor Author

sp98 commented Apr 7, 2022

  • in general, we don't have any validation of CR yet, better we start adding validation code with this CR or mark mandatory fields as required in CRD via kubebuilder?

added CRD validation for the required fields for the new ThinPoolConfig.

@sp98 sp98 requested a review from leelavg April 8, 2022 07:26
Copy link
Contributor

@leelavg leelavg left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 12, 2022
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 13, 2022
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 13, 2022
@sp98 sp98 requested a review from nbalacha April 13, 2022 05:48
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.

Does anything extra need to be done for the cleanup?

// OverProvisionRatio is the factor by which additional storage can be provisioned compared to
// the available storage in the thin pool.
// +kubebuilder:validation:Minimum=2
OverprovisionRatio int `json:"overprovisionRatio,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

can this be empty?

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. Marked it as required.

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.

The thin pool needs to be deleted before the VG is deleted:
{"level":"error","ts":1650198338.4370134,"logger":"controller.lvmcluster","msg":"Reconciler error","reconciler group":"lvm.topolvm.io","reconciler kind":"LVMCluster","name":"lvmcluster-sample","namespace":"lvm-operator-system","error":"failed cleaning up: lvmvg-manager waiting for all VGs to be deleted","stacktrace":"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:227"}

- Also update LVMVolumeGroup CR to use thinPoolConfig
- Update suite test to include the required thinPoolConfig

Signed-off-by: Santosh Pillai <[email protected]>
args := []string{"-f", fmt.Sprintf("%s/%s", volumeGroup.Name, volumeGroup.Spec.ThinPoolConfig.Name)}
_, err = r.executor.ExecuteCommandWithOutputAsHost(lvRemoveCmd, args...)
if err != nil {
return fmt.Errorf("failed to delete thin pool %q. %v", volumeGroup.Spec.ThinPoolConfig.Name, err)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does not cover the case when the thin pool is already deleted by the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated. Checking if the thin pool exists before deleting it.

@sp98 sp98 force-pushed the thin-pool branch 2 times, most recently from 4e778e6 to a710e84 Compare April 18, 2022 10:08
sp98 added 2 commits April 18, 2022 15:40
Signed-off-by: Santosh Pillai <[email protected]>
Signed-off-by: Santosh Pillai <[email protected]>
@sp98 sp98 force-pushed the thin-pool branch 2 times, most recently from c053dfa to 03afe07 Compare April 18, 2022 10:14
@sp98 sp98 requested a review from nbalacha April 18, 2022 10:21
@@ -249,6 +294,25 @@ func (r *VGReconciler) processDelete(ctx context.Context, volumeGroup *lvmv1alph
return nil
}

// Delete thin pool
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be done after checking if the volumegroup exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's right. Fixed.

@sp98 sp98 requested a review from nbalacha April 18, 2022 12:30
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 18, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 18, 2022

[APPROVALNOTIFIER] This PR is APPROVED

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

The full list of commands accepted by this bot can be found here.

The pull request process is described 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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 18, 2022
@openshift-merge-robot openshift-merge-robot merged commit d69fbde into openshift:main Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. 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