Skip to content

Commit

Permalink
Add volume id got from mount request to path
Browse files Browse the repository at this point in the history
Signed-off-by: Vignesh Laxman <[email protected]>
  • Loading branch information
vlaxman-px committed Oct 17, 2023
1 parent fdbdcd2 commit 8253002
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions api/server/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ func (d *driver) status(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, fmt.Sprintln("osd plugin", d.version))
}

func (d *driver) mountpath(name string) string {
return path.Join(volume.MountBase, name)
func (d *driver) mountpath(nameWithID string) string {
return path.Join(volume.MountBase, nameWithID)
}

func (d *driver) getConn() (*grpc.ClientConn, error) {
Expand Down Expand Up @@ -651,6 +651,8 @@ func (d *driver) mount(w http.ResponseWriter, r *http.Request) {

// get spec and name from request
_, spec, _, _, name := d.SpecFromString(request.Name)
_, _, _, _, volID := d.SpecFromString(request.ID)
nameWithID := name + volID
attachOptions := d.attachOptionsFromSpec(spec)

// attach token in context metadata
Expand Down Expand Up @@ -686,7 +688,7 @@ func (d *driver) mount(w http.ResponseWriter, r *http.Request) {

// If a scaled volume is already mounted, check if it can be unmounted and
// detached. If not return an error.
mountpoint := d.mountpath(name)
mountpoint := d.mountpath(nameWithID)
if vol.Spec.Scale > 1 {
id := v.MountedAt(ctx, mountpoint)
if len(id) != 0 {
Expand Down Expand Up @@ -857,14 +859,16 @@ func (d *driver) unmount(w http.ResponseWriter, r *http.Request) {
}

_, _, _, _, name := d.SpecFromString(request.Name)
_, _, _, _, volID := d.SpecFromString(request.ID)
nameWithID := name + volID
vol, err := d.volFromName(name)
if err != nil {
e := d.volNotFound(method, name, err, w)
d.errorResponse(method, w, e)
return
}

mountpoint := d.mountpath(name)
mountpoint := d.mountpath(nameWithID)
id := vol.Id
if vol.Spec.Scale > 1 {
id = v.MountedAt(ctx, mountpoint)
Expand Down

0 comments on commit 8253002

Please sign in to comment.