Skip to content

Commit

Permalink
Merge pull request #3022 from stephenfin/scheduler-hints-rework
Browse files Browse the repository at this point in the history
compute, block storage: Rework scheduler hints
  • Loading branch information
EmilienM committed May 20, 2024
2 parents 59af460 + d520ff8 commit 64c7682
Show file tree
Hide file tree
Showing 18 changed files with 193 additions and 276 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func CreateVolume(t *testing.T, client *gophercloud.ServiceClient) (*volumes.Vol
Name: volumeName,
}

volume, err := volumes.Create(context.TODO(), client, createOpts).Extract()
volume, err := volumes.Create(context.TODO(), client, createOpts, nil).Extract()
if err != nil {
return volume, err
}
Expand Down Expand Up @@ -67,7 +67,7 @@ func CreateVolumeFromImage(t *testing.T, client *gophercloud.ServiceClient) (*vo
ImageID: choices.ImageID,
}

volume, err := volumes.Create(context.TODO(), client, createOpts).Extract()
volume, err := volumes.Create(context.TODO(), client, createOpts, nil).Extract()
if err != nil {
return volume, err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/acceptance/openstack/blockstorage/v2/blockstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func CreateVolume(t *testing.T, client *gophercloud.ServiceClient) (*volumes.Vol
Description: volumeDescription,
}

volume, err := volumes.Create(context.TODO(), client, createOpts).Extract()
volume, err := volumes.Create(context.TODO(), client, createOpts, nil).Extract()
if err != nil {
return volume, err
}
Expand Down Expand Up @@ -106,7 +106,7 @@ func CreateVolumeFromImage(t *testing.T, client *gophercloud.ServiceClient) (*vo
ImageID: choices.ImageID,
}

volume, err := volumes.Create(context.TODO(), client, createOpts).Extract()
volume, err := volumes.Create(context.TODO(), client, createOpts, nil).Extract()
if err != nil {
return volume, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestSchedulerHints(t *testing.T) {
Name: volumeName,
}

volume1, err := volumes.Create(context.TODO(), client, createOpts).Extract()
volume1, err := volumes.Create(context.TODO(), client, createOpts, nil).Extract()
th.AssertNoErr(t, err)

ctx, cancel := context.WithTimeout(context.TODO(), 60*time.Second)
Expand All @@ -37,18 +37,17 @@ func TestSchedulerHints(t *testing.T) {
defer volumes.Delete(context.TODO(), client, volume1.ID, volumes.DeleteOpts{})

volumeName = tools.RandomString("ACPTTEST", 16)
schedulerHints := volumes.SchedulerHints{
createOpts = volumes.CreateOpts{
Size: 1,
Name: volumeName,
}
schedulerHintOpts := volumes.SchedulerHintOpts{
SameHost: []string{
volume1.ID,
},
}
createOpts = volumes.CreateOpts{
Size: 1,
Name: volumeName,
SchedulerHints: schedulerHints,
}

volume2, err := volumes.Create(context.TODO(), client, createOpts).Extract()
volume2, err := volumes.Create(context.TODO(), client, createOpts, schedulerHintOpts).Extract()
th.AssertNoErr(t, err)

ctx2, cancel := context.WithTimeout(context.TODO(), 60*time.Second)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func TestVolumeConns(t *testing.T) {
cv, err := volumes.Create(client, &volumes.CreateOpts{
Size: 1,
Name: "blockv2-volume",
}).Extract()
}, nil).Extract()
th.AssertNoErr(t, err)
defer func() {
Expand Down
4 changes: 2 additions & 2 deletions internal/acceptance/openstack/blockstorage/v3/blockstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func CreateVolume(t *testing.T, client *gophercloud.ServiceClient) (*volumes.Vol
Description: volumeDescription,
}

volume, err := volumes.Create(context.TODO(), client, createOpts).Extract()
volume, err := volumes.Create(context.TODO(), client, createOpts, nil).Extract()
if err != nil {
return volume, err
}
Expand Down Expand Up @@ -119,7 +119,7 @@ func CreateVolumeWithType(t *testing.T, client *gophercloud.ServiceClient, vt *v
VolumeType: vt.Name,
}

volume, err := volumes.Create(context.TODO(), client, createOpts).Extract()
volume, err := volumes.Create(context.TODO(), client, createOpts, nil).Extract()
if err != nil {
return volume, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestSchedulerHints(t *testing.T) {
Name: volumeName,
}

volume1, err := volumes.Create(context.TODO(), client, createOpts).Extract()
volume1, err := volumes.Create(context.TODO(), client, createOpts, nil).Extract()
th.AssertNoErr(t, err)

ctx, cancel := context.WithTimeout(context.TODO(), 60*time.Second)
Expand All @@ -36,18 +36,17 @@ func TestSchedulerHints(t *testing.T) {
defer volumes.Delete(context.TODO(), client, volume1.ID, volumes.DeleteOpts{})

volumeName = tools.RandomString("ACPTTEST", 16)
schedulerHints := volumes.SchedulerHints{
createOpts = volumes.CreateOpts{
Size: 1,
Name: volumeName,
}
schedulerHintOpts := volumes.SchedulerHintOpts{
SameHost: []string{
volume1.ID,
},
}
createOpts = volumes.CreateOpts{
Size: 1,
Name: volumeName,
SchedulerHints: schedulerHints,
}

volume2, err := volumes.Create(context.TODO(), client, createOpts).Extract()
volume2, err := volumes.Create(context.TODO(), client, createOpts, schedulerHintOpts).Extract()
th.AssertNoErr(t, err)

ctx2, cancel2 := context.WithTimeout(context.TODO(), 60*time.Second)
Expand Down
4 changes: 2 additions & 2 deletions internal/acceptance/openstack/blockstorage/v3/volumes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestVolumesMultiAttach(t *testing.T) {
VolumeType: vt.ID,
}

vol, err := volumes.Create(context.TODO(), client, volOpts).Extract()
vol, err := volumes.Create(context.TODO(), client, volOpts, nil).Extract()
th.AssertNoErr(t, err)
defer DeleteVolume(t, client, vol)

Expand Down Expand Up @@ -332,7 +332,7 @@ func TestVolumeConns(t *testing.T) {
cv, err := volumes.Create(context.TODO(), client, &volumes.CreateOpts{
Size: 1,
Name: "blockv2-volume",
}).Extract()
}, nil).Extract()
th.AssertNoErr(t, err)
defer func() {
Expand Down
24 changes: 12 additions & 12 deletions internal/acceptance/openstack/compute/v2/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func CreateBootableVolumeServer(t *testing.T, client *gophercloud.ServiceClient,
createOpts.ImageRef = blockDevices[0].UUID
}

server, err = servers.Create(context.TODO(), client, createOpts).Extract()
server, err = servers.Create(context.TODO(), client, createOpts, nil).Extract()

if err != nil {
return server, err
Expand Down Expand Up @@ -249,7 +249,7 @@ func CreateMultiEphemeralServer(t *testing.T, client *gophercloud.ServiceClient,
BlockDevice: blockDevices,
}

server, err = servers.Create(context.TODO(), client, createOpts).Extract()
server, err = servers.Create(context.TODO(), client, createOpts, nil).Extract()

if err != nil {
return server, err
Expand Down Expand Up @@ -389,7 +389,7 @@ func CreateServer(t *testing.T, client *gophercloud.ServiceClient) (*servers.Ser
Contents: []byte("hello world"),
},
},
}).Extract()
}, nil).Extract()
if err != nil {
return server, err
}
Expand Down Expand Up @@ -443,7 +443,7 @@ func CreateMicroversionServer(t *testing.T, client *gophercloud.ServiceClient) (
Metadata: map[string]string{
"abc": "def",
},
}).Extract()
}, nil).Extract()
if err != nil {
return server, err
}
Expand Down Expand Up @@ -497,7 +497,7 @@ func CreateServerWithoutImageRef(t *testing.T, client *gophercloud.ServiceClient
Contents: []byte("hello world"),
},
},
}).Extract()
}, nil).Extract()
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -544,7 +544,7 @@ func CreateServerWithTags(t *testing.T, client *gophercloud.ServiceClient, netwo
},
},
Tags: []string{"tag1", "tag2"},
}).Extract()
}, nil).Extract()
if err != nil {
return server, err
}
Expand Down Expand Up @@ -643,12 +643,12 @@ func CreateServerInServerGroup(t *testing.T, client *gophercloud.ServiceClient,
Networks: []servers.Network{
{UUID: networkID},
},
SchedulerHints: servers.SchedulerHints{
Group: serverGroup.ID,
},
}
schedulerHintOpts := servers.SchedulerHintOpts{
Group: serverGroup.ID,
}

