Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute v2: Add Live Migration Action #728

Merged
merged 6 commits into from Jan 21, 2018

Conversation

dstdfx
Copy link
Contributor

@dstdfx dstdfx commented Jan 17, 2018

For #520

The same for Openstack CLI:

  • openstack server migrate --live <hostname> <server-name-or-id>

Links to the line numbers/files in the OpenStack source code that support the
code in this PR:

API doc:

Source code:

@coveralls
Copy link

coveralls commented Jan 17, 2018

Coverage Status

Changes Unknown when pulling fd197c6 on dstdfx:server-live-migration into ** on gophercloud:master**.

@theopenlab-ci
Copy link

theopenlab-ci bot commented Jan 17, 2018

@coveralls
Copy link

coveralls commented Jan 19, 2018

Coverage Status

Coverage decreased (-0.0003%) to 73.134% when pulling 36c6c90 on dstdfx:server-live-migration into 8ca2d18 on gophercloud:master.

@coveralls
Copy link

coveralls commented Jan 19, 2018

Coverage Status

Coverage decreased (-0.0003%) to 73.134% when pulling b8706ed on dstdfx:server-live-migration into 8ca2d18 on gophercloud:master.

@coveralls
Copy link

coveralls commented Jan 19, 2018

Coverage Status

Coverage decreased (-0.0003%) to 73.134% when pulling 4f5656e on dstdfx:server-live-migration into 8ca2d18 on gophercloud:master.

@dstdfx
Copy link
Contributor Author

dstdfx commented Jan 19, 2018

@jtopjian This is ready for review, but I've got -0.0003% as a decreased coverage after some refactoring, is it possible to skip it ?

@jtopjian
Copy link
Contributor

@dstdfx I think we can let that slide 😉

Thank you for working on this. I'll have time to do a full review in the next day or so.

Copy link
Contributor

@jtopjian jtopjian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dstdfx Nice work. I have one nit and one questions.

Additionally, I won't be able to run the acceptance test for this since I don't have a multi-node test environment on-hand at the moment. I'll take your word that the acceptance test works 😄

But that brings up a good point: the OpenLab CI environment probably can't run this test, either, so we will want to use an environment variable to trigger when this can be run.

Can you add a field called LiveMigrate (bool) here.

Then set the value by checking if OS_LIVE_MIGRATE is set here. Don't error if it's not set.

Add the LiveMigrate field here, too.

Then in the acceptance test, check if choices.LiveMigrate is false. If so, do t.Skip().

You can obtain choices by doing this.

Let me know if you need help with this - I realize it is a unique request for this test.

note: The reason we don't do this for the other Migrate test is because Nova can migrate to the same host (if nova.conf is set accordingly).


// The host to which to migrate the server.
// If this parameter is None, the scheduler chooses a host.
Host *string `json:"host"`
Copy link
Contributor

@jtopjian jtopjian Jan 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this so you can specify "" as a valid host value? Is that different than if host was omitted from the request body?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtopjian It will be "valid", but I reckon that "host" has to be always in the request body according to this line.
Moreover there's no clear mention as for migrate-server-migrate-action

If you specify null or don’t specify this parameter, the scheduler chooses a host.

I might be wrong please correct me.


