Skip to content

Commit 605022b

Browse files
author
Power Cloud Robot
authored
Merge pull request #36 from Madhan-SWE/dependency_fixes_v2
PVMInstanceId is added as part of NodeService
2 parents b83198b + 630dd45 commit 605022b

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

pkg/driver/node.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ type nodeService struct {
6363
cloud cloud.Cloud
6464
mounter Mounter
6565
driverOptions *Options
66+
pvmInstanceId string
6667
}
6768

6869
// newNodeService creates a new node service
@@ -83,6 +84,7 @@ func newNodeService(driverOptions *Options) nodeService {
8384
cloud: pvsCloud,
8485
mounter: newNodeMounter(),
8586
driverOptions: driverOptions,
87+
pvmInstanceId: metadata.GetPvmInstanceId(),
8688
}
8789
}
8890

@@ -365,17 +367,11 @@ func (d *nodeService) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetC
365367

366368
func (d *nodeService) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) {
367369
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()
374370

375-
in, err := d.cloud.GetPVMInstanceByID(pvmInstanceId)
371+
in, err := d.cloud.GetPVMInstanceByID(d.pvmInstanceId)
376372
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)
379375
}
380376
image, err := d.cloud.GetImageByID(in.ImageID)
381377
if err != nil {
@@ -389,7 +385,7 @@ func (d *nodeService) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoReque
389385
topology := &csi.Topology{Segments: segments}
390386

391387
return &csi.NodeGetInfoResponse{
392-
NodeId: pvmInstanceId,
388+
NodeId: d.pvmInstanceId,
393389
MaxVolumesPerNode: d.getVolumesLimit(),
394390
AccessibleTopology: topology,
395391
}, nil

0 commit comments

Comments
 (0)