Skip to content

Commit

Permalink
set pinning field in CephSubvolumeGroup CR
Browse files Browse the repository at this point in the history
Updated the CephSubvolumeGroup CR to include the pinning field
with a default value of `Distributed: 1`

Signed-off-by: Nikhil-Ladha <[email protected]>
  • Loading branch information
Nikhil-Ladha committed Dec 12, 2023
1 parent 081cc45 commit 2d16c4f
Show file tree
Hide file tree
Showing 478 changed files with 8,836 additions and 4,011 deletions.
12 changes: 10 additions & 2 deletions config/crd/bases/ocs.openshift.io_storageclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1365,8 +1365,7 @@ spec:
properties:
enabled:
description: Whether to compress the data in transit across
the wire. The default is not set. Requires Ceph Quincy
(v17) or newer.
the wire. The default is not set.
type: boolean
type: object
encryption:
Expand Down Expand Up @@ -1430,6 +1429,10 @@ spec:
- multus
nullable: true
type: string
x-kubernetes-validations:
- message: network provider must be disabled (reverted to empty
string) before a new provider is enabled
rule: self == '' || self == oldSelf
selectors:
additionalProperties:
type: string
Expand All @@ -1456,6 +1459,11 @@ spec:
nullable: true
type: object
type: object
x-kubernetes-validations:
- message: at least one network selector must be specified when using
multus
rule: '!has(self.provider) || (self.provider != ''multus'' || (self.provider
== ''multus'' && size(self.selectors) > 0))'
nfs:
description: NFSSpec defines specific nfs configuration options
properties:
Expand Down
49 changes: 33 additions & 16 deletions controllers/storagecluster/cephfilesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down Expand Up @@ -164,30 +163,48 @@ func (obj *ocsCephFilesystems) ensureCreated(r *StorageClusterReconciler, instan
}

