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

Make read callbacks graceful for gitlab_project_share_group, gitlab_branch_protection and gitlab_label resources #222

Closed
wants to merge 1 commit into from

Conversation

ymatsiuk
Copy link
Contributor

Every time resource got changed manually, provider fails and the only fix is to remove failing resource from the state. If resource doesn't exist in gitlab, terraform should be informed and state cleaned, instead of failing with error.
Inspired by #209

@ghost ghost added the size/M label Nov 22, 2019
@roidelapluie
Copy link
Collaborator

This is the expected behaviour.

The provider uses gitlab ID's to identify resources. That ID can not change.

If a resource has a different id in gitlab, then it is not the resource that was created by terraform.

Note: in addition to that, if you do not have the rights to read resources, we also get a 404 from the API. It means that the state could be destroyed if someone launches the plug-in with bad credentials.

@ymatsiuk
Copy link
Contributor Author

@roidelapluie So in other words if I created protected branch with terraform and someone removed protection using gitlab admin interface it's expected for terraform to fail next plan by design?

I'm very curious, because here it says:

If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case.

@roidelapluie
Copy link
Collaborator

For the protected branch we could adopt this.

However for git repos etc I would not do it because of the mentionned issue: if you do not have the rights to read resources, we also get a 404 from the API. It means that the state could be destroyed if someone launches the plug-in with bad credentials.

@roidelapluie
Copy link
Collaborator

I would be happy if gitlab would return 403 but they return 404.

@ymatsiuk
Copy link
Contributor Author

gitlab_project_share_group causes the same amount of manual actions as gitlab_branch_protection. Shall I rebase for both resources and revert the rest?

@roidelapluie
Copy link
Collaborator

Also gitlab_labels

@ymatsiuk ymatsiuk changed the title Make read callbacks graceful Make read callbacks graceful for gitlab_project_share_group, gitlab_branch_protection and gitlab_label resources Nov 25, 2019
@ymatsiuk
Copy link
Contributor Author

could you please re-open this PR?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

2 participants