@@ -29,12 +29,14 @@ import (
2929 "k8s.io/cloud-provider-openstack/pkg/csi/manila/options"
3030 "k8s.io/cloud-provider-openstack/pkg/csi/manila/shareadapters"
3131 clouderrors "k8s.io/cloud-provider-openstack/pkg/util/errors"
32+ "k8s.io/cloud-provider-openstack/pkg/util/metadata"
3233 "k8s.io/klog/v2"
3334)
3435
3536type nodeServer struct {
3637 d * Driver
3738
39+ metadata metadata.IMetadata
3840 supportsNodeStage bool
3941 // The result of NodeStageVolume is stashed away for NodePublishVolume(s) that will follow
4042 nodeStageCache map [volumeID ]stageCacheEntry
@@ -324,13 +326,23 @@ func (ns *nodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstag
324326}
325327
326328func (ns * nodeServer ) NodeGetInfo (ctx context.Context , req * csi.NodeGetInfoRequest ) (* csi.NodeGetInfoResponse , error ) {
329+ nodeID , err := ns .metadata .GetInstanceID ()
330+ if err != nil {
331+ return nil , status .Errorf (codes .Internal , "[NodeGetInfo] unable to retrieve instance id of node %v" , err )
332+ }
333+
327334 nodeInfo := & csi.NodeGetInfoResponse {
328- NodeId : ns . d . nodeID ,
335+ NodeId : nodeID ,
329336 }
330337
331338 if ns .d .withTopology {
339+ zone , err := ns .metadata .GetAvailabilityZone ()
340+ if err != nil {
341+ return nil , status .Errorf (codes .Internal , "[NodeGetInfo] Unable to retrieve availability zone of node %v" , err )
342+ }
343+
332344 nodeInfo .AccessibleTopology = & csi.Topology {
333- Segments : map [string ]string {topologyKey : ns . d . nodeAZ },
345+ Segments : map [string ]string {topologyKey : zone },
334346 }
335347 }
336348
0 commit comments