PATCH /1.0/images/aliases/{name} - context deadline exceeded
Not sure if this is a documentation or a code bug (or a user error :wink: ).
According to the documentation, PATCH /1.0/images/aliases/{name} can be used to partially update the image alias configuration. However, no matter whether I try to update the description or the target, I get "Error: context deadline exceeded".
I can use POST to update the name of the alias, or PUT to update the target (or target and description). So everything can be updated, but PATCH would make it easier to update the target while maintaining the description, or to update the description without having to repeat the target.
Could you give an example of the request you're making and the response you're getting please?
ubuntu@ru-fu01:~$ lxc query --request POST /1.0/images/aliases --data '{"name":"mytest", "target":"748cff26706d"}'
ubuntu@ru-fu01:~$ lxc query --request POST /1.0/images/aliases/mytest --data '{"name":"mytest2"}'
ubuntu@ru-fu01:~$ lxc query --request GET /1.0/images/aliases?recursion=1
[
{
"description": "",
"name": "mytest2",
"target": "748cff26706d7fc21599c1eefb599f031ddc4970d97fe0e10ed075f385a48bf0",
"type": "virtual-machine"
}
]
ubuntu@ru-fu01:~$ lxc query --request PATCH /1.0/images/aliases/mytest2 --data '{"target":"be25b31cb556"}'
Error: context deadline exceeded
ubuntu@ru-fu01:~$ lxc query --request PATCH /1.0/images/aliases/mytest2 --data '{"target":"be25b31cb556"}'
Error: context deadline exceeded
ubuntu@ru-fu01:~$ lxc query --request GET /1.0/images/aliases?recursion=1
[
{
"description": "",
"name": "mytest2",
"target": "748cff26706d7fc21599c1eefb599f031ddc4970d97fe0e10ed075f385a48bf0",
"type": "virtual-machine"
}
]
ubuntu@ru-fu01:~$ lxc query --request PATCH /1.0/images/aliases/mytest2 --data '{"description":"testing"}'
Error: context deadline exceeded
ubuntu@ru-fu01:~$ lxc query --request POST /1.0/images/aliases/mytest2 --data '{"name":"mytest3"}'
ubuntu@ru-fu01:~$ lxc query --request PATCH /1.0/images/aliases/mytest3 --data '{"description":"testing"}'
Error: context deadline exceeded
ubuntu@ru-fu01:~$ lxc query --request PUT /1.0/images/aliases/mytest3 --data '{"name":"mytest3", "target":"be25b31cb556"}'
ubuntu@ru-fu01:~$ lxc query --request GET /1.0/images/aliases?recursion=1
[
{
"description": "",
"name": "mytest3",
"target": "be25b31cb556f449007f60990a9878067d454511fc2051108cc5dd441b1e69c8",
"type": "container"
}
]
ubuntu@ru-fu01:~$ lxc query --request PUT /1.0/images/aliases/mytest3 --data '{"target":"748cff26706d7"}'
ubuntu@ru-fu01:~$ lxc query --request GET /1.0/images/aliases?recursion=1
[
{
"description": "",
"name": "mytest3",
"target": "748cff26706d7fc21599c1eefb599f031ddc4970d97fe0e10ed075f385a48bf0",
"type": "virtual-machine"
}
]
@ru-fu the scenario you provided (with container and vm images) works on my side. Could you attach the LXD server logs (lxc monitor --pretty) with the reproducer you provided? The problem could come from the database transaction. However, the related DB transaction code looks fine to me and is rather short. So my wild guess would be that you might encounter a locking issue with the DB transaction. It might also be related to a network latency or database load issue (but it seems unlikely, as PUT/POST are working)... Anyway, I'll need the logs to have a clearer view ;)
Yes, it seems to be some database issue:
DEBUG [2024-03-12T14:23:03Z] Dqlite: attempt 1: server 1: connected
WARNING[2024-03-12T14:23:03Z] Failed to rollback transaction after error (context deadline exceeded): sql: transaction has already been committed or rolled back
Here's the full lxc monitor output: https://pastebin.canonical.com/p/cBx2DY2wmJ/
For the following commands:
ubuntu@ru-fu01:~$ lxc query --request POST /1.0/images/aliases --data '{"name":"mytest", "target":"1241d0fe84b3"}'
ubuntu@ru-fu01:~$ lxc query --request POST /1.0/images/aliases/mytest --data '{"name":"mytest2"}'
ubuntu@ru-fu01:~$ lxc query --request GET /1.0/images/aliases?recursion=1
[
{
"description": "",
"name": "mytest2",
"target": "1241d0fe84b3f2bc047e0ab1c7e4344bded7f7f57b0010507cdad79bf4f0aa85",
"type": "virtual-machine"
},
{
"description": "",
"name": "yay",
"target": "273d37fe0c9dab2d71ebcdb6b22599b44db0151103a349d3d7c9ac9e3aeaf315",
"type": "container"
}
]
ubuntu@ru-fu01:~$ lxc query --request PATCH /1.0/images/aliases/mytest2 --data '{"target":"98f9a02ad850"}'
Error: context deadline exceeded
ubuntu@ru-fu01:~$ lxc query --request GET /1.0/images/aliases?recursion=1
[
{
"description": "",
"name": "mytest2",
"target": "1241d0fe84b3f2bc047e0ab1c7e4344bded7f7f57b0010507cdad79bf4f0aa85",
"type": "virtual-machine"
},
{
"description": "",
"name": "yay",
"target": "273d37fe0c9dab2d71ebcdb6b22599b44db0151103a349d3d7c9ac9e3aeaf315",
"type": "container"
}
]
ubuntu@ru-fu01:~$ lxc query --request PATCH /1.0/images/aliases/mytest2 --data '{"description":"testing"}'
Error: context deadline exceeded
ubuntu@ru-fu01:~$ lxc query --request POST /1.0/images/aliases/mytest2 --data '{"name":"mytest3"}'
ubuntu@ru-fu01:~$ lxc query --request PATCH /1.0/images/aliases/mytest3 --data '{"description":"testing"}'
Error: context deadline exceeded
@ru-fu Are you running LXD in a cluster configuration on is it in standalone mode? Also, is it causing issues if you upgrade your LXD deployment (maybe this that refreshing the DB will help) or just if you do systemctl restart snap.lxd.daemon ?
@gabrielmougard This is on my VM (so I can probably give you access if you want). It's not clustered. I'm getting the exact same on my local machine though (also not clustered).
Restarting the daemon doesn't change anything. And I'm on 5.20-f3dd836, so there isn't much to upgrade to?
@ru-fu if you dont mind getting all of the latest schema updates (preventing a downgrade) can you check on latest/edge (sudo snap refresh lxd ---channel=latest/edge) to check its still a valid issue. Thanks
That seems to fix it, the PATCH goes through now.
Can I close this issue?