shellhub: Cannot upgrade to any release after 0.7.1

We tried to upgrade from 0.5.1 to 0.7.3 but got an error in the API logs - “Failed to apply mongo migrations” error=“(DuplicateKey) Index build failed: 1a0a7170-101b-4f5e-807f-4904ded96680: Collection main.users ( 2956abc2-99e7-4fda-b906-4d02ea0370b6 ) :: caused by :: E11000 duplicate key error collection: main.users index: tenant_id dup key: { tenant_id: null }”’

We then tried to upgrade to 0.7.2 and also to 0.7.1 and got the same error. Next we tried to upgrade to 0.7.0 and that works fine. If we try to upgrade from 0.7.0 to 0.7.1 we get the failed to apply mongo migrations error again.

See below after the upgrade to 0.7.3. The same error is in the API logs on upgrade to 0.7.2 and to 0.7.1.

Containers running

docker ps -a

CONTAINER ID   IMAGE                       COMMAND                  CREATED          STATUS                          PORTS                    NAMES
87feebc4683f   shellhubio/gateway:v0.7.3   "/entrypoint.sh /usr…"   9 minutes ago    Restarting (1) 29 seconds ago                            shellhub_gateway_1
9591feaacaaf   shellhubio/ui:v0.7.3        "/scripts/entrypoint…"   9 minutes ago    Up 2 minutes                    80/tcp                   shellhub_ui_1
40344f6f79d6   shellhubio/cli:v0.7.3       "/bin/sleep infinity"    9 minutes ago    Up 2 minutes                                             shellhub_cli_1
718d27cc0c67   mcuadros/ofelia:v0.3.4      "/usr/bin/ofelia dae…"   9 minutes ago    Up 2 minutes                                             shellhub_scheduler_1
46b295b520a1   shellhubio/api:v0.7.3       "/bin/sh -c '/api se…"   9 minutes ago    Restarting (1) 35 seconds ago                            shellhub_api_1
7b899c708709   shellhubio/ssh:v0.7.3       "/bin/sh -c /ssh"        9 minutes ago    Up 2 minutes                    0.0.0.0:2222->2222/tcp   shellhub_ssh_1
79f786231db1   mongo:4.4.4                 "docker-entrypoint.s…"   10 minutes ago   Up 2 minutes                    27017/tcp                shellhub_mongo_1
dad074c9b7c9   shellhubio/agent:v0.5.1     "/bin/agent"             5 months ago     Up 30 minutes                                            shellhub

API logs:

docker logs shellhub_api_1

time="2021-08-17T13:46:17Z" level=info msg="Starting API server"
time="2021-08-17T13:46:17Z" level=info msg="Connecting to MongoDB"
time="2021-08-17T13:46:17Z" level=info msg="Running database migrations"
time="2021-08-17T13:46:17Z" level=info msg="Creating lock for the resource migrations"
time="2021-08-17T13:46:17Z" level=info msg="Locking the resource migrations"
time="2021-08-17T13:46:17Z" level=info msg="Applying migration 13 - Up"
time="2021-08-17T13:46:17Z" level=info msg="Unlocking the resource migrations"
time="2021-08-17T13:46:17Z" level=fatal msg="Failed to apply mongo migrations" error="(DuplicateKey) Index build failed: 1a0a7170-101b-4f5e-807f-4904ded96680: Collection main.users ( 2956abc2-99e7-4fda-b906-4d02ea0370b6 ) :: caused by :: E11000 duplicate key error collection: main.users index: tenant_id dup key: { tenant_id: null }"

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (10 by maintainers)

Most upvoted comments

Can I also check if there is compatability between the older versions of the agent and newer versions of the server? e.g. if we upgrade the server to 0,7.3 but devices still have the 0.7.0 agent. Will it work until the agents get upgraded or will there be issues immedtiately after the server is upgraded?

@gercorri Yes, compatibility is guaranteed between versions, shouldn’t have problems updating the agent. I’m trying to reproduce the error you have received.