canonical / lxd

Powerful system container and virtual machine manager
https://canonical.com/lxd
GNU Affero General Public License v3.0
4.26k stars 909 forks source link

`PATCH /1.0/projects/<project>` removes existing configuration #13632

Open ru-fu opened 1 week ago

ru-fu commented 1 week ago

When you try to update a specific configuration option for a project using PATCH, existing configuration options are discarded:

ubuntu@ru-fu01:~$ lxc project show my-project1
name: my-project1
description: ""
config:
  features.images: "false"
  features.profiles: "false"
  features.storage.buckets: "true"
  features.storage.volumes: "true"
used_by: []
ubuntu@ru-fu01:~$ lxc query --request PATCH /1.0/projects/my-project1 --data '{
  "config": {
    "limits.containers": "5"
  }
}'
Error: Delete project default profile: Profile not found
ubuntu@ru-fu01:~$ lxc query --request PATCH /1.0/projects/my-project1 --data '{
  "config": {
    "limits.containers": "5",
    "features.profiles": "false"
  }
}'
ubuntu@ru-fu01:~$ lxc project show my-project1
name: my-project1
description: ""
config:
  features.profiles: "false"
  limits.containers: "5"
used_by: []

This could be regarded as intended behaviour (since you're updating the "config" field - which could mean the FULL "config" field). But this is inconsistent with how PATCH works for, for example, profiles:

ubuntu@ru-fu01:~$ lxc profile show testprofile
name: testprofile
description: ""
config:
  limits.cpu: "4"
  limits.memory: 1GiB
devices:
  root:
    path: /
    pool: default
    size: 1GiB
    type: disk
used_by: []
ubuntu@ru-fu01:~$ lxc query --request PATCH /1.0/profiles/testprofile --data '{
  "config": {
    "user.test": "hello"
  }                                 
}'
ubuntu@ru-fu01:~$ lxc profile show testprofile
name: testprofile
description: ""
config:
  limits.cpu: "4"
  limits.memory: 1GiB
  user.test: hello
devices:
  root:
    path: /
    pool: default
    size: 1GiB
    type: disk
used_by: []
tomponline commented 1 week ago

Sounds like a bug to me.