@@ -63,6 +63,7 @@ type nodeService struct {
63
63
cloud cloud.Cloud
64
64
mounter Mounter
65
65
driverOptions * Options
66
+ pvmInstanceId string
66
67
}
67
68
68
69
// newNodeService creates a new node service
@@ -83,6 +84,7 @@ func newNodeService(driverOptions *Options) nodeService {
83
84
cloud : pvsCloud ,
84
85
mounter : newNodeMounter (),
85
86
driverOptions : driverOptions ,
87
+ pvmInstanceId : metadata .GetPvmInstanceId (),
86
88
}
87
89
}
88
90
@@ -365,17 +367,11 @@ func (d *nodeService) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetC
365
367
366
368
func (d * nodeService ) NodeGetInfo (ctx context.Context , req * csi.NodeGetInfoRequest ) (* csi.NodeGetInfoResponse , error ) {
367
369
klog .V (4 ).Infof ("NodeGetInfo: called with args %+v" , * req )
368
- klog .V (4 ).Infof ("retrieving node info from metadata service" )
369
- metadata , err := cloud .NewMetadataService (cloud .DefaultKubernetesAPIClient )
370
- if err != nil {
371
- panic (err )
372
- }
373
- pvmInstanceId := metadata .GetPvmInstanceId ()
374
370
375
- in , err := d .cloud .GetPVMInstanceByID (pvmInstanceId )
371
+ in , err := d .cloud .GetPVMInstanceByID (d . pvmInstanceId )
376
372
if err != nil {
377
- klog .Errorf ("failed to get the instance for pvmInstanceId %s, err: %s" , pvmInstanceId , err )
378
- return nil , fmt .Errorf ("failed to get the instance for pvmInstanceId %s, err: %s" , pvmInstanceId , err )
373
+ klog .Errorf ("failed to get the instance for pvmInstanceId %s, err: %s" , d . pvmInstanceId , err )
374
+ return nil , fmt .Errorf ("failed to get the instance for pvmInstanceId %s, err: %s" , d . pvmInstanceId , err )
379
375
}
380
376
image , err := d .cloud .GetImageByID (in .ImageID )
381
377
if err != nil {
@@ -389,7 +385,7 @@ func (d *nodeService) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoReque
389
385
topology := & csi.Topology {Segments : segments }
390
386
391
387
return & csi.NodeGetInfoResponse {
392
- NodeId : pvmInstanceId ,
388
+ NodeId : d . pvmInstanceId ,
393
389
MaxVolumesPerNode : d .getVolumesLimit (),
394
390
AccessibleTopology : topology ,
395
391
}, nil
0 commit comments