Skip to content

Commit

Permalink
Merge pull request #131 from sp98/thin-pool
Browse files Browse the repository at this point in the history
Thin pool creation
  • Loading branch information
openshift-merge-robot authored Apr 18, 2022
2 parents bdb698d + a809e90 commit d69fbde
Show file tree
Hide file tree
Showing 14 changed files with 464 additions and 106 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ test: manifests generate fmt vet envtest ## Run tests.


OPERATOR_NAMESPACE ?= openshift-storage
TOPOLVM_CSI_IMAGE ?= quay.io/topolvm/topolvm:0.10.3
TOPOLVM_CSI_IMAGE ?= quay.io/topolvm/topolvm:0.11.0
CSI_REGISTRAR_IMAGE ?= k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.3.0
CSI_PROVISIONER_IMAGE ?= k8s.gcr.io/sig-storage/csi-provisioner:v3.0.0
CSI_LIVENESSPROBE_IMAGE ?= k8s.gcr.io/sig-storage/livenessprobe:v2.5.0
Expand Down Expand Up @@ -307,7 +307,7 @@ catalog-push: ## Push a catalog image.
lvm-must-gather:
@echo "Building the lvm-must-gather image"
$(IMAGE_BUILD_CMD) build -f must-gather/Dockerfile -t "${MUST_GATHER_FULL_IMAGE_NAME}" must-gather/

# Variables required to run and build LVM end to end tests.
LVM_OPERATOR_INSTALL ?= true
LVM_OPERATOR_UNINSTALL ?= true
Expand All @@ -317,4 +317,3 @@ e2e-test: ginkgo
@echo "build and run e2e tests"
cd e2e/lvm && $(GINKGO) build
cd e2e/lvm && ./lvm.test --lvm-catalog-image=$(CATALOG_IMG) --lvm-subscription-channel=$(CHANNELS) --lvm-operator-install=$(LVM_OPERATOR_INSTALL) --lvm-operator-uninstall=$(LVM_OPERATOR_UNINSTALL)

26 changes: 26 additions & 0 deletions api/v1alpha1/lvmcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,27 @@ type LVMClusterSpec struct {
Storage Storage `json:"storage,omitempty"`
}

