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

Error: Provider produced inconsistent result after apply #474

Closed
bb-josh opened this issue Oct 20, 2021 · 2 comments
Closed

Error: Provider produced inconsistent result after apply #474

bb-josh opened this issue Oct 20, 2021 · 2 comments
Labels

Comments

@bb-josh
Copy link

bb-josh commented Oct 20, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and Azure DevOps Provider) Version

terraform -v
Terraform v1.0.9
on darwin_amd64
+ provider registry.terraform.io/microsoft/azuredevops v0.1.7

Affected Resource(s)

azuredevops_project

Terraform Configuration Files

terraform {
  required_providers {
    azuredevops = {
      source  = "microsoft/azuredevops"
      version = "0.1.7"
    }
  }
}

provider "azuredevops" {
  org_service_url       = "https://dev.azure.com/${var.organization}"
  personal_access_token = var.personal_access_token_full_access
}

resource "azuredevops_project" "terraform_ado_project" {
  name               = var.project_name
  description        = var.description
  visibility         = var.visibility
  version_control    = var.version_control
  work_item_template = var.work_item_template
}

Debug Output

Gist_0
Gist_1

Expected Behavior

NOTE: This issue appears inconsistently. With the same Terraform configuration and the same commands, this configuration will sometimes apply and destroy as expected. Other-times not.

Applying this plan should consistently create a project under my organization in Azure Devops and consistently be tracked in the Terraform state.

Actual Behavior

NOTE: This issue appears inconsistently. With the same Terraform configuration and the same commands, this configuration will sometimes apply and destroy as expected. Other-times not.

  1. Applying this plan led to Terraform throwing the error:
    Error: Provider produced inconsistent result after apply

  2. The project is created and viewable in the UI

  3. When running apply a second time Terraform throws this error indicating it is not tracking the resource state:
    Error: Error creating project: TF200019: The following project already exists on the Azure DevOps Server: TEST_PROJECT_00. You cannot create a new project with the same name as an existing project. Provide a different name.

  4. terraform destroy (as expected) does not have any trackable resources to destroy

Steps to Reproduce

  1. terraform apply
  2. terraform apply
  3. terraform destroy

References

Related issues:

Related PRs:

@xuzhang3
Copy link
Collaborator

@bb-josh Thanks for the feedback. I can reproduce this error by manually change the service response. The project has been created but when provider try get the project, service response indicate that this project was not found. In this scenario, the ADO provider will set resource ID to empty string to notify Terraform that this resource should be deleted from the state file. One way to fix this issue is enhance the get project logic, a retry logic should be helpful here.

@xuzhang3
Copy link
Collaborator

close this issue, feel free to open another if you still have questions.

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

No branches or pull requests

2 participants