lxd icon indicating copy to clipboard operation
lxd copied to clipboard

Instance POST changing target and project/pool cannot be mixed

Open edlerd opened this issue 7 months ago • 6 comments

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:

Image

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

  1. Create an instance on a clustered backend
  2. Request migration of the instance with migration payload sent to the endpoint mentioned above. Set a target and a project.
  3. The instance is migrated to the new project, but the new target is ignored.
  4. 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.log or /var/snap/lxd/common/lxd/logs/lxd.log)
  • [ ] Output of the client with --debug
  • [ ] Output of the daemon with --debug (or use lxc monitor while reproducing the issue)

edlerd avatar May 06 '25 08:05 edlerd

@kadinsayani please can you evaulate this one and see 8f a bug?

tomponline avatar May 13 '25 05:05 tomponline

@kadinsayani please can you evaulate this one and see 8f a bug?

Sure I'll take a look!

kadinsayani avatar May 13 '25 05:05 kadinsayani

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.

kadinsayani avatar May 13 '25 13:05 kadinsayani

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 avatar May 14 '25 08:05 kadinsayani

@kadinsayani thanks sounds good

tomponline avatar May 14 '25 08:05 tomponline

I'll take a look at https://github.com/lxc/incus/pull/567 and https://github.com/lxc/incus/pull/696 as well.

kadinsayani avatar May 14 '25 21:05 kadinsayani