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

Gitlab introduced soft delete of projects and groups #782

Closed
ringods opened this issue Feb 25, 2020 · 10 comments · Fixed by #823
Closed

Gitlab introduced soft delete of projects and groups #782

ringods opened this issue Feb 25, 2020 · 10 comments · Fixed by #823
Labels

Comments

@ringods
Copy link

ringods commented Feb 25, 2020

Filing this ticket not as a bug report, more as an awareness.

The test suites for the Gitlab Terraform & Pulumi providers became instable since Gitlab 12.6. After some investigation, it seems that soft-delete of Projects was introduced in that version by changing the behaviour of DELETE /projects/{id}.

More context here:
https://github.com/terraform-providers/terraform-provider-gitlab/issues/263
which links to even more gitlab tickets.

So be aware that a delete is not necessarily a hard delete.

@svanharmelen
Copy link
Member

If I read it correctly, there now is a pending_delete field in the returned project struct? If so, we probably need to add it so it can (maybe) be used to update the logic in the TF provider to be able to cope with this...

@ringods
Copy link
Author

ringods commented Mar 1, 2020

I asked for some help from Gitlab:

https://gitlab.com/gitlab-org/gitlab/issues/33257#note_296585615

@svanharmelen
Copy link
Member

Maybe good to have the discussion there, but not what kind of help you mean? Adding the pending_delete fields should be a tiny PR right? Not sure what else you are looking for?

@ringods
Copy link
Author

ringods commented Mar 1, 2020

@svanharmelen if it is clear to you what the response structure and fields are for a delete request of a project or group, then no additional help is needed. If not, then it is mainly my request to the Gitlab people to help us out to clarify how we can detect the pending delete status programmatically.

Nevertheless, are you able to implement the pending delete status to be interpreted as "the repo is deleted"?

@svanharmelen
Copy link
Member

@ringods can you confirm that the fields in PR #791 are filled correctly? If so, I can merge the request and it can be used in the TF provider...

@ringods
Copy link
Author

ringods commented Apr 1, 2020

@svanharmelen I finally came around integrating the soft-delete changes in Terraform. What I notice from debug logs is that the server never sets the pending_delete field in the response JSON of groups and repositories.

Here is a link to a testsuite run with DEBUG logs enabled:

https://github.com/terraform-providers/terraform-provider-gitlab/runs/552631042?check_suite_focus=true

Note: download the logs from the menu in the 3 dots in the upper right of the black logs screen for faster search. 😉

If you search for marked_for_deletion_at in the logs, you will see the response given back from the server. When a non-null value is set, there is no pending_delete field in the same response JSON. The marked_for_deletion_at is only added to the Project type, not to Group so I can't detect a soft delete on groups.

In https://github.com/terraform-providers/terraform-provider-gitlab/pull/291, I asked for help from 2 Gitlab employees. I hope we finally get some support on this one. My free time is not endless...

@svanharmelen
Copy link
Member

Same here... Let's see what they come back with.

@ringods
Copy link
Author

ringods commented Apr 2, 2020

@svanharmelen my findings so far can be read here: https://github.com/terraform-providers/terraform-provider-gitlab/pull/291#issuecomment-607665336

In short for you, here is a change request:

  • REMOVE: you can remove the PendingDelete attributes as the server never seems to return such field in the response of a GET request for a project or a group.
  • KEEP: on project, you correctly added the MarkedForDeletionAt property, mapping to the marked_for_deletion_at field from the JSON.
  • ADD: on group, a similar but not exactly the same field should be added: MarkedForDeletionOn mapping to marked_for_deletion_on

Note the difference in the last two characters of the field name.

@svanharmelen
Copy link
Member

Done @ringods! I'll create another release today or tomorrow, but want to include another (bigger) change to make things more flexible moving forwards.

@ringods
Copy link
Author

ringods commented Apr 2, 2020

Tnx.

Gitlab opened an issue also about the inconsistency of the field names:

https://gitlab.com/gitlab-org/gitlab/-/issues/212937

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants