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

Support for Gitlab EE soft-delete of groups and projects #291

Merged
merged 9 commits into from
Apr 4, 2020

Conversation

ringods
Copy link
Contributor

@ringods ringods commented Apr 1, 2020

Adding the support in the gitlab_group and gitlab_project resources for soft delete as defined in Gitlab Enterprise Edition since version 12.

Fixes: #263

@weimeng and/or @kuahyeow I still could use some help with the Gitlab Enterprise Edition test suite. On Github Actions, I can't get them to run. First of all, they time out which means that the tests are hanging somewhere. I also have several failures.

Comparing this to the Gitlab CE test suite. These are the same tests, but they all succeed when running against the Gitlab CE edition. Also, when I run the test suite against Gitlab EE on my local mac in a Vagrant box, they run in about 11 minutes and I have 1 test failure which I think is related to #269.

Would one of you be open for a conference call where we could discuss things? With me knowing how TF tests work and you knowing how Gitlab and the API work, we have to bring this knowledge together to get this working.

@ringods
Copy link
Contributor Author

ringods commented Apr 2, 2020

@weimeng and @kuahyeow, I have further analysed the logs from an acceptance test run with DEBUG output showing the requests and respones going to and coming from a Gitlab server. I detected an inconsistency between groups and projects:

  • groups: soft-delete can be detected by field marked_for_deletion_on
  • projects: soft-delete can be detected by field marked_for_deletion_at

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

Additional question: is there even a pending_delete field in the groups or projects JSON returned by a GET operation?

@@ -208,6 +208,10 @@ func resourceGitlabGroupDelete(d *schema.ResourceData, meta interface{}) error {
log.Printf("[ERROR] Received error: %#v", err)
return out, "Error", err
}
if out.PendingDelete {
Copy link

@kuahyeow kuahyeow Apr 2, 2020

Choose a reason for hiding this comment

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

I'm not sure GitLab has pending_delete for groups, but rather it has marked_for_deletion_on instead.

Here's a snippet of JSON for https://gitlab.com/api/v4/groups/9970

{"id":9970,"web_url":"https://gitlab.com/groups/gitlab-org","name":"GitLab.org","path":"gitlab-org","description":"Open source software to collaborate on code","visibility":"public","share_with_group_lock":false,"require_two_factor_authentication":true,"two_factor_grace_period":120,"project_creation_level":"developer","auto_devops_enabled":null,"subgroup_creation_level":"owner","emails_disabled":false,"mentions_disabled":true,"lfs_enabled":true,"default_branch_protection":2,"avatar_url":"https://assets.gitlab-static.net/uploads/-/system/group/avatar/9970/logo-extra-whitespace.png","request_access_enabled":false,"full_name":"GitLab.org","full_path":"gitlab-org","created_at":"2013-09-26T06:02:04.000Z","parent_id":null,"ldap_cn":null,"ldap_access":null,"file_template_project_id":null,"marked_for_deletion_on":null,

@kuahyeow
Copy link

kuahyeow commented Apr 2, 2020

@weimeng and @kuahyeow, I have further analysed the logs from an acceptance test run with DEBUG output showing the requests and respones going to and coming from a Gitlab server. I detected an inconsistency between groups and projects:

  • groups: soft-delete can be detected by field marked_for_deletion_on
  • projects: soft-delete can be detected by field marked_for_deletion_at

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

Yeah, I have noticed this and opened https://gitlab.com/gitlab-org/gitlab/-/issues/212937

Additional question: is there even a pending_delete field in the groups or projects JSON returned by a GET operation?

I don't think there's a pending_delete at all. It's marked_for_deletion_at / marked_for_deletion_on for projects and groups respectively as you have noticed

@ghost ghost added size/XL and removed size/S labels Apr 3, 2020
@ringods ringods mentioned this pull request Apr 3, 2020
@ringods ringods merged commit da9cca3 into master Apr 4, 2020
@ringods ringods deleted the soft-delete branch April 4, 2020 15:54
ahmet2mir pushed a commit to ahmet2mir/terraform-provider-gitlab that referenced this pull request Sep 15, 2020
Support for Gitlab EE soft-delete of groups and projects
@github-actions github-actions bot locked and limited conversation to collaborators Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

Gitlab introduced soft delete of projects and groups
2 participants