Skip to content

Commit

Permalink
Merge pull request #2570 from leelavg/rename-request-type
Browse files Browse the repository at this point in the history
change storagerequest spec.type to be either block or sharedfile
  • Loading branch information
openshift-merge-bot[bot] authored Apr 22, 2024
2 parents 6520010 + beec2a0 commit faced96
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha1/storagerequest_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

// StorageRequestSpec defines the desired state of StorageRequest
type StorageRequestSpec struct {
//+kubebuilder:validation:Enum=blockpool;sharedfilesystem
//+kubebuilder:validation:Enum=block;sharedfile
Type string `json:"type"`
EncryptionMethod string `json:"encryptionMethod,omitempty"`
StorageProfile string `json:"storageProfile,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions config/crd/bases/ocs.openshift.io_storagerequests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ spec:
type: string
type:
enum:
- blockpool
- sharedfilesystem
- block
- sharedfile
type: string
required:
- type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ spec:
apiservicedefinitions: {}
customresourcedefinitions:
owned:
- description: StorageRequest is the Schema for the StorageRequests API
displayName: Storage Request
kind: StorageRequest
name: storagerequests.ocs.openshift.io
version: v1alpha1
- description: OCSInitialization represents the initial data to be created when
the operator is installed.
displayName: OCS Initialization
Expand Down Expand Up @@ -49,6 +44,11 @@ spec:
kind: StorageProfile
name: storageprofiles.ocs.openshift.io
version: v1
- description: StorageRequest is the Schema for the StorageRequests API
displayName: Storage Request
kind: StorageRequest
name: storagerequests.ocs.openshift.io
version: v1alpha1
description: |
**Red Hat OpenShift Container Storage** deploys three operators.
Expand Down
12 changes: 6 additions & 6 deletions controllers/storagerequest/storagerequest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (r *StorageRequestReconciler) initPhase() error {
}

// check request status already contains the name of the resource. if not, add it.
if r.StorageRequest.Spec.Type == "blockpool" {
if r.StorageRequest.Spec.Type == "block" {
// initialize in-memory structs
r.cephRadosNamespace = &rookCephv1.CephBlockPoolRadosNamespace{}
r.cephRadosNamespace.Namespace = r.OperatorNamespace
Expand Down Expand Up @@ -243,7 +243,7 @@ func (r *StorageRequestReconciler) initPhase() error {
} else {
return fmt.Errorf("invalid number of CephBlockPoolRadosNamespaces for storage consumer %q: found %d, expecting 0 or 1", r.storageConsumer.Name, rnsItemsLen)
}
} else if r.StorageRequest.Spec.Type == "sharedfilesystem" {
} else if r.StorageRequest.Spec.Type == "sharedfile" {
r.cephFilesystemSubVolumeGroup = &rookCephv1.CephFilesystemSubVolumeGroup{}
r.cephFilesystemSubVolumeGroup.Namespace = r.OperatorNamespace

Expand Down Expand Up @@ -303,7 +303,7 @@ func (r *StorageRequestReconciler) reconcilePhases() (reconcile.Result, error) {
return reconcile.Result{}, fmt.Errorf("failed to add finalizer: %v", err)
}
}
if r.StorageRequest.Spec.Type == "blockpool" {
if r.StorageRequest.Spec.Type == "block" {

if err := r.reconcileCephClientRBDProvisioner(); err != nil {
return reconcile.Result{}, err
Expand All @@ -317,7 +317,7 @@ func (r *StorageRequestReconciler) reconcilePhases() (reconcile.Result, error) {
return reconcile.Result{}, err
}

} else if r.StorageRequest.Spec.Type == "sharedfilesystem" {
} else if r.StorageRequest.Spec.Type == "sharedfile" {
if err := r.reconcileCephClientCephFSProvisioner(); err != nil {
return reconcile.Result{}, err
}
Expand Down Expand Up @@ -639,15 +639,15 @@ func (r *StorageRequestReconciler) setCephResourceStatus(name string, kind strin
}

func (r *StorageRequestReconciler) deletionPhase() error {
if r.StorageRequest.Spec.Type == "blockpool" {
if r.StorageRequest.Spec.Type == "block" {
if err := r.get(r.cephRadosNamespace); err != nil && !errors.IsNotFound(err) {
return fmt.Errorf("failed to get CephRadosNamespace: %v", err)
} else if err == nil && util.AddAnnotation(r.cephRadosNamespace, forceDeletionAnnotationKey, "true") {
if err := r.update(r.cephRadosNamespace); err != nil {
return fmt.Errorf("failed to annotate CephRadosNamespace: %v", err)
}
}
} else if r.StorageRequest.Spec.Type == "sharedfilesystem" {
} else if r.StorageRequest.Spec.Type == "sharedfile" {
if err := r.get(r.cephFilesystemSubVolumeGroup); err != nil && !errors.IsNotFound(err) {
return fmt.Errorf("failed to get CephFileSystemSubVolumeGroup: %v", err)
} else if err == nil && util.AddAnnotation(r.cephFilesystemSubVolumeGroup, forceDeletionAnnotationKey, "true") {
Expand Down
6 changes: 3 additions & 3 deletions controllers/storagerequest/storagerequest_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func TestCephBlockPool(t *testing.T) {

r := createFakeReconciler(t)
r.StorageRequest.Status.CephResources = c.cephResources
r.StorageRequest.Spec.Type = "blockpool"
r.StorageRequest.Spec.Type = "block"

c.createObjects = append(c.createObjects, fakeStorageConsumer)
c.createObjects = append(c.createObjects, r.StorageRequest)
Expand Down Expand Up @@ -381,7 +381,7 @@ func TestCephFsSubVolGroup(t *testing.T) {
fmt.Println(caseLabel)

r := createFakeReconciler(t)
r.StorageRequest.Spec.Type = "sharedfilesystem"
r.StorageRequest.Spec.Type = "sharedfile"

c.createObjects = append(c.createObjects, fakeCephFs)
c.createObjects = append(c.createObjects, fakeStorageConsumer)
Expand Down Expand Up @@ -411,7 +411,7 @@ func TestCephFsSubVolGroup(t *testing.T) {
fmt.Println(caseLabel)

r := createFakeReconciler(t)
r.StorageRequest.Spec.Type = "sharedfilesystem"
r.StorageRequest.Spec.Type = "sharedfile"
fakeClient := newFakeClientBuilder(r.Scheme).
WithRuntimeObjects(fakeStorageConsumer, r.StorageRequest)
r.Client = fakeClient.Build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ spec:
type: string
type:
enum:
- blockpool
- sharedfilesystem
- block
- sharedfile
type: string
required:
- type
Expand Down
4 changes: 2 additions & 2 deletions deploy/ocs-operator/manifests/storagerequest.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ spec:
type: string
type:
enum:
- blockpool
- sharedfilesystem
- block
- sharedfile
type: string
required:
- type
Expand Down

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

4 changes: 2 additions & 2 deletions services/provider/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ type StorageType uint

const (
StorageTypeBlock StorageType = iota
StorageTypeSharedfile
StorageTypeSharedFile
)

func (cc *OCSProviderClient) FulfillStorageClaim(
Expand All @@ -138,7 +138,7 @@ func (cc *OCSProviderClient) FulfillStorageClaim(
return nil, fmt.Errorf("provider client is closed")
}
var st pb.FulfillStorageClaimRequest_StorageType
if storageType == StorageTypeSharedfile {
if storageType == StorageTypeSharedFile {
st = pb.FulfillStorageClaimRequest_SHAREDFILE
} else if storageType == StorageTypeBlock {
st = pb.FulfillStorageClaimRequest_BLOCK
Expand Down
6 changes: 3 additions & 3 deletions services/provider/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,9 @@ func (s *OCSProviderServer) FulfillStorageClaim(ctx context.Context, req *pb.Ful
var storageType string
switch req.StorageType {
case pb.FulfillStorageClaimRequest_BLOCK:
storageType = "blockpool"
storageType = "block"
case pb.FulfillStorageClaimRequest_SHAREDFILE:
storageType = "sharedfilesystem"
storageType = "sharedfile"
default:
return nil, status.Errorf(codes.InvalidArgument, "encountered an unknown storage type, %s", storageType)
}
Expand Down Expand Up @@ -569,7 +569,7 @@ func (s *OCSProviderServer) GetStorageClaimConfig(ctx context.Context, req *pb.S

idProp := "userID"
keyProp := "userKey"
if storageRequest.Spec.Type == "sharedfilesystem" {
if storageRequest.Spec.Type == "sharedfile" {
idProp = "adminID"
keyProp = "adminKey"
}
Expand Down
2 changes: 1 addition & 1 deletion services/provider/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ func TestOCSProviderServerGetStorageClaimConfig(t *testing.T) {
Namespace: serverNamespace,
},
Spec: ocsv1alpha1.StorageRequestSpec{
Type: "sharedfilesystem",
Type: "sharedfile",
},
Status: ocsv1alpha1.StorageRequestStatus{
CephResources: []*ocsv1alpha1.CephResourcesSpec{
Expand Down

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

0 comments on commit faced96

Please sign in to comment.