type ThinPoolConfig struct {
// Name of the thin pool to be created
// +kubebuilder:validation:Required
// +required
Name string `json:"name"`

// SizePercent represents percentage of remaining space in the volume group that should be used
// for creating the thin pool.
// +kubebuilder:validation:default=75
// +kubebuilder:validation:Minimum=10
// +kubebuilder:validation:Maximum=90
SizePercent int `json:"sizePercent,omitempty"`

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

type DeviceClass struct {
// Name of the class, the VG and possibly the storageclass.
// Validations to confirm that this field can be used as metadata.name field in storageclass
Expand All @@ -57,6 +78,11 @@ type DeviceClass struct {
// // Config for this deviceClass, lvm settings are a field here
// // +optional
// Config *DeviceClassConfig `json:"config,omitempty"`

// ThinPoolConfig contains configurations for the thin-pool
// +kubebuilder:validation:Required
// +required
ThinPoolConfig *ThinPoolConfig `json:"thinPoolConfig"`
}

// DeviceSelector specifies the list of criteria that have to match before a device is assigned
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/lvmvolumegroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ type LVMVolumeGroupSpec struct {
// // Config for this deviceClass, lvm settings are a field here
// // +optional
// Config *DeviceClassConfig `json:"config,omitempty"`

// ThinPoolConfig contains configurations for the thin-pool
// +kubebuilder:validation:Required
// +required
ThinPoolConfig *ThinPoolConfig `json:"thinPoolConfig"`
}

// LVMVolumeGroupStatus defines the observed state of LVMVolumeGroup
Expand Down
25 changes: 25 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions config/crd/bases/lvm.topolvm.io_lvmclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,32 @@ spec:
required:
- nodeSelectorTerms
type: object
thinPoolConfig:
description: ThinPoolConfig contains configurations for
the thin-pool
properties:
name:
description: Name of the thin pool to be created
type: string
overprovisionRatio:
description: OverProvisionRatio is the factor by which
additional storage can be provisioned compared to
the available storage in the thin pool.
minimum: 2
type: integer
sizePercent:
description: SizePercent represents percentage of remaining
space in the volume group that should be used for
creating the thin pool.
maximum: 90
minimum: 10
type: integer
required:
- name
- overprovisionRatio
type: object
required:
- thinPoolConfig
type: object
type: array
type: object
Expand Down
25 changes: 25 additions & 0 deletions config/crd/bases/lvm.topolvm.io_lvmvolumegroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,31 @@ spec:
required:
- nodeSelectorTerms
type: object
thinPoolConfig:
description: ThinPoolConfig contains configurations for the thin-pool
properties:
name:
description: Name of the thin pool to be created
type: string
overprovisionRatio:
description: OverProvisionRatio is the factor by which additional
storage can be provisioned compared to the available storage
in the thin pool.
minimum: 2
type: integer
sizePercent:
description: SizePercent represents percentage of remaining space
in the volume group that should be used for creating the thin
pool.
maximum: 90
minimum: 10
type: integer
required:
- name
- overprovisionRatio
type: object
required:
- thinPoolConfig
type: object
status:
description: LVMVolumeGroupStatus defines the observed state of LVMVolumeGroup
Expand Down
4 changes: 4 additions & 0 deletions config/samples/lvm_v1alpha1_lvmcluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ spec:
storage:
deviceClasses:
- name: vg1
thinPoolConfig:
name: thin-pool-1
sizePercent: 50
overprovisionRatio: 50
1 change: 1 addition & 0 deletions controllers/lvm_volumegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func (c lvmVG) getLvmVolumeGroups(r *LVMClusterReconciler, instance *lvmv1alpha1
Spec: lvmv1alpha1.LVMVolumeGroupSpec{
NodeSelector: deviceClass.NodeSelector,
DeviceSelector: deviceClass.DeviceSelector,
ThinPoolConfig: deviceClass.ThinPoolConfig,
},
}
lvmVolumeGroups = append(lvmVolumeGroups, lvmVolumeGroup)
Expand Down
9 changes: 8 additions & 1 deletion controllers/lvmcluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ var _ = Describe("LVMCluster controller", func() {
},
Spec: lvmv1alpha1.LVMClusterSpec{
Storage: lvmv1alpha1.Storage{
DeviceClasses: []lvmv1alpha1.DeviceClass{{Name: testDeviceClassName}},
DeviceClasses: []lvmv1alpha1.DeviceClass{{
Name: testDeviceClassName,
ThinPoolConfig: &lvmv1alpha1.ThinPoolConfig{
Name: testThinPoolName,
SizePercent: 50,
OverprovisionRatio: 10,
},
}},
},
},
}
Expand Down
1 change: 1 addition & 0 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func TestAPIs(t *testing.T) {

const (
testLvmClusterName = "test-lvmcluster"
testThinPoolName = "test-thinPool"
testLvmClusterNamespace = "openshift-storage"
testDeviceClassName = "test"
testImageName = "test"
Expand Down
34 changes: 17 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ require (
github.com/go-logr/logr v1.2.0
github.com/google/go-cmp v0.5.6
github.com/onsi/ginkgo v1.16.5
github.com/onsi/ginkgo/v2 v2.1.3
github.com/onsi/gomega v1.17.0
github.com/openshift/api v0.0.0-20211028023115-7224b732cc14
github.com/openshift/client-go v0.0.0-20210831095141-e19a065e79f7
github.com/operator-framework/api v0.14.0
github.com/operator-framework/operator-lifecycle-manager v0.20.0
github.com/prometheus/client_golang v1.11.0
github.com/stretchr/testify v1.7.0
github.com/topolvm/topolvm v0.10.3
github.com/topolvm/topolvm v0.11.0
gotest.tools/v3 v3.0.3
k8s.io/api v0.23.4
k8s.io/apimachinery v0.23.4
Expand All @@ -22,7 +25,7 @@ require (
)

require (
cloud.google.com/go v0.81.0 // indirect
cloud.google.com/go v0.99.0 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.18 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.13 // indirect
Expand All @@ -31,7 +34,7 @@ require (
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cybozu-go/log v1.6.0 // indirect
github.com/cybozu-go/netutil v1.2.0 // indirect
github.com/cybozu-go/well v1.10.0 // indirect
Expand All @@ -52,50 +55,47 @@ require (
github.com/json-iterator/go v1.1.12 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/onsi/ginkgo/v2 v2.1.3 // indirect
github.com/operator-framework/api v0.14.0 // indirect
github.com/operator-framework/operator-lifecycle-manager v0.20.0 // indirect
github.com/pelletier/go-toml v1.9.3 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.28.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v1.2.1 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/cobra v1.3.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.8.1 // indirect
github.com/spf13/viper v1.10.1 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.19.1 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2 // indirect
google.golang.org/grpc v1.42.0 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
google.golang.org/grpc v1.43.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/apiextensions-apiserver v0.23.0 // indirect
k8s.io/component-base v0.23.0 // indirect
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/klog/v2 v2.40.1 // indirect
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
k8s.io/utils v0.0.0-20211116205334-6203023598ed // indirect
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
Expand Down
Loading

0 comments on commit d69fbde

Please sign in to comment.