Skip to content

Commit

Permalink
Merge pull request #383 from akutz/bugfix/attachment-filtering-31
Browse files Browse the repository at this point in the history
WiP - Fix for Attachment Filtering on Unavailable Vols
  • Loading branch information
akutz authored Jan 4, 2017
2 parents ec7b258 + ede1721 commit 15d0c6a
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 15d0c6a

Please sign in to comment.