aws-samples / aws-samples/cloudformation-studio-domain

delete user domain will not work if there are active applications

Open
#2 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
14
Forks
17
PR merge metrics
No merged PRs in 30d

Description

There is a problem in UserProfile_function.py:

delete_user_profile function will not work (exception in sagemaker::DeleteUserProfile) if there are active application for a user profile, which is expected use case.

The correct deletion of user profile should include the deletion of application first, for example:

```
def delete_apps(domain_id, user_profile_name):
print("Start deleting user applications..")

for p in sm_client.get_paginator('list_apps').paginate(DomainIdEquals=domain_id, UserProfileNameEquals=user_profile_name):
for a in p["Apps"]:
sm_client.delete_app(DomainId=a["DomainId"], UserProfileName=a["UserProfileName"], AppType=a["AppType"], AppName=a["AppName"])

apps = 1
while apps:
apps = 0
for p in sm_client.get_paginator('list_apps').paginate(DomainIdEquals=domain_id, UserProfileNameEquals=user_profile_name):
apps += len([a["AppName"] for a in p["Apps"] if a["Status"] != "Deleted"])

print(f"Number of active apps: {str(apps)}")
time.sleep(5)

print("All apps are shutdown")
```

Only after all applications are in the "Deleted" state you can delete the user profile.

Please refer to [Delete a SageMaker Studio Domain](https://docs.aws.amazon.com/sagemaker/latest/dg/gs-studio-delete-domain.html)

Contributor guide

Open the contributing guide

Research direction

Start in UserProfile_function.py at delete_user_profile and review how SageMaker user profiles and applications are currently removed. Ensure applications are deleted and remain in the Deleted state before the user profile deletion is attempted; completion is confirmed when profiles with active applications can be deleted successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.