Instance POST changing target and project/pool cannot be mixed
Please confirm
- [x] I have searched existing issues to check if an issue already exists for the bug I encountered.
Distribution
ubuntu
Distribution version
snap
Output of "snap list --all lxd core20 core22 core24 snapd"
lxd git-54945ae 33432 5.21/edge canonical✓ in-cohort
Output of "lxc info" or system info if it fails
-
Issue description
Instance migration can only change target exclusively.
When changing instance target together with pool or project, the target change is ignored. The code path in instancePost seems to exit early if project or pool is set in the payload and ignored the target.
This is the client logic in lxd-ui:
If target is set exclusively and pool and targetProject are undefined, it works.
Another observation is that on submitting the migration payload above without target, pool or project, the cluster member goes under heavy load.
Steps to reproduce
- Create an instance on a clustered backend
- Request migration of the instance with migration payload sent to the endpoint mentioned above. Set a target and a project.
- The instance is migrated to the new project, but the new target is ignored.
- Expected is both project and target to change.
Information to attach
- [ ] Any relevant kernel output (
dmesg) - [ ] Instance log (
lxc info NAME --show-log) - [ ] Instance configuration (
lxc config show NAME --expanded) - [ ] Main daemon log (at
/var/log/lxd/lxd.logor/var/snap/lxd/common/lxd/logs/lxd.log) - [ ] Output of the client with
--debug - [ ] Output of the daemon with
--debug(or uselxc monitorwhile reproducing the issue)
@kadinsayani please can you evaulate this one and see 8f a bug?
@kadinsayani please can you evaulate this one and see 8f a bug?
Sure I'll take a look!
There isn't an early exit, but rather a returned operation which runs instancePostMigration. When pool or project are set, the request is treated as an instance move or rename on the node the instance is running on. In the CLI, we disallow using the --storage and --target-project flags with the --target flag.
Relevant Incus PR which reworks server-side migration: https://github.com/lxc/incus/pull/727. This PR makes it possible to change name, pool, project and/or location in one step. @tomponline I've triaged this Incus PR and I don't see any issues with us cherry-picking it. Can I go ahead with it?
@kadinsayani thanks sounds good
I'll take a look at https://github.com/lxc/incus/pull/567 and https://github.com/lxc/incus/pull/696 as well.