-
Notifications
You must be signed in to change notification settings - Fork 897
Issue Deleting Abandoned Workspaces #7872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Did you try coder delete? coder delete --orphan true -y WORKSPACE |
@MrPeacockNLB Sorry I didn't catch that in the docs earlier. I tried running this and got an unexpected output -
If I run without the workspace arg it prompts but doesn't tell me what it's going to delete -
Any suggestions on how to proceed? |
|
@ammario Thanks for following up and clarifying! I'm now running into a slightly different error . If I use just the workspace name, I get a "Resource not found or you do not have access to this resource -
I'm a full admin on the coder instance so I expect I would have access. When I try to give the fully qualified username/workspace I get a different error that seems similar to what's shown the UI -
I was able to delete another workspace from that user's new OIDC account using the same fully qualified username/password format. coder delete --orphan aldensomayire/terraform-upload
The terraform-upload workspace has been deleted at Jun 6 23:43:06! Any ideas why it doesn't work for the orphan case? |
Since this issues appears related to auth perhaps @Emyrk can assist. |
Looks like it 🤔 Looking into it |
Solution@atnomoverflow I think this solution will work for you.
ExplanationWhen you run To delete the correct workspace, you need to specify it with:
You must use the deleted user's ID and not their username. This is because when a user is deleted, we no longer guarantee their username to be unique. So it can conflict with an active or other deleted users. Below this line is just an explanation for any future readers or those who are curious. The abandoned workspace stateBeing able to delete a user who has workspaces should not be allowed. We have a check to prevent deleting a user if the user has workspaces: Lines 433 to 438 in f13632c
So there might be a bug or avenue that allowed this to happen. How to reproduceI can force this state in a unit test by bypassing the check. I get the same error when trying to delete the deleted user's workspace:
I am running from an admin authenticated cli
To make the test pass, you must do:
What is happeningWhat is happening is that this line in the cli that fetches the workspace: Line 34 in ac605ba
Hits this route: Line 216 in ac605ba
Which uses this middleware: coder/coderd/httpmw/userparam.go Line 38 in ac605ba
We currently do not allow this middleware to return deleted users by username. This is because a deleted user does not guarantee a unique username. So the username could refer to any number of deleted users, or conflict with an active user. |
@Emyrk Is there a way for me to find out what that value of "deleted_user_id" is? |
Great question. Right now the coder/coderd/database/queries/users.sql Line 139 in ba42c17
We might want to make that an option 🤔. I don't think there is a way to get the user_id except from maybe audit logs. @bpmct Is there any reason to prevent being able to query for deleted users? |
Should we add a new category to the user state? |
@matifali that does avoid adding a new knob |
@baxters-ctc I was working on implementing this, and might have found a solution for you to get the deleted user id. If this is still an issue, can you try this? coder ls --search 2nd-test -o json You can grep for the coder ls --search 2nd-test -o json | grep \"owner_id\"
# Use the output from above for the deleted user.
coder delete <deleted_user_id>/2nd-test -y --orphan |
After doing some work on this, I think we should leave the code how it is and not add any functionality regarding this issue. First: This edge case should not happen, so it should be rare. Second: It can be resolved, as mentioned above (#7872 (comment)) Third: Deleted user IDs can be found via database directly, audit logs, or through the resource itself (#7872 (comment)) The code solution to this would be to add the ability to list deleted users. However I think listing deleted users gets into privacy/security questions around who should be able to see all deleted users. Since there exists work arounds for this edge case, I am going to close this issue. If the problem still exists, or the mentioned workarounds do not work, anyone can feel free to reopen this PR with additional information. |
In the process of moving from local users to OIDC, I ended up deleting and recreating a user. There were still workspaces attached to the user and I can't find a way to delete them.
When I access the workspace from the main Workspaces section in the UI I get this message -
"user" must be an existing uuid or username.
None of the typical UI items are visible including the delete button.
I tried recreating the username as a local user and now when I try to load the workspace it just redirects me back to the main Workspaces tab.
Is there any way to force delete these workspaces without going through the UI?
The text was updated successfully, but these errors were encountered: