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

enable static pv to create in dynamic way #1288

Merged
merged 41 commits into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
9be344d
enable static pv to create in dynamic way
badri-pathak Feb 12, 2025
9640f2d
Merge remote-tracking branch 'upstream/dev' into static_pv_to_dynamic
badri-pathak Feb 12, 2025
b18a751
Merge branch 'dev' into static_pv_to_dynamic
Jainbrt Feb 13, 2025
ec6371c
Merge branch 'dev' into static_pv_to_dynamic
saurabhwani5 Feb 13, 2025
97fbb2b
static target shouldn't allowed for snapsource or volsource
badri-pathak Feb 14, 2025
bb8374d
expand volume should increase quota is already set
badri-pathak Feb 14, 2025
793d8c5
code refine
badri-pathak Feb 15, 2025
63f73be
review comments
badri-pathak Feb 22, 2025
71c3d92
Merge branch 'dev' into static_pv_to_dynamic
Jainbrt Feb 24, 2025
7ab9c53
Merge branch 'dev' into static_pv_to_dynamic
saurabhwani5 Feb 24, 2025
6ee48b3
moved yamls at main directory
badri-pathak Feb 25, 2025
2ed4948
added dockerignore file not to build when examples got changed
badri-pathak Feb 25, 2025
ce314ea
Merge branch 'dev' into static_pv_to_dynamic
badri-pathak Feb 25, 2025
2cb9371
moved yamls at main directory
badri-pathak Feb 25, 2025
60c8947
Merge branch 'dev' into static_pv_to_dynamic
Jainbrt Feb 26, 2025
89eaea6
Merge branch 'dev' into static_pv_to_dynamic
badri-pathak Mar 5, 2025
e0634ed
Merge branch 'dev' into static_pv_to_dynamic
badri-pathak Mar 10, 2025
a1e7f3e
Merge branch 'dev' into static_pv_to_dynamic
badri-pathak Mar 13, 2025
29d8bee
Merge branch 'dev' into static_pv_to_dynamic
badri-pathak Mar 14, 2025
f200a37
Merge branch 'dev' into static_pv_to_dynamic
badri-pathak Mar 14, 2025
6799ff0
Merge branch 'dev' into static_pv_to_dynamic
Jainbrt Mar 14, 2025
86a7c09
Merge branch 'dev' into static_pv_to_dynamic
badri-pathak Mar 14, 2025
a205294
issue fixes for clone
badri-pathak Mar 18, 2025
9dcdcba
issue fixes for shallowcopy
badri-pathak Mar 18, 2025
d506cd9
Merge branch 'dev' into static_pv_to_dynamic
badri-pathak Mar 19, 2025
03c56b7
typo fixes
badri-pathak Mar 19, 2025
5e2a6ef
typo fixes
badri-pathak Mar 19, 2025
c92b3e8
fileset name can be provided using volumeattributeclass
badri-pathak Mar 19, 2025
5db0514
fileset name can be provided using volumeattributeclass
badri-pathak Mar 19, 2025
105019f
blocking shallow copy creation from static source
badri-pathak Mar 20, 2025
82113d0
Merge branch 'dev' into static_pv_to_dynamic
Jainbrt Mar 25, 2025
53943a4
Merge remote-tracking branch 'upstream/dev' into static_pv_to_dynamic
badri-pathak Mar 25, 2025
2be0bc9
accomodate filesetcomment changes into staticvolume pr
badri-pathak Mar 25, 2025
1540041
added shallow copy example file
badri-pathak Mar 25, 2025
0303754
Merge branch 'dev' into static_pv_to_dynamic
badri-pathak Mar 27, 2025
e366a41
Merge branch 'dev' into static_pv_to_dynamic
badri-pathak Mar 28, 2025
df09fd4
addressed review comment
badri-pathak Mar 28, 2025
957f593
addressed review comment and issue 8443
badri-pathak Mar 28, 2025
c4f20d2
addressed review comment
badri-pathak Mar 28, 2025
f1d8d5d
addressed review comment
badri-pathak Mar 28, 2025
7a2b1d1
Merge branch 'dev' into static_pv_to_dynamic
hemalathagajendran Mar 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions driver/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
examples
9 changes: 5 additions & 4 deletions driver/csiplugin/connectors/connectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,15 @@ const (
UserSpecifiedCacheMode string = "cacheMode"
UserSpecifiedVolumeType string = "volumeType"
UserSpecifiedVolNamePrefix string = "volNamePrefix"
UserSpecifiedExistingData string = "existingData"

// AFM tuning parameters to modify cache fileset
AfmReadSparseThreshold string = "afmReadSparseThreshold"
AfmNumFlushThreads string = "afmNumFlushThreads"
AfmPrefetchThreshold string = "afmPrefetchThreshold"
AfmObjectFastReaddir string = "afmObjectFastReaddir"
AfmNumFlushThreads string = "afmNumFlushThreads"
AfmPrefetchThreshold string = "afmPrefetchThreshold"
AfmObjectFastReaddir string = "afmObjectFastReaddir"
AfmFileOpenRefreshInterval string = "afmFileOpenRefreshInterval"
AfmNumReadThreads string = "afmNumReadThreads"
AfmNumReadThreads string = "afmNumReadThreads"

// default value for AFM tuning parameters
AfmNumFlushThreadsDefault = 4
Expand Down
3 changes: 1 addition & 2 deletions driver/csiplugin/connectors/rest_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ func (s *SpectrumRestV2) WaitForJobCompletionWithResp(ctx context.Context, statu
klog.V(4).Infof("[%s] rest_v2 WaitForJobCompletionWithResp. jobID: %d, statusCode: %d", utils.GetLoggerId(ctx), jobID, statusCode)

if s.checkAsynchronousJob(statusCode) {
response := GenericResponse{}
jobURL := fmt.Sprintf("scalemgmt/v2/jobs/%d?fields=:all:", jobID)
response, err := s.AsyncJobCompletion(ctx, jobURL)
if err != nil {
Expand Down Expand Up @@ -1778,7 +1777,7 @@ func (s *SpectrumRestV2) GetSnapshotCreateTimestamp(ctx context.Context, filesys
return "", fmt.Errorf("unable to list snapshot %v", snapName)
}

return fmt.Sprintf(getSnapshotResponse.Snapshots[0].Created), nil
return fmt.Sprintf("%v", getSnapshotResponse.Snapshots[0].Created), nil
}

//nolint:dupl
Expand Down
183 changes: 159 additions & 24 deletions driver/csiplugin/controllerserver.go

Large diffs are not rendered by default.

51 changes: 42 additions & 9 deletions driver/csiplugin/gpfs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ import (
)

const (
dependentFileset = "dependent"
independentFileset = "independent"
scversion1 = "1"
scversion2 = "2"
sharedPermissions = "777"
defaultVolNamePrefix = "pvc"
VolNamePrefixEnvKey = "VOLUME_NAME_PREFIX"
dependentFileset = "dependent"
independentFileset = "independent"
scversion1 = "1"
scversion2 = "2"
sharedPermissions = "777"
defaultVolNamePrefix = "pvc"
VolNamePrefixEnvKey = "VOLUME_NAME_PREFIX"
existingDataAllowedVal = "enabled"
AFMCacheSharedPermission = "0777"
)

Expand Down Expand Up @@ -99,6 +100,8 @@ type scaleVolume struct {
VolumeType string `json:"volumeType"`
CacheMode string `json:"cacheMode"`
VolNamePrefix string `json:"volNamePrefix"`
ExistingData string `json:"existingData"`
IsStaticPVBased bool `json:"isStaticPV"`
}

type scaleVolId struct {
Expand All @@ -113,6 +116,7 @@ type scaleVolId struct {
StorageClassType string
ConsistencyGroup string
VolType string
IsStaticPVBased bool
}

type scaleSnapId struct {
Expand Down Expand Up @@ -172,6 +176,13 @@ func getScaleVolumeOptions(ctx context.Context, volOptions map[string]string) (*
volumeType, volumeTypeSpecified := volOptions[connectors.UserSpecifiedVolumeType]
cacheMode, cacheModeSpecified := volOptions[connectors.UserSpecifiedCacheMode]

// for static pv
scaleVol.IsStaticPVBased = false
existingData, existingDataSpecified := volOptions[connectors.UserSpecifiedExistingData]
if existingDataSpecified && existingData == "enabled" {
scaleVol.IsStaticPVBased = true
}

// Handling empty values
scaleVol.VolDirBasePath = ""
scaleVol.InodeLimit = ""
Expand All @@ -192,10 +203,13 @@ func getScaleVolumeOptions(ctx context.Context, volOptions map[string]string) (*
return &scaleVolume{}, status.Error(codes.InvalidArgument, "The parameter \"version\" can have values only "+
"\""+scversion1+"\" or \""+scversion2+"\"")
}
if storageClassType == scversion2 {
if storageClassType == scversion2 && scaleVol.IsStaticPVBased {
return &scaleVolume{}, status.Error(codes.InvalidArgument, "The parameter \"existingData\" is not allowed for version "+""+scversion2+"\"")
} else if storageClassType == scversion2 {
isSCAdvanced = true
scaleVol.StorageClassType = STORAGECLASS_ADVANCED
}

if storageClassType == scversion1 {
scaleVol.StorageClassType = STORAGECLASS_CLASSIC
}
Expand Down Expand Up @@ -345,6 +359,18 @@ func getScaleVolumeOptions(ctx context.Context, volOptions map[string]string) (*
}
}

if scaleVol.IsStaticPVBased {
if uidSpecified || gidSpecified || isSharedSpecified || inodeLimSpecified || isPermissionsSpecified || isNodeClassSpecified {
return &scaleVolume{}, status.Error(codes.InvalidArgument, "The parameters \"uid\" , \"gid\" , \"inodeLimit\" , \"shared\" , \"nodeClass\" and \"permissions\" are not allowed in storageClass for static volumes i.e. with \"existingData\"")
}
if volDirPathSpecified {
return &scaleVolume{}, status.Error(codes.InvalidArgument, "volDirBasePath is not allowed in storageClass for static volumes i.e. with \"existingData\"")
}
if isCompressionSpecified || isTierSpecified {
return &scaleVolume{}, status.Error(codes.InvalidArgument, "The parameters \"compression\" and \"tier\" are not supported in storageClass for static volumes i.e. with \"existingData\"")
}
}

/* Get UID/GID */
if uidSpecified {
scaleVol.VolUid = uid
Expand Down Expand Up @@ -405,7 +431,13 @@ func getScaleVolumeOptions(ctx context.Context, volOptions map[string]string) (*
scaleVol.NodeClass = nodeClass
}

if isCGSpecified {
if scaleVol.IsStaticPVBased {
Copy link
Member

Choose a reason for hiding this comment

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

if condition for static pv and else condition has the same code. can we combine it together

Copy link
Member Author

Choose a reason for hiding this comment

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

addressed the comment

cgPrefix := utils.GetEnv("CSI_CG_PREFIX", notFound)
if cgPrefix == notFound {
return &scaleVolume{}, status.Error(codes.InvalidArgument, "Failed to extract the consistencyGroup prefix")
}
scaleVol.ConsistencyGroup = fmt.Sprintf("%s-%s", cgPrefix, volOptions["csi.storage.k8s.io/pvc/namespace"])
} else if isCGSpecified {
scaleVol.ConsistencyGroup = cg
} else {
cgPrefix := utils.GetEnv("CSI_CG_PREFIX", notFound)
Expand Down Expand Up @@ -658,6 +690,7 @@ func getVolIDMembers(vID string) (scaleVolId, error) {
} else {
vIdMem.IsFilesetBased = true
}

} else {
vIdMem.IsFilesetBased = true
}
Expand Down
2 changes: 1 addition & 1 deletion driver/csiplugin/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, c
u, err := url.Parse(endpoint)

if err != nil {
klog.Fatalf(err.Error())
klog.Fatalf("%v", err.Error())
}

var addr string
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ibm-spectrum-scale-pvc-from-snapshot-static
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
storageClassName: ibm-spectrum-scale-csi-fileset
dataSource:
name: ibm-spectrum-scale-snapshot-static
kind: VolumeSnapshot
apiGroup: snapshot.storage.k8s.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: ibm-spectrum-scale-snapshot-static
spec:
volumeSnapshotClassName: ibm-spectrum-scale-snapshotclass
source:
persistentVolumeClaimName: scale-static-pvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ibm-spectrum-scale-static-pvc-clone-from-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
storageClassName: ibm-spectrum-scale-csi-static-dependent
dataSource:
name: scale-static-pvc
kind: PersistentVolumeClaim
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ibm-spectrum-scale-static-pvc-clone-from-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
storageClassName: ibm-spectrum-scale-csi-fileset
dataSource:
name: scale-static-pvc
kind: PersistentVolumeClaim
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: scale-static-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
storageClassName: ibm-spectrum-scale-csi-static-dependent

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: scale-static-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
storageClassName: ibm-spectrum-scale-csi-static

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ibm-spectrum-scale-csi-static-dependent
provisioner: spectrumscale.csi.ibm.com
parameters:
volBackendFs: "fs1"
existingData: "enabled"
filesetType: "dependent"
parentFileset: "scale-static-pvc-parent-1"
reclaimPolicy: Delete
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ibm-spectrum-scale-csi-static-expansion
provisioner: spectrumscale.csi.ibm.com
parameters:
volBackendFs: "fs1"
existingData: "enabled"
reclaimPolicy: Delete
allowVolumeExpansion: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ibm-spectrum-scale-csi-static
provisioner: spectrumscale.csi.ibm.com
parameters:
volBackendFs: "fs1"
existingData: "enabled"
reclaimPolicy: Delete
16 changes: 16 additions & 0 deletions driver/examples/staticVolume/staticprovisioning/pvcfrmsnap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ibm-spectrum-scale-pvc-from-snapshot
namespace: default
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
storageClassName: ibm-spectrum-scale-storageclass
dataSource:
name: ibm-spectrum-scale-snapshot
kind: VolumeSnapshot
apiGroup: snapshot.storage.k8s.io
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: Pod
metadata:
name: csi-scale-fsetdemo-pod
name: csi-scale-staticdemo-pod
labels:
app: nginx
spec:
Expand All @@ -16,6 +16,6 @@ spec:
volumes:
- name: mypvc
persistentVolumeClaim:
claimName: scale-fset-pvc
claimName: scale-static-pvc
readOnly: false

6 changes: 6 additions & 0 deletions driver/examples/version1/snapshot/volsnapclass.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata:
name: ibm-spectrum-scale-snapshotclass
driver: spectrumscale.csi.ibm.com
deletionPolicy: Delete