Container name is set to an empty string after move

lxd version: 5.5
lxc version: 5.5

root@lxdserver1:~# lxc ls -cntL
+-----------------+-----------------+------------+
|      NAME       |      TYPE       |  LOCATION  |
+-----------------+-----------------+------------+
| cont-by0TCYF0y2 | CONTAINER       | lxdserver2 |
+-----------------+-----------------+------------+
| cont-sJGo5BKmA7 | CONTAINER       | lxdserver3 |
+-----------------+-----------------+------------+
| vm-v1qlJKbeQ6   | VIRTUAL-MACHINE | lxdserver1 |
+-----------------+-----------------+------------+
|                 | CONTAINER       | lxdserver2 |
+-----------------+-----------------+------------+

As you can see, There is a container whose name is blank.
Because I called the restapi of move instance.

here is my cluster info:

+------------+----------------------------+-----------------+--------------+----------------+-------------+--------+-------------------+
|    NAME    |            URL             |      ROLES      | ARCHITECTURE | FAILURE DOMAIN | DESCRIPTION | STATE  |      MESSAGE      |
+------------+----------------------------+-----------------+--------------+----------------+-------------+--------+-------------------+
| lxdserver1 | https://172.31.30.129:8443 | database        | aarch64      | default        |             | ONLINE | Fully operational |
+------------+----------------------------+-----------------+--------------+----------------+-------------+--------+-------------------+
| lxdserver2 | https://172.31.30.130:8443 | database-leader | aarch64      | default        |             | ONLINE | Fully operational |
|            |                            | database        |              |                |             |        |                   |
+------------+----------------------------+-----------------+--------------+----------------+-------------+--------+-------------------+
| lxdserver3 | https://172.31.30.131:8443 | database        | aarch64      | default        |             | ONLINE | Fully operational |
+------------+----------------------------+-----------------+--------------+----------------+-------------+--------+-------------------+

here is my rest url :

https://172.31.30.129:8443/1.0/instances/cont-D74qF3riK2?target=lxdserver2

here is my rest request body:

{"migration": true}

My requirement is to move containers from lxdserver1 to lxdserver2 through the rest api.
My requestbody must be wrongly written.

1.Who can tell me how to delete container with blank name?
2.How can I correctly send a rest request to move the container from lxdserver1 to lxdserver2 ?

Hi @chenchen, I’m not so sure if it is the correct way, but you may change the blank container name like that.

lxd sql global "select * from instances;"
lxd sql global "update instances set name='new_name_of_the_container' where id=<blank_container_id>;"

After rename the container, you can use lxc delete command.
Regards.

1 Like

Thank you for your very helpful reply. This solved my first problem.
On my second question, Do you know to move instance to another cluster member by restful api?
I have read the official rest document, but I still don’t know how to pass the request body .

Hi @chenchen, here, you can investigate and change the values according to your request. I havent tested in the cluster environment but it works renaming instance name on the same host.
Regards.
Create a simple test.json like this.

{
  "allow_inconsistent": false,
  "container_only": false,
  "instance_only": false,
  "live": false,
  "migration": false,
  "name": "new name of the instance",
  "pool": "default",
  "project": "default",
  "target": {
    "certificate": "X509 PEM certificate",
    "operation": "https://<remote server>:8443/1.0/operations/5e8e1638-5345-4c2d-bac9-2c79c8577292",
    "secrets": {
      "criu": "random-string",
      "migration": "random-string"
    }
  }
}

And the curl step,

curl -s --unix-socket /var/snap/lxd/common/lxd/unix.socket -X POST -d @test.json a/1.0/containers/<name of the container to be moved> | jq .
1 Like

the following requestbody works.
it can successfully move from one cluster member to another.
If other people have the same problem as me, you can try this:

uri: https://172.31.30.129:8443/1.0/instances/cont-XogizYc7G5?target=lxdserver2
requestbody:
{
	"container_only": false,
	"instance_only": false,
	"migration": true,
	"name": "cont-XogizYc7G5"
}

Thanks for reporting this. I fixed the bug that allowed an instance to be moved to an empty name.

1 Like