func (r *StorageClusterReconciler) createDefaultSubvolumeGroup(filesystemName, filesystemNamespace string, ownerReferences []metav1.OwnerReference) error {
// TODO: After fix of rook issue https://github.com/rook/rook/issues/13220 add svg name spec

existingsvg := &cephv1.CephFilesystemSubVolumeGroup{}
err := r.Client.Get(r.ctx, types.NamespacedName{Name: defaultSubvolumeGroupName, Namespace: filesystemNamespace}, existingsvg)
defaultPinningValue := 1
cephsvg := &cephv1.CephFilesystemSubVolumeGroup{
ObjectMeta: metav1.ObjectMeta{
Name: generateNameForCephSubvolumeGroup(filesystemName),
Namespace: filesystemNamespace,
OwnerReferences: ownerReferences,
},
Spec: cephv1.CephFilesystemSubVolumeGroupSpec{
Name: defaultSubvolumeGroupName,
FilesystemName: filesystemName,
Pinning: cephv1.CephFilesystemSubVolumeGroupSpecPinning{
Distributed: &defaultPinningValue,
},
},
}

err := r.Client.Get(r.ctx, types.NamespacedName{Name: cephsvg.Name, Namespace: cephsvg.Namespace}, existingsvg)
if err == nil {
if existingsvg.DeletionTimestamp != nil {
r.Log.Info("Unable to restore subvolumegroup because it is marked for deletion.", "subvolumegroup", klog.KRef(filesystemNamespace, defaultSubvolumeGroupName))
return fmt.Errorf("failed to restore subvolumegroup %s because it is marked for deletion", existingsvg.Name)
return fmt.Errorf("Failed to restore subvolumegroup %s because it is marked for deletion", existingsvg.Name)
}
}

objectMeta := metav1.ObjectMeta{Name: defaultSubvolumeGroupName, Namespace: filesystemNamespace, OwnerReferences: ownerReferences}
cephFilesystemSubVolumeGroup := &cephv1.CephFilesystemSubVolumeGroup{ObjectMeta: objectMeta}
mutateFn := func() error {
cephFilesystemSubVolumeGroup.Spec = cephv1.CephFilesystemSubVolumeGroupSpec{
FilesystemName: filesystemName,
r.Log.Info("Restoring original CephSubvolumeGroup.", "CephSubvolumeGroup", klog.KRef(cephsvg.Namespace, cephsvg.Name))
existingsvg.ObjectMeta.OwnerReferences = cephsvg.ObjectMeta.OwnerReferences
existingsvg.Spec = cephsvg.Spec
err = r.Client.Update(context.TODO(), existingsvg)
if err != nil {
r.Log.Error(err, "Unable to update CephSubvolumeGroup.", "CephFileSystem", "CephSubvolumeGroup", klog.KRef(cephsvg.Namespace, cephsvg.Name))
return err
}
} else if errors.IsNotFound(err) {
r.Log.Info("Creating CephSubvolumeGroup.", "CephSubvolumeGroup", klog.KRef(cephsvg.Namespace, cephsvg.Name))
err = r.Client.Create(context.TODO(), cephsvg)
if err != nil {
r.Log.Error(err, "Unable to create CephSubvolumeGroup.", "CephSubvolumeGroup", klog.KRef(cephsvg.Namespace, cephsvg.Name))
return err
}
return nil
}
_, err = ctrl.CreateOrUpdate(r.ctx, r.Client, cephFilesystemSubVolumeGroup, mutateFn)
if err != nil {
r.Log.Error(err, "Could not create/update default csi cephFilesystemSubVolumeGroup.", "cephFilesystemSubVolumeGroup", klog.KRef(cephFilesystemSubVolumeGroup.Namespace, cephFilesystemSubVolumeGroup.Name))
return err
}

return nil
}

Expand Down
3 changes: 2 additions & 1 deletion controllers/storagecluster/cephfilesystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ func TestCreateDefaultSubvolumeGroup(t *testing.T) {
assert.NoError(t, err)

svg := &cephv1.CephFilesystemSubVolumeGroup{}
err = reconciler.Client.Get(context.TODO(), types.NamespacedName{Name: defaultSubvolumeGroupName, Namespace: filesystem[0].Namespace}, svg)
expectedsvgName := generateNameForCephSubvolumeGroup(filesystem[0].Name)
err = reconciler.Client.Get(context.TODO(), types.NamespacedName{Name: expectedsvgName, Namespace: filesystem[0].Namespace}, svg)
assert.NoError(t, err) // no error
}

Expand Down
5 changes: 5 additions & 0 deletions controllers/storagecluster/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,8 @@ func generateCephReplicatedSpec(initData *ocsv1.StorageCluster, poolType string)
func generateStorageQuotaName(storageClassName, quotaName string) string {
return fmt.Sprintf("%s-%s", storageClassName, quotaName)
}

// generateNameForCephSubvolumeGroup function generates a name for CephFilesystemSubVolumeGroup
func generateNameForCephSubvolumeGroup(filesystemName string) string {
return fmt.Sprintf("%s-subvolumegroup", filesystemName)
}
Original file line number Diff line number Diff line change
Expand Up @@ -1365,8 +1365,7 @@ spec:
properties:
enabled:
description: Whether to compress the data in transit across
the wire. The default is not set. Requires Ceph Quincy
(v17) or newer.
the wire. The default is not set.
type: boolean
type: object
encryption:
Expand Down Expand Up @@ -1430,6 +1429,10 @@ spec:
- multus
nullable: true
type: string
x-kubernetes-validations:
- message: network provider must be disabled (reverted to empty
string) before a new provider is enabled
rule: self == '' || self == oldSelf
selectors:
additionalProperties:
type: string
Expand All @@ -1456,6 +1459,11 @@ spec:
nullable: true
type: object
type: object
x-kubernetes-validations:
- message: at least one network selector must be specified when using
multus
rule: '!has(self.provider) || (self.provider != ''multus'' || (self.provider
== ''multus'' && size(self.selectors) > 0))'
nfs:
description: NFSSpec defines specific nfs configuration options
properties:
Expand Down
12 changes: 10 additions & 2 deletions deploy/ocs-operator/manifests/storagecluster.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1364,8 +1364,7 @@ spec:
properties:
enabled:
description: Whether to compress the data in transit across
the wire. The default is not set. Requires Ceph Quincy
(v17) or newer.
the wire. The default is not set.
type: boolean
type: object
encryption:
Expand Down Expand Up @@ -1429,6 +1428,10 @@ spec:
- multus
nullable: true
type: string
x-kubernetes-validations:
- message: network provider must be disabled (reverted to empty
string) before a new provider is enabled
rule: self == '' || self == oldSelf
selectors:
additionalProperties:
type: string
Expand All @@ -1455,6 +1458,11 @@ spec:
nullable: true
type: object
type: object
x-kubernetes-validations:
- message: at least one network selector must be specified when using
multus
rule: '!has(self.provider) || (self.provider != ''multus'' || (self.provider
== ''multus'' && size(self.selectors) > 0))'
nfs:
description: NFSSpec defines specific nfs configuration options
properties:
Expand Down
40 changes: 19 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/ceph/ceph-csi/api v0.0.0-20230713140649-15931b2e4f19
github.com/ceph/go-ceph v0.24.0
github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344
github.com/go-logr/logr v1.2.4
github.com/go-logr/logr v1.3.0
github.com/google/uuid v1.4.0
github.com/imdario/mergo v0.3.16
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.4.0
Expand All @@ -18,7 +18,7 @@ require (
github.com/oklog/run v1.1.0
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.10
github.com/openshift/api v0.0.0-20231010191030-1f9525271dda
github.com/openshift/api v0.0.0-20231204192004-bfea29e5e6c4
github.com/openshift/build-machinery-go v0.0.0-20230306181456-d321ffa04533
github.com/openshift/client-go v0.0.0-20231005121823-e81400b97c46
github.com/openshift/custom-resource-status v1.1.2
Expand All @@ -30,11 +30,11 @@ require (
github.com/prometheus/client_golang v1.17.0
github.com/prometheus/client_model v0.5.0
github.com/rook/rook v1.12.0-alpha.0
github.com/rook/rook/pkg/apis v0.0.0-20231201141116-eacc7e74412e
github.com/rook/rook/pkg/apis v0.0.0-20231211195439-c80ea7b64424
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
go.uber.org/multierr v1.11.0
golang.org/x/net v0.17.0
golang.org/x/net v0.19.0
google.golang.org/grpc v1.56.3
google.golang.org/protobuf v1.31.0
gopkg.in/ini.v1 v1.67.0
Expand All @@ -43,8 +43,8 @@ require (
k8s.io/apiextensions-apiserver v0.28.4
k8s.io/apimachinery v0.28.4
k8s.io/client-go v0.28.4
k8s.io/klog/v2 v2.100.1
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
k8s.io/klog/v2 v2.110.1
k8s.io/utils v0.0.0-20231127182322-b307cd553661
open-cluster-management.io/api v0.11.0
sigs.k8s.io/controller-runtime v0.16.3
)
Expand All @@ -56,13 +56,11 @@ require (
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containernetworking/cni v1.1.2 // indirect
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
github.com/coreos/pkg v0.0.0-20230601102743-20bbbf26f4d8 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.7.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-jose/go-jose/v3 v3.0.1 // indirect
github.com/go-logr/zapr v1.2.4 // indirect
github.com/go-openapi/analysis v0.20.0 // indirect
Expand All @@ -87,11 +85,11 @@ require (
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.4 // indirect
github.com/hashicorp/go-retryablehttp v0.7.5 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7 // indirect
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.8 // indirect
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect
github.com/hashicorp/go-sockaddr v1.0.5 // indirect
github.com/hashicorp/go-sockaddr v1.0.6 // indirect
github.com/hashicorp/hcl v1.0.1-vault-5 // indirect
github.com/hashicorp/vault/api v1.10.0 // indirect
github.com/hashicorp/vault/api/auth/approle v0.5.0 // indirect
Expand All @@ -116,14 +114,14 @@ require (
github.com/tidwall/pretty v1.2.0 // indirect
go.mongodb.org/mongo-driver v1.9.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/exp v0.0.0-20230206171751-46f607a40771 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.14.0 // indirect
golang.org/x/oauth2 v0.15.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.16.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
Expand All @@ -134,10 +132,10 @@ require (
k8s.io/component-base v0.28.4 // indirect
k8s.io/klog v1.0.0 // indirect
k8s.io/kube-aggregator v0.26.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/kube-openapi v0.0.0-20231129212854-f0671cc7e66a // indirect
sigs.k8s.io/container-object-storage-interface-api v0.1.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

Expand Down
Loading

0 comments on commit 2d16c4f

Please sign in to comment.