Skip to content

Inconsistent behaviour in handling projectid param for different list APIs #11517

Description

@shwstppr

problem

Many list APIs support the projectid parameter to filter resources for a specific project. However, when projectid = -1 is passed with listall=true, the behavior is inconsistent: some APIs return all resources accessible to the caller (typically for admins), while others only return resources explicitly associated with a project. This inconsistency creates confusion, and we should explore options to normalize the behavior across APIs.

Related:

versions

4.21-Snapshot, earlier

Different API behaviour for listVirtualMachines and listNetworks

(localcloud) 🐱 > list networks listall=true filter=id,name,project
{
  "count": 1,
  "network": [
    {
      "id": "8d7f5b0f-f215-48ee-92f5-8cbd1d0259d9",
      "name": "demonet"
    }
  ]
}
(localcloud) 🐱 > list virtualmachines projectid=-1 listall=true filter=id,name,project
{
  "count": 3,
  "virtualmachine": [
    {
      "id": "e34775ec-720b-42b4-a7ee-726e399e429d",
      "name": "kvm-vm"
    },
    {
      "id": "76108354-30fe-4ced-a18d-0db35afca135",
      "name": "proxmox-vm"
    },
    {
      "id": "0a652b81-c2b2-45b4-a747-0de511fcdcc7",
      "name": "project-vm",
      "project": "demo"
    }
  ]
}
(localcloud) 🐱 > list virtualmachines listall=true filter=id,name,project
{
  "count": 2,
  "virtualmachine": [
    {
      "id": "e34775ec-720b-42b4-a7ee-726e399e429d",
      "name": "kvm-vm"
    },
    {
      "id": "76108354-30fe-4ced-a18d-0db35afca135",
      "name": "proxmox-vm"
    }
  ]
}
(localcloud) 🐱 > list networks projectid=-1 listall=true filter=id,name,project
{
  "count": 1,
  "network": [
    {
      "id": "2640fda5-2b5a-4f7f-8750-b2b898ea9e9a",
      "name": "project-l2",
      "project": "demo"
    }
  ]
}
(localcloud) 🐱 > list networks listall=true filter=id,name,project
{
  "count": 1,
  "network": [
    {
      "id": "8d7f5b0f-f215-48ee-92f5-8cbd1d0259d9",
      "name": "demonet"
    }
  ]
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions