@@ -116,10 +116,12 @@ func newControllerServer(region string) (*controllerServer, error) {
116116 return nil , err
117117 }
118118 kubeclient := mustGetKubeClient ()
119- nodeInformer := informerv1 .NewFilteredNodeInformer (kubeclient , 0 , cache.Indexers {NODEID_INDEX : nodeIndexFunc }, func (options * metav1.ListOptions ) {
119+ nodeInformer := informerv1 .NewFilteredNodeInformer (kubeclient , 0 , cache.Indexers {NodeIDIndex : nodeIndexFunc }, func (options * metav1.ListOptions ) {
120120 options .FieldSelector = fields .OneTermEqualSelector ("alibabacloud.com/lingjun-worker" , "true" ).String ()
121121 })
122- nodeInformer .SetTransform (nodeTransformFunc )
122+ if err := nodeInformer .SetTransform (nodeTransformFunc ); err != nil {
123+ return nil , fmt .Errorf ("failed to set transform function: %w" , err )
124+ }
123125 return & controllerServer {
124126 vscManager : internal .NewPrimaryVscManagerWithCache (efloClient ),
125127 attachDetacher : internal .NewCPFSAttachDetacher (nasClient ),
@@ -137,16 +139,6 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
137139 logger := klog .FromContext (ctx )
138140 logger .V (2 ).Info ("starting" )
139141
140- // Handle static volume creation (existing fileset)
141- csiVolume , err := staticFileSetCreate (req , cs .filsetManager )
142- if err != nil {
143- return nil , status .Errorf (codes .InvalidArgument , "create static volume failed: %v" , err )
144- }
145- if csiVolume != nil {
146- klog .Infof ("CreateVolume: static volume create successful, pvName: %s, VolumeId: %s, volumeContext: %v" , req .Name , csiVolume .VolumeId , csiVolume .VolumeContext )
147- return & csi.CreateVolumeResponse {Volume : csiVolume }, nil
148- }
149-
150142 // Validate parameters
151143 if err := validateFileSetParameters (req ); err != nil {
152144 klog .Errorf ("CreateVolume: error parameters from input: %v, with error: %v" , req .Name , err )
@@ -366,22 +358,20 @@ func (cs *controllerServer) ControllerUnpublishVolume(ctx context.Context, req *
366358 if ! nodeStatus .HasPrefixInUse (cpfsID ) {
367359 err := cs .attachDetacher .Detach (ctx , cpfsID , vsc .VscID )
368360 if err != nil {
369- return nil , status .Error (codes .Internal , err .Error ())
361+ return nil , status .Errorf (codes .Internal , "detach error: %v" , err .Error ())
370362 }
371363 return & csi.ControllerUnpublishVolumeResponse {}, nil
372364 }
373- // 分支2:inuse & attach 同时存在,跳过卸载,返回成功
374365 if nodeStatus .HasPrefixInUse (cpfsID ) && nodeStatus .HasVolumeAttachment (cpfsID ) {
375- klog .Infof ("volume is in use and attached, skip detach for cpfsID: %s at node: %s " , cpfsID , lingjunInstanceID )
366+ klog .InfoS ("volume is in use and attached, skip detach" , " cpfsID" , cpfsID , "lingjunID" , lingjunInstanceID )
376367 return & csi.ControllerUnpublishVolumeResponse {}, nil
377368 }
378- // 分支3:inuse 存在,除了当前的 cpfs+fileset 之外的 attach 不存在,双重检查后卸载
379369 if nodeStatus .HasPrefixInUse (cpfsID ) && ! nodeStatus .HasVolumeAttachment (cpfsID ) {
380370 currentStatus , err := cs .getActualStateOfNodeVolumeAttached (nodeStatus .Name ) // TODO: checkRemoteNodeStatusByNodeName
381371 if err == nil && ! currentStatus .HasVolumeAttachmentExceptVolumeHandle (cpfsID , req .VolumeId ) {
382372 err := cs .attachDetacher .Detach (ctx , cpfsID , vsc .VscID )
383373 if err != nil {
384- return nil , status .Error (codes .Internal , err .Error ())
374+ return nil , status .Errorf (codes .Internal , "detach error: %v" , err .Error ())
385375 }
386376 // TODO: patch event 到 node
387377 return & csi.ControllerUnpublishVolumeResponse {}, nil
0 commit comments