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

fix(generate_migration_data): doesn't keep instance type #567

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MrDaGree
Copy link
Contributor

@MrDaGree MrDaGree commented Nov 8, 2023

While working on a project of mine I ran across a few issues when attempting to migrate a virtual-machine to another lxd host. Both hosts are running Ubuntu 22.04 and have been tested with 5.15/stable and 5.19/stable.

  1. The first issue was due to the volatile.vsock_id in the config. As this is volatile and unique I decided to just drop the key from the config entirely.
  2. The second issue was due to the lack of generating the "type" for the migration data. Since it isn't setting the type to its current type it was attempting to migrate my virtual-machine typed instance as a container, thus when trying to start it back up it would not work as it had completely missed the actual .block zfs dataset with all the data. This was also when I realized the profiles it had set weren't being migrated correctly as well.

Error attempting to move due to Unknown configuration key: volatile.vsock_id

File "/home/dgreeley/.../lxd.py", line 10, in move
moved_instance = self._lxd.migrate(dest._client, live=live, wait=True)
File "/home/dgreeley/.cache/pypoetry/virtualenvs/my-amazing-project-9Pci4AF4-py3.10/lib/python3.10/site-packages/pylxd/models/instance.py", line 618, in migrate
res = getattr(new_client, self._endpoint).create(
File "/home/dgreeley/.cache/pypoetry/virtualenvs/my-amazing-project-9Pci4AF4-py3.10/lib/python3.10/site-packages/pylxd/models/instance.py", line 340, in create
response = client.api[cls._endpoint].post(json=config, target=target)
File "/home/dgreeley/.cache/pypoetry/virtualenvs/my-amazing-project-9Pci4AF4-py3.10/lib/python3.10/site-packages/pylxd/client.py", line 230, in post
self._assert_response(response, allowed_status_codes=(200, 201, 202))
File "/home/dgreeley/.cache/pypoetry/virtualenvs/my-amazing-project-9Pci4AF4-py3.10/lib/python3.10/site-packages/pylxd/client.py", line 159, in _assert_response
raise exceptions.LXDAPIException(response)
pylxd.exceptions.LXDAPIException: Failed creating instance record: Unknown configuration key: volatile.vsock_id

generate_migration_data function does not keep the profiles or type correctly

File "/home/dgreeley/.../lxd.py", line 11, in move
moved_instance.start(wait=True)
File "/home/dgreeley/.cache/pypoetry/virtualenvs/my-amazing-project-9Pci4AF4-py3.10/lib/python3.10/site-packages/pylxd/models/instance.py", line 380, in start
return self._set_state("start", timeout=timeout, force=force, wait=wait)
File "/home/dgreeley/.cache/pypoetry/virtualenvs/my-amazing-project-9Pci4AF4-py3.10/lib/python3.10/site-packages/pylxd/models/instance.py", line 365, in _set_state
self.client.operations.wait_for_operation(response.json()["operation"])
File "/home/dgreeley/.cache/pypoetry/virtualenvs/my-amazing-project-9Pci4AF4-py3.10/lib/python3.10/site-packages/pylxd/models/operation.py", line 57, in wait_for_operation
operation.wait()
File "/home/dgreeley/.cache/pypoetry/virtualenvs/my-amazing-project-9Pci4AF4-py3.10/lib/python3.10/site-packages/pylxd/models/operation.py", line 94, in wait
response = self._client.api.operations[self.id].wait.get()
File "/home/dgreeley/.cache/pypoetry/virtualenvs/my-amazing-project-9Pci4AF4-py3.10/lib/python3.10/site-packages/pylxd/client.py", line 207, in get
self._assert_response(
File "/home/dgreeley/.cache/pypoetry/virtualenvs/my-amazing-project-9Pci4AF4-py3.10/lib/python3.10/site-packages/pylxd/client.py", line 159, in _assert_response
raise exceptions.LXDAPIException(response)
pylxd.exceptions.LXDAPIException: Failed to handle idmapped storage: No such file or directory: "/var/snap/lxd/common/lxd/storage-pools/default/containers/dgreeley-migrate-test/rootfs"

@simondeziel
Copy link
Member

While working on a project of mine I ran across a few issues when attempting to migrate a virtual-machine to another lxd host. Both hosts are running Ubuntu 22.04 and have been tested with 5.15/stable and 5.19/stable.

It'd be great if you could provide reproducing code, thanks!

1. The first issue was due to the `volatile.vsock_id` in the config. As this is volatile and unique I decided to just drop the key from the config entirely.

Could it be because it was trying to migrate to a container?

Could you please split up the commits into smaller pieces and take a look at the tests failures. Thanks!

@MrDaGree
Copy link
Contributor Author

It'd be great if you could provide reproducing code, thanks!

The example right on the docs for migration would produce the same issue as long as the original instance is a virtual-machine type. https://pylxd.readthedocs.io/en/latest/instances.html

Could it be because it was trying to migrate to a container?

I don't believe so as I tested if this was also needed after fixing the type issue. I believe its an issue with the ConfigKeyChecker in LXD itself.

Could you please split up the commits into smaller pieces and take a look at the tests failures. Thanks!

Commits, sure. Tests, I'm not exactly sure why its failing with TypeError: Object of type object is not JSON serializable after my changes.

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.

2 participants