Skip to content

feat: Implement address space cleanup on workspace service uninstall - #5076

Draft
James Chapman (JC-wk) wants to merge 6 commits into
microsoft:mainfrom
JC-wk:4727-deallocate-service-address-spaces
Draft

feat: Implement address space cleanup on workspace service uninstall#5076
James Chapman (JC-wk) wants to merge 6 commits into
microsoft:mainfrom
JC-wk:4727-deallocate-service-address-spaces

Conversation

@JC-wk

Copy link
Copy Markdown
Collaborator

Resolves #4727

What is being addressed

Workspace services don't release the address spaces they use when they are deallocated

How is this addressed

  • Bump version to 0.26.10.
  • Add method to retrieve allocated service address spaces in WorkspaceRepository.
  • Update address space validation to include allocated service address spaces.
  • Enhance patch_workspace method to handle address space cleanup.
  • Introduce cleanup_workspace_service_address_space method in DeploymentStatusUpdater to manage address space removal during service uninstallation.
  • Add tests for address space allocation and cleanup logic, ensuring correct behavior during service uninstall scenarios.
  • Document the address space cleanup plan and rationale for changes.

@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown

Unit Test Results

779 tests   779 ✅  11s ⏱️
  1 suites    0 💤
  1 files      0 ❌

Results for commit 806d6ae.

♻️ This comment has been updated with latest results.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Cleanup persistence and upgrade dispatch are not atomic or serialized, allowing lost or stale updates that leave Cosmos and Azure inconsistent.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Releases workspace-service address spaces after uninstall and prevents active allocations from being reused.

Changes:

  • Removes the service CIDR and dispatches a workspace upgrade.
  • Includes active service CIDRs during allocation validation.
  • Adds cleanup/allocation tests, documentation, changelog, and version updates.
File summaries
File Description
CHANGELOG.md Records the bug fix.
azuretre-address-space-cleanup-plan.md Documents designs, risks, and recommendations.
api_app/tests_ma/test_service_bus/test_deployment_status_update.py Tests cleanup and upgrade dispatch.
api_app/tests_ma/test_db/test_repositories/test_workpaces_repository.py Tests service CIDR allocation checks.
api_app/service_bus/deployment_status_updater.py Performs post-uninstall cleanup.
api_app/db/repositories/workspaces.py Includes active service CIDRs when allocating.
api_app/_version.py Bumps the API patch version.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread api_app/service_bus/deployment_status_updater.py Outdated
Comment thread api_app/service_bus/deployment_status_updater.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Cleanup currently reuses a stale Cosmos ETag, and lock enforcement can permit conflicting mutations or permanently block creation.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 12/12 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread api_app/api/routes/workspaces.py Outdated
Comment thread api_app/service_bus/deployment_status_updater.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Expired-lock handling breaks workspace PATCH requests, and the unrenewed lease permits overlapping long-running operations.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

api_app/_version.py:1

  • The PR description says this component should be bumped from 0.26.9 to 0.26.10, but this line publishes 0.27.0 instead. Align the version with the stated release plan (or update the PR description if the minor bump is intentional) so downstream release automation and consumers receive the intended version.
  • Files reviewed: 13/13 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread api_app/api/routes/workspaces.py Outdated
Comment thread api_app/service_bus/deployment_status_updater.py
…d keep lock active during in-progress cleanup

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Cleanup locking can dead-letter competing work, retain stale locks indefinitely, and overwrite concurrent workspace metadata.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 13/13 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment on lines +123 to +124
workspace.etag = fresh.etag
workspace.properties = fresh.properties
Comment on lines +220 to +221
except AddressSpaceCleanupBusyError:
return False
Comment on lines +315 to +318
operations_repo = getattr(self, "operations_repo", None)
if operations_repo:
return await operations_repo.is_address_space_cleanup_active(operation_id)
return lock.get("expires_when", 0) > time.time()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IP address spaces are not deallocated when a workspace service is uninstalled

2 participants