Skip to content

Commit

Permalink
Fix for Attachment Filtering on Unavailable Vols
Browse files Browse the repository at this point in the history
This patch should fix the issue where volumes are not filtered with a
mask of 31 if they're unavailable.
  • Loading branch information
akutz committed Jan 4, 2017
1 parent ec7b258 commit ede1721
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
5 changes: 3 additions & 2 deletions api/server/router/volume/volume_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,9 @@ func handleVolAttachments(
// volume
if attachments.Mine() &&
attachments.Attached() &&
(s == types.VolumeAvailable || s == types.VolumeUnavailable) &&
!attachments.Unattached() {
((s == types.VolumeAvailable && !attachments.Unattached()) ||
s == types.VolumeUnavailable) {
//!attachments.Unattached() {
ctx.WithFields(lf).Debug("omitting unavailable volume")
return false
}
Expand Down
45 changes: 41 additions & 4 deletions drivers/storage/vfs/tests/vfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,46 @@ func TestVolumesWithAttachmentsAttachedAndMineWithNotMyInstanceID(
t.Fatal(err)
}

assert.Nil(t, reply["vfs"]["vfs-000"])
assert.Nil(t, reply["vfs"]["vfs-001"])
assert.Nil(t, reply["vfs"]["vfs-002"])
if !assert.Nil(t, reply["vfs"]["vfs-000"]) {
t.FailNow()
}
if !assert.Nil(t, reply["vfs"]["vfs-001"]) {
t.FailNow()
}
if !assert.Nil(t, reply["vfs"]["vfs-002"]) {
t.FailNow()
}
}
apitests.RunWithClientType(t, types.ControllerClient, vfs.Name, tc, tf)
}

func TestVolumesWithAttachmentsAttachedAndMineOrUnattachedWithNotMyInstanceID(
t *testing.T) {
t.SkipNow()
tc, _, _, _ := newTestConfigAll(t)
tf := func(config gofig.Config, client types.Client, t *testing.T) {

ctx := context.Background()
iidm := types.InstanceIDMap{
"vfs": &types.InstanceID{ID: "none", Driver: "vfs"},
}
ctx = ctx.WithValue(context.AllInstanceIDsKey, iidm)

reply, err := client.API().Volumes(ctx,
types.VolAttReqWithDevMapOnlyVolsAttachedToInstanceOrUnattachedVols)
if err != nil {
t.Fatal(err)
}

if !assert.Nil(t, reply["vfs"]["vfs-000"]) {
t.FailNow()
}
if !assert.Nil(t, reply["vfs"]["vfs-001"]) {
t.FailNow()
}
if !assert.Nil(t, reply["vfs"]["vfs-002"]) {
t.FailNow()
}
}
apitests.RunWithClientType(t, types.ControllerClient, vfs.Name, tc, tf)
}
Expand Down Expand Up @@ -973,7 +1010,7 @@ func newTestConfigAll(
if x < 2 {
vj = []byte(fmt.Sprintf(volJSON, x, hostName))
} else {
vj = []byte(fmt.Sprintf(volNoAttachJSON, x, hostName))
vj = []byte(fmt.Sprintf(volNoAttachJSON, x))
}
v := &types.Volume{}
if err := json.Unmarshal(vj, v); err != nil {
Expand Down

0 comments on commit ede1721

Please sign in to comment.