Skip to content
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

Unable to delete VCS client after deleting Workspace #1100

Closed
ValeriiVozniuk opened this issue Jul 22, 2024 · 2 comments · Fixed by #1502
Closed

Unable to delete VCS client after deleting Workspace #1100

ValeriiVozniuk opened this issue Jul 22, 2024 · 2 comments · Fixed by #1502
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@ValeriiVozniuk
Copy link

Bug description 🐞

When I'm trying to delete a VCS client which have deleted Workspace associated with it, I'm getting an error:

ERROR: update or delete on table "vcs" violates foreign key constraint "fk_workspace_vcs" on table "workspace"\n  Detail: Key (id)=(5c325b88-dbc2-412d-9fcc-b609eae1b033) is still referenced from table "workspace".

Per what I see in database, deleted Workspaces are staying in the workspace table just having _DEL_xxxx suffix added. I assume they both should be dropped at this point.

Steps to reproduce

  1. Create VCS client.
  2. Create associated Workspace.
  3. Delete that Workspace.
  4. Try to delete VCS client

Expected behavior

VCS client is deleted

Example repository

No response

Anything else?

I'm also don't see any mentions in documentation about that soft delete process in database, and how those deleted workspaces should be properly cleaned.

@ValeriiVozniuk ValeriiVozniuk added the bug Something isn't working label Jul 22, 2024
@alfespa17
Copy link
Member

That is correct we only do a "soft delete" updating one flag called "deleted = true", we don't delete the record from the database

What we are currently deleting is the "backend storage" where we put all the logs, state, json, terraform plan, etc in this part of the code:

public void deleteWorkspaceStorage(Workspace workspace){

storageTypeService.deleteWorkspaceOutputData(organizationId, jobList);

For now I think the alternative will be to add an additional update in the UI that calls the API and remove the relationship from the workspace that will be "soft deleted" in that way you could delete the VCS connection once all the relationships from the workspaces are removed.

It should be something similar to this code that we use to remove or add the relationship to a self hosted agent

@alfespa17 alfespa17 added good first issue Good for newcomers help wanted Extra attention is needed labels Jul 22, 2024
@WladyX
Copy link

WladyX commented Sep 29, 2024

I encountered the same issue, jut by trying to delete a VCS client, without deleting the workspace.
I added a gitlab VCS as admin app then added gitlab VCS as user app and now I am unable to remove the initial gitlab VCS admin app client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants