Skip to content

PATCH on a cluster group fails with HTTP 500 when the group has more than one member #3821

Description

@martijnbruins

Is there an existing issue for this?

  • There is no existing issue for this bug

Is this happening on an up to date version of Incus?

  • This is happening on a supported version of Incus

Incus system details

HypervisorOS 202607080301

Instance details

No response

Instance log

No response

Current behavior

PATCH /1.0/cluster/groups/{name} returns HTTP 500 for any group with two or more members:

{"error":"Query deleted 2 NodeClusterGroup rows instead of 1","error_code":500}

The handler clears the group's membership and rebuilds it, calling DeleteNodeClusterGroup (cmd/incusd/api_cluster_group.go:818). That mapper runs DELETE FROM nodes_cluster_groups WHERE group_id = ? (internal/server/db/cluster/nodes_cluster_groups.mapper.go:40-42), which deletes every member row, but it is generated as DeleteOne-by-GroupID and rejects any result other than one row (:280-284).

So the SQL is a delete-many while the guard is a delete-one. One member passes, two or more always fail. The transaction rolls back, so nothing is lost — but the group cannot be patched at all, and the default group on any cluster of three or more members is permanently unpatchable.

PUT on the same group works and is the workaround.

Expected behavior

PATCH succeeds regardless of member count. The generator annotation should be Delete-by-GroupID rather than DeleteOne-by-GroupID, so the row count is not asserted to be one.

Steps to reproduce

incus cluster group create g1
incus cluster group assign member1 default,g1
incus query -X PATCH -d '{"config":{"user.foo":"bar"}}' /1.0/cluster/groups/g1

succeeds with one member

incus cluster group assign member2 default,g1
incus query -X PATCH -d '{"config":{"user.foo":"baz"}}' /1.0/cluster/groups/g1

Error: Query deleted 2 NodeClusterGroup rows instead of 1

incus query -X PUT -d '{"description":"","members":["member1","member2"],"config":{"user.foo":"baz"}}' /1.0/cluster/groups/g1

succeeds

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions