Skip to content

Implements address space cleanup when a workspace service is uninstalled#4744

Open
JC-wk wants to merge 15 commits into
microsoft:mainfrom
JC-wk:deallocate-ip-addresses
Open

Implements address space cleanup when a workspace service is uninstalled#4744
JC-wk wants to merge 15 commits into
microsoft:mainfrom
JC-wk:deallocate-ip-addresses

Conversation

@JC-wk

@JC-wk JC-wk commented Nov 4, 2025

Copy link
Copy Markdown
Collaborator

Resolves #4727

PR

  • unit testing may be needed?
  • I have noted an edge case of the address being released during a failed uninstall and then allocated elsewhere. I need to move the deallocation process to run after the main step has succeeded so it runs after the terraform uninstall. I am testing doing this in the service_bus now and it is working ok.

What is being addressed

Currently address spaces are not cleaned up when a workspace service is uninstalled from a workspace, this could lead to ip range exhaustion.
This PR adds the functionality to delete the address_space used by a workspace-service on uninstall of the service. The address range is then freed from the workspace and can be reused.

How is this addressed

  • Adds a step to the api to delete the address space when a workspace service is uninstalled
  • Updates templates to conduct a workspace upgrade after uninstall
  • I have not added any tests but happy to accept advice on how to implement these
  • Updated documentation
  • Updated CHANGELOG.md
  • Increment template versions

@github-actions

github-actions Bot commented Nov 4, 2025

Copy link
Copy Markdown

Unit Test Results

678 tests   678 ✅  9s ⏱️
  1 suites    0 💤
  1 files      0 ❌

Results for commit 2924a12.

♻️ This comment has been updated with latest results.

@JC-wk JC-wk marked this pull request as ready for review November 10, 2025 09:50
@JC-wk JC-wk requested a review from a team as a code owner November 10, 2025 09:50
@JC-wk

JC-wk commented Nov 10, 2025

Copy link
Copy Markdown
Collaborator Author

I have been testing this for a few days, I am not sure if unit tests are needed and how best to write them if anyone wants to assist.

@JC-wk JC-wk marked this pull request as draft November 10, 2025 16:21
@JC-wk JC-wk marked this pull request as ready for review February 6, 2026 16:58

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.

Pull request overview

This PR addresses IP range exhaustion risk by ensuring workspace address spaces allocated by workspace services are freed on successful uninstall, and by triggering a workspace upgrade so downstream infra reflects the removal.

Changes:

  • Add post-uninstall cleanup in the service bus deployment status handler to remove a workspace-service address_space from the parent workspace’s address_spaces.
  • Update AzureML and Databricks workspace-service templates to run a workspace upgrade step after uninstall.
  • Bump API + template versions and add a changelog entry.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
templates/workspace_services/databricks/template_schema.json Adds a workspace upgrade step after uninstall (and JSON formatting changes).
templates/workspace_services/databricks/porter.yaml Patch version bump.
templates/workspace_services/azureml/template_schema.json Adds a workspace upgrade step after uninstall.
templates/workspace_services/azureml/porter.yaml Patch version bump.
api_app/service_bus/deployment_status_updater.py Implements address space cleanup after successful uninstall main step.
api_app/_version.py API patch version bump.
CHANGELOG.md Adds an Unreleased entry describing the change.

Comment thread CHANGELOG.md
Comment on lines +212 to +216
try:
await workspace_repo.patch_workspace(workspace, workspace_patch, workspace.etag, self.resource_template_repo, self.resource_history_repo, operation.user, False)
logger.info(f"Freed address space {address_to_free} from workspace {parent_workspace_id} after successful uninstall of {resource_id}")
except CosmosAccessConditionFailedError:
logger.exception("ETag conflict when freeing workspace address space after successful uninstall")

Copilot AI Feb 10, 2026

Copy link

Choose a reason for hiding this comment

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

If patching the workspace fails with an ETag conflict here, the code only logs and then continues. That can permanently leak the address space (no retry and the uninstall pipeline will keep running). Consider reusing the existing retry logic used elsewhere for Cosmos ETag mismatches (or implement a small bounded retry) so address space cleanup is resilient under concurrent workspace updates.

Copilot uses AI. Check for mistakes.
Comment thread api_app/service_bus/deployment_status_updater.py
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