microsoft / microsoft/AzureTRE

Provide mechanism to clean up any failed deployments of resources

Open
#3,214 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

design feature story
Dominant language
Python
Stars
235
Forks
192
Avg merge
1d 23h
Merged PRs (30d)
13

Description

Describe the bug

make db-migrate can fail where cosmos contains resources that correspond to workspaces that have failed to deploy. api logs:

2023-02-10T10:09:39.761582740Z INFO:root:PR 1717 - Shared services
2023-02-10T10:09:39.824579237Z INFO:root:PR 1726 - Authentication needs to be in properties so we can update them
2023-02-10T10:09:39.832641465Z ERROR:root:Failed to migrate database
2023-02-10T10:09:39.832683565Z Traceback (most recent call last):
2023-02-10T10:09:39.832688665Z File "/api/./api/routes/migrations.py", line 51, in migrate_database
2023-02-10T10:09:39.832692265Z migration_status = "Executed" if await workspace_migration.moveAuthInformationToProperties() else "Skipped"
2023-02-10T10:09:39.832695665Z File "/api/./db/migrations/workspaces.py", line 31, in moveAuthInformationToProperties
2023-02-10T10:09:39.832698965Z item["properties"]["scope_id"] = f"api://{item['properties']['client_id']}"
2023-02-10T10:09:39.832702365Z KeyError: 'client_id'
2023-02-10T10:09:39.835888016Z {'paths': ['/id'], 'kind': 'Hash', 'version': 2}
2023-02-10T10:09:39.835919516Z {'paths': ['/id'], 'kind': 'Hash', 'version': 2}
2023-02-10T10:09:39.835924616Z {'paths': ['/resourceId'], 'kind': 'Hash', 'version': 2}
2023-02-10T10:09:39.835927617Z {'paths': ['/id'], 'kind': 'Hash', 'version': 2}
2023-02-10T10:09:39.835930517Z {'paths': ['/id'], 'kind': 'Hash', 'version': 2}
2023-02-10T10:09:39.835933417Z {'paths': ['/id'], 'kind': 'Hash', 'version': 2}
2023-02-10T10:09:39.835936417Z {'paths': ['/id'], 'kind': 'Hash', 'version': 2}
2023-02-10T10:09:39.835939317Z INFO: x.x.x.x:x - "POST /api/migrations HTTP/1.1" 400 Bad Request

Deleting the workspaces without a client_id field from cosmos fixes the issue

Steps to reproduce

  1. Deploy a workspace that does not succeed, due to an unrelated issue
  2. Run make db-migrate

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with api/routes/migrations.py and db/migrations/workspaces.py, then reproduce the failure with make db-migrate using Cosmos resources from a failed workspace. Done means failed workspace resources without a client_id are cleaned up or safely handled so the migration completes without the reported KeyError.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, python
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.