Skip to content

Commit 4d5fba5

Browse files
authored
Merge pull request #231 from Jiawei0227/master
Add topology in the CreateVolumeResponse for existing volume
2 parents 77d8eb3 + 075d973 commit 4d5fba5

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

pkg/hostpath/controllerserver.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
121121
return nil, status.Errorf(codes.OutOfRange, "Requested capacity %d exceeds maximum allowed %d", capacity, maxStorageCapacity)
122122
}
123123

124+
topologies := []*csi.Topology{&csi.Topology{
125+
Segments: map[string]string{TopologyKeyNode: cs.nodeID},
126+
}}
127+
124128
// Need to check for already existing volume name, and if found
125129
// check for the requested capacity and already allocated capacity
126130
if exVol, err := getVolumeByName(req.GetName()); err == nil {
@@ -148,10 +152,11 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
148152
// TODO (sbezverk) Do I need to make sure that volume still exists?
149153
return &csi.CreateVolumeResponse{
150154
Volume: &csi.Volume{
151-
VolumeId: exVol.VolID,
152-
CapacityBytes: int64(exVol.VolSize),
153-
VolumeContext: req.GetParameters(),
154-
ContentSource: req.GetVolumeContentSource(),
155+
VolumeId: exVol.VolID,
156+
CapacityBytes: int64(exVol.VolSize),
157+
VolumeContext: req.GetParameters(),
158+
ContentSource: req.GetVolumeContentSource(),
159+
AccessibleTopology: topologies,
155160
},
156161
}, nil
157162
}
@@ -190,10 +195,6 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
190195
glog.V(4).Infof("successfully populated volume %s", vol.VolID)
191196
}
192197

193-
topologies := []*csi.Topology{&csi.Topology{
194-
Segments: map[string]string{TopologyKeyNode: cs.nodeID},
195-
}}
196-
197198
return &csi.CreateVolumeResponse{
198199
Volume: &csi.Volume{
199200
VolumeId: volumeID,

0 commit comments

Comments
 (0)