// LiveMigrateOpts specifies parameters of live migrate action.
type LiveMigrateOpts struct {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you remove this line?

@coveralls
Copy link

coveralls commented Jan 20, 2018

Coverage Status

Coverage decreased (-0.0003%) to 73.134% when pulling 1d12f0d on dstdfx:server-live-migration into 8ca2d18 on gophercloud:master.

Copy link
Contributor

@jtopjian jtopjian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dstdfx Looks good! Thank you for implementing this.

Two small changes.

With regard to the Host setting, are you able to test whether or not Host needs to be "" or if it can be omitted?

@@ -56,6 +60,7 @@ func AcceptanceTestChoicesFromEnv() (*AcceptanceTestChoices, error) {
shareNetworkID := os.Getenv("OS_SHARE_NETWORK_ID")
dbDatastoreType := os.Getenv("OS_DB_DATASTORE_TYPE")
dbDatastoreVersion := os.Getenv("OS_DB_DATASTORE_VERSION")
liveMigrate := os.Getenv("OS_LIVE_MIGRATE")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be easier to do this:

var liveMigrate bool
if v := os.Getenv("OS_LIVE_MIGRATE"); v != "" {
  liveMigrate = true
}

Copy link
Contributor Author

@dstdfx dstdfx Jan 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtopjian Unfortunately I can't test it on my environment

}

if !choices.LiveMigrate {
t.Skip()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about

t.Skip("Testing of live migration is disabled")

@coveralls
Copy link

coveralls commented Jan 20, 2018

Coverage Status

Coverage decreased (-0.0003%) to 73.134% when pulling 729daa9 on dstdfx:server-live-migration into 8ca2d18 on gophercloud:master.

@jtopjian
Copy link
Contributor

@dstdfx

Unfortunately I can't test it on my environment

Do you mean you can't test this PR at all?

@dstdfx
Copy link
Contributor Author

dstdfx commented Jan 20, 2018

@jtopjian Sorry for balls-up! Finally I've tested cases with omitted host in request body, empty string and nil, so the results from nova-api.log:

  • DEBUG nova.api.openstack.wsgi [req-e3ee5fc5-8bc2-4be1-b457-06742cdac9a7 b6ba9c75146a49829a7427a3e8cc3c10 192796e61c174f718d6147b129f3f2ff] Action: 'action', calling method: <bound method MigrateServerController._migrate_live of <nova.api.openstack.compute.migrate_server.MigrateServerController object at 0x7f0d409eadd0>>, body: {"os-migrateLive":{"block_migration":false,"disk_over_commit":false}} _process_stack /usr/lib/python2.7/dist-packages/nova/api/openstack/wsgi.py:633 2018-01-21 00:44:51,425.425 28797 DEBUG nova.api.openstack.wsgi [req-e3ee5fc5-8bc2-4be1-b457-06742cdac9a7 b6ba9c75146a49829a7427a3e8cc3c10 192796e61c174f718d6147b129f3f2ff] Returning 400 to user: Invalid input for field/attribute os-migrateLive. Value: {u'disk_over_commit': False, u'block_migration': False}. 'host' is a required property __call__ /usr/lib/python2.7/dist-packages/nova/api/openstack/wsgi.py:1044

  • DEBUG nova.api.openstack.wsgi [req-cb1e7a08-10c7-4e5b-8c3e-8bfc788be0ec b6ba9c75146a49829a7427a3e8cc3c10 192796e61c174f718d6147b129f3f2ff] Action: 'action', calling method: <bound method MigrateServerController._migrate_live of <nova.api.openstack.compute.migrate_server.MigrateServerController object at 0x7f0d409eadd0>>, body: {"os-migrateLive":{"block_migration":false,"disk_over_commit":false,"host":""}} _process_stack /usr/lib/python2.7/dist-packages/nova/api/openstack/wsgi.py:633 2018-01-20 23:56:27,170.170 28792 DEBUG nova.api.openstack.wsgi [req-cb1e7a08-10c7-4e5b-8c3e-8bfc788be0ec b6ba9c75146a49829a7427a3e8cc3c10 192796e61c174f718d6147b129f3f2ff] Returning 400 to user: Invalid input for field/attribute host. Value: . u'' is too short __call__ /usr/lib/python2.7/dist-packages/nova/api/openstack/wsgi.py:1044

  • DEBUG nova.api.openstack.wsgi [req-07bcd3e0-4e85-4ed2-9b1b-7766fe8841f5 b6ba9c75146a49829a7427a3e8cc3c10 192796e61c174f718d6147b129f3f2ff] Action: 'action', calling method: <bound method MigrateServerController._migrate_live of <nova.api.openstack.compute.migrate_server.MigrateServerController object at 0x7f0d409eadd0>>, body: {"os-migrateLive":{"block_migration":false,"disk_over_commit":false,"host":null}} _process_stack /usr/lib/python2.7/dist-packages/nova/api/openstack/wsgi.py:633 2018-01-21 00:15:54,153.153 28793 DEBUG nova.compute.api [req-07bcd3e0-4e85-4ed2-9b1b-7766fe8841f5 b6ba9c75146a49829a7427a3e8cc3c10 192796e61c174f718d6147b129f3f2ff] [instance: b4811f78-8fa0-4c90-a67f-b2cacf34cc49] Fetching instance by UUID get /usr/lib/python2.7/dist-packages/nova/compute/api.py:2224

@jtopjian
Copy link
Contributor

@dstdfx Thank you for getting that information :)

I realize this PR is more difficult to test, so if you weren't able to test, it's understandable. I would have picked it up at some point in the future. But since you can test it, that's great.

So it looks like Nova does not like when host is omitted and when host is "".

What about

Host string `json:"host"`

That should put "host": null in the request body.

@dstdfx
Copy link
Contributor Author

dstdfx commented Jan 20, 2018

@jtopjian Are you sure? As far as I know we will get empty string if we don't specify Host field. Just as pointer to string will give us nil -> unmarshalled null. https://play.golang.org/p/etRTk0Hf2cm

@jtopjian
Copy link
Contributor

I apologize. I misunderstood that *string wasn't working when in fact it is.

So we've confirmed that all options are correct, then, right?

@dstdfx
Copy link
Contributor Author

dstdfx commented Jan 20, 2018

@jtopjian Right

@jtopjian
Copy link
Contributor

In that case, this looks good to me. Thank you for your help and patience with this one -- it's really appreciated.

@jtopjian jtopjian merged commit a13ccee into gophercloud:master Jan 21, 2018
@dstdfx dstdfx deleted the server-live-migration branch January 21, 2018 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants