owncloud / ocis

:atom_symbol: ownCloud Infinite Scale Stack
https://doc.owncloud.com/ocis/next/
Apache License 2.0
1.35k stars 174 forks source link

User assignments-list gets longer after every restart on default users #3432

Closed AlexAndBear closed 1 year ago

AlexAndBear commented 2 years ago

Describe the bug

User assignments-list gets longer after every restart on default users image

Steps to reproduce

Steps to reproduce the behavior:

  1. Start ocis
  2. POST https://localhost:9200/api/v0/settings/assignments-list with payload { "account_uuid": "058bff95-6708-4fe5-91e4-9ea3d377588b" }
  3. Observe the length of the assignments
  4. Kill ocis
  5. Start ocis
  6. POST https://localhost:9200/api/v0/settings/assignments-list with payload { "account_uuid": "058bff95-6708-4fe5-91e4-9ea3d377588b" }
  7. Observe that the assignment list have more items, than before

Expected behavior

The assignment list should not have more items after kill and start ocis for no reason

Actual behavior

User assignments-list gets longer after every restart on default users

Setup

Please describe how you started the server and provide a list of relevant environment variables.

```console OCIS_VERSION=vX.X.X BRANCH=vX.X.X STORAGE_FRONTEND_UPLOAD_DISABLE_TUS=false ```

Additional context

Add any other context about the problem here.

rhafer commented 2 years ago

Some notes: This only happens when using the "metadata" storage for settings (which is our default since a few weeks). When using "metadata" the default assignments are only created when processing the first (wrirte) request on the settings API.

wkloucek commented 1 year ago

could not reproduce on https://github.com/owncloud/ocis/commit/7f68049c043d87e2d6a342a513be920513e9d3ea (post 2.0.0rc.1)

rhafer commented 1 year ago

This but is definitely still present in current master:

ocis/bin/ocis init --insecure true --ap admin
PROXY_ENABLE_BASIC_AUTH=true ocis/bin/ocis server

now list assignments:

curl -XPOST "https://localhost:9200/api/v0/settings/assignments-list" -d'{"account_uuid": "me"}' -uadmin:admin -k | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   334  100   312  100    22   2310    162 --:--:-- --:--:-- --:--:--  2492
{
  "assignments": [
    {
      "id": "8129e0fc-8956-47cc-b997-157667bd316c",
      "accountUuid": "09a0500d-f175-4778-9f4d-c1ec1d69b5e5",
      "roleId": "71881883-1768-46bd-a24d-a356a2afdf7f"
    },
    {
      "id": "1a638431-a524-4e51-bbe5-ef53e5193a2c",
      "accountUuid": "09a0500d-f175-4778-9f4d-c1ec1d69b5e5",
      "roleId": "71881883-1768-46bd-a24d-a356a2afdf7f"
    }
  ]
}

Having the admin role assigment twice is already a bug. But when you restart restart ocis and list assignments again you get it listed 4 times.:

curl -XPOST "https://localhost:9200/api/v0/settings/assignments-list" -d'{"account_uuid": "me"}' -uadmin:admin -k | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   628  100   606  100    22   3376    122 --:--:-- --:--:-- --:--:--  3488
{
  "assignments": [
    {
      "id": "8129e0fc-8956-47cc-b997-157667bd316c",
      "accountUuid": "09a0500d-f175-4778-9f4d-c1ec1d69b5e5",
      "roleId": "71881883-1768-46bd-a24d-a356a2afdf7f"
    },
    {
      "id": "1a638431-a524-4e51-bbe5-ef53e5193a2c",
      "accountUuid": "09a0500d-f175-4778-9f4d-c1ec1d69b5e5",
      "roleId": "71881883-1768-46bd-a24d-a356a2afdf7f"
    },
    {
      "id": "67a28885-6f75-43f9-87f6-2fb528136f4e",
      "accountUuid": "09a0500d-f175-4778-9f4d-c1ec1d69b5e5",
      "roleId": "71881883-1768-46bd-a24d-a356a2afdf7f"
    },
    {
      "id": "17a99600-196d-4f68-b31c-f6ccf083440b",
      "accountUuid": "09a0500d-f175-4778-9f4d-c1ec1d69b5e5",
      "roleId": "71881883-1768-46bd-a24d-a356a2afdf7f"
    }
  ]
}

I think this only happens for admin and demo-users.