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

migration: "instances" entry already exists #513

Open
nihr43 opened this issue Jun 21, 2022 · 1 comment
Open

migration: "instances" entry already exists #513

nihr43 opened this issue Jun 21, 2022 · 1 comment

Comments

@nihr43
Copy link

nihr43 commented Jun 21, 2022

Hi; unsure if this is expected behavior or something that slipped through the integration tests.

Im trying to migrate instances within a cluster, precisely akin to lxc mv "$instance" --target="$target_node". Im getting:

...
  File "/home/nhensel/.local/lib/python3.10/site-packages/pylxd/models/instance.py", line 601, in migrate
    res = getattr(new_client, self._endpoint).create(
  File "/home/nhensel/.local/lib/python3.10/site-packages/pylxd/models/instance.py", line 323, in create
    response = client.api[cls._endpoint].post(json=config, target=target)
  File "/home/nhensel/.local/lib/python3.10/site-packages/pylxd/client.py", line 216, in post
    self._assert_response(response, allowed_status_codes=(200, 201, 202))
  File "/home/nhensel/.local/lib/python3.10/site-packages/pylxd/client.py", line 145, in _assert_response
    raise exceptions.LXDAPIException(response)
pylxd.exceptions.LXDAPIException: Failed creating instance record: Add instance info to the database: This "instances" entry already exists

I'm reminded of how the lxc client creates a temporary instance like 'mv-uuid...' during a migration; this behavior must have already been worked around over there.

I see how this could have been missed; i don't see any sort of ad-hoc cluster construction ( like in lxd proper ) going on in the integration tests here. I see migration/run_migration_integration_tests-18-04 but it doesnt appear to be consumed by anything.

So my questions are.. Is this expected behavior? Am I the consumer expected to work around this in my own code?
Or, if this is not expected behavior, what input would you have on an integration test and fix for this? Im interested in taking a stab at it.. I figure migration/run_migration_integration_tests-18-04 needs taught to build a cluster of two, and migrate() needs taught to juggle instance names like lxc does.

Or perhaps im missing something? Any better ideas? Thanks.

@nihr43
Copy link
Author

nihr43 commented Jun 22, 2022

oh, looks like lxd itself does know how to handle intra-cluster migrations correctly, pylxd just needs to know how to do it:

heres what lxc does:
https://github.com/lxc/lxd/blob/master/lxc/move.go#L258

heres what lxd knows:
https://github.com/lxc/lxd/blob/master/lxd/instance_post.go#L102

meanwhile pylxd is just doing a naive create():
https://github.com/lxc/pylxd/blob/master/pylxd/models/instance.py#L592

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

No branches or pull requests

1 participant