@@ -169,10 +169,16 @@ func (s *controllerService) CreateVolume(pctx lctx.Context, preq *lcsi.CreateVol
169
169
volumeSource := preq .GetVolumeContentSource ()
170
170
if volumeSource != nil {
171
171
if _ , ok := volumeSource .GetType ().(* lcsi.VolumeContentSource_Snapshot ); ! ok {
172
+ llog .ErrorS (nil , "[ERROR] - CreateVolume: VolumeContentSource not supported" , "volumeID" , volName )
173
+ s .k8sClient .PersistentVolumeClaimEventWarning (pctx , cvr .PvcNamespaceTag , cvr .PvcNameTag ,
174
+ "CsiVolumeContentSourceNotSupported" , "VolumeContentSource_Snapshot not supported" )
172
175
return nil , ErrVolumeContentSourceNotSupported
173
176
}
174
177
sourceSnapshot := volumeSource .GetSnapshot ()
175
178
if sourceSnapshot == nil {
179
+ llog .ErrorS (nil , "[ERROR] - CreateVolume: Snapshot is nil within volumeContentSource" , "volumeID" , volName )
180
+ s .k8sClient .PersistentVolumeClaimEventWarning (pctx , cvr .PvcNamespaceTag , cvr .PvcNameTag ,
181
+ "CsiSnapshotNotFound" , "Snapshot is nil within volumeContentSource" )
176
182
return nil , ErrSnapshotIsNil
177
183
}
178
184
cvr = cvr .WithSnapshotID (sourceSnapshot .GetSnapshotId ())
@@ -181,6 +187,8 @@ func (s *controllerService) CreateVolume(pctx lctx.Context, preq *lcsi.CreateVol
181
187
respCtx , err := cvr .ToResponseContext (volCap )
182
188
if err != nil {
183
189
llog .ErrorS (err , "[ERROR] - CreateVolume: Failed to parse response context" , "volumeID" , volName )
190
+ s .k8sClient .PersistentVolumeClaimEventWarning (pctx , cvr .PvcNamespaceTag , cvr .PvcNameTag ,
191
+ "CsiCreateVolumeRequestInvalid" , err .Error ())
184
192
return nil , err
185
193
}
186
194
@@ -194,13 +202,17 @@ func (s *controllerService) CreateVolume(pctx lctx.Context, preq *lcsi.CreateVol
194
202
pvc , ierr := s .k8sClient .GetPersistentVolumeClaimByName (pctx , cvr .PvcNamespaceTag , cvr .PvcNameTag )
195
203
if ierr != nil {
196
204
llog .ErrorS (ierr .GetError (), "[ERROR] - CreateVolume: Failed to get PVC" , "pvcName" , cvr .PvcNameTag , "pvcNamespace" , cvr .PvcNamespaceTag )
205
+ s .k8sClient .PersistentVolumeClaimEventWarning (pctx , cvr .PvcNamespaceTag , cvr .PvcNameTag ,
206
+ "CsiGetPersistentVolumeClaimFailure" , ierr .GetMessage ())
197
207
return nil , ierr .GetError ()
198
208
}
199
209
200
210
// Get the StorageClass from the API server
201
211
sc , ierr := s .k8sClient .GetStorageClassByName (pctx , pvc .GetStorageClassName ())
202
212
if ierr != nil {
203
213
llog .ErrorS (ierr .GetError (), "[ERROR] - CreateVolume: Failed to get StorageClass" , "storageClassName" , pvc .GetStorageClassName ())
214
+ s .k8sClient .PersistentVolumeClaimEventWarning (pctx , cvr .PvcNamespaceTag , cvr .PvcNameTag ,
215
+ "CsiGetStorageClassFailure" , ierr .GetMessage ())
204
216
return nil , ierr .GetError ()
205
217
}
206
218
@@ -215,11 +227,13 @@ func (s *controllerService) CreateVolume(pctx lctx.Context, preq *lcsi.CreateVol
215
227
newVol , sdkErr := s .cloud .EitherCreateResizeVolume (cvr .ToSdkCreateVolumeRequest ())
216
228
if sdkErr != nil {
217
229
llog .ErrorS (sdkErr .GetError (), "[ERROR] - CreateVolume: failed to create volume" , sdkErr .GetErrorMessages ())
230
+ s .k8sClient .PersistentVolumeClaimEventWarning (pctx , cvr .PvcNamespaceTag , cvr .PvcNameTag ,
231
+ "CsiCreateVolumeFailure" , sdkErr .GetMessage ())
218
232
return nil , sdkErr .GetError ()
219
233
}
220
234
221
235
s .k8sClient .PersistentVolumeClaimEventNormal (pctx , cvr .PvcNamespaceTag , cvr .PvcNameTag ,
222
- "CsiCreateVolumeSuccess" , lfmt .Sprintf ("Volume created successfully with ID %s for PVC %s" , newVol .Id , newVol .Name ))
236
+ "CsiCreateVolumeSuccess" , lfmt .Sprintf ("Volume created successfully with ID %s for PersistentVolume %s" , newVol .Id , newVol .Name ))
223
237
return newCreateVolumeResponse (newVol , cvr , respCtx ), nil
224
238
}
225
239
0 commit comments