server, err := servers.Create(context.TODO(), client, serverCreateOpts).Extract()
server, err := servers.Create(context.TODO(), client, serverCreateOpts, schedulerHintOpts).Extract()
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -697,7 +697,7 @@ func CreateServerWithPublicKey(t *testing.T, client *gophercloud.ServiceClient,
server, err := servers.Create(context.TODO(), client, keypairs.CreateOptsExt{
CreateOptsBuilder: serverCreateOpts,
KeyName: keyPairName,
}).Extract()
}, nil).Extract()
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1056,7 +1056,7 @@ func CreateServerNoNetwork(t *testing.T, client *gophercloud.ServiceClient) (*se
Contents: []byte("hello world"),
},
},
}).Extract()
}, nil).Extract()
if err != nil {
return server, err
}
Expand Down
10 changes: 4 additions & 6 deletions openstack/blockstorage/v2/volumes/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ a time.
Example of creating Volume B on a Different Host than Volume A
schedulerHints := volumes.SchedulerHints{
schedulerHintOpts := volumes.SchedulerHintCreateOpts{
DifferentHost: []string{
"volume-a-uuid",
}
Expand All @@ -15,17 +15,16 @@ Example of creating Volume B on a Different Host than Volume A
createOpts := volumes.CreateOpts{
Name: "volume_b",
Size: 10,
SchedulerHints: schedulerHints,
}
volume, err := volumes.Create(context.TODO(), computeClient, createOpts).Extract()
volume, err := volumes.Create(context.TODO(), computeClient, createOpts, schedulerHintOpts).Extract()
if err != nil {
panic(err)
}
Example of creating Volume B on the Same Host as Volume A
schedulerHints := volumes.SchedulerHints{
schedulerHintOpts := volumes.SchedulerHintCreateOpts{
SameHost: []string{
"volume-a-uuid",
}
Expand All @@ -34,10 +33,9 @@ Example of creating Volume B on the Same Host as Volume A
createOpts := volumes.CreateOpts{
Name: "volume_b",
Size: 10
SchedulerHints: schedulerHints,
}
volume, err := volumes.Create(context.TODO(), computeClient, createOpts).Extract()
volume, err := volumes.Create(context.TODO(), computeClient, createOpts, schedulerHintOpts).Extract()
if err != nil {
panic(err)
}
Expand Down
Loading

0 comments on commit 64c7682

Please sign in to comment.