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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing azurerm_cognitive_deployment resources produces an unexpected status before attempting to import #35237

Open
1 task done
MohnJadden opened this issue May 23, 2024 · 6 comments
Labels
bug new new issue not yet triaged v1.8 Issues (primarily bugs) reported against v1.8 releases waiting for reproduction unable to reproduce issue without further information

Comments

@MohnJadden
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

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 and review the contribution guide to help.

Terraform Version

1.8.4

AzureRM Provider Version

3.104.2

Affected Resource(s)/Data Source(s)

azurerm_cognitive_deployment

Terraform Configuration Files

resource "azurerm_cognitive_deployment" "test-gpt4o-gs" {
  for_each             = var.environmentName
  name                 = "gpt-4o-gs"
  cognitive_account_id = azurerm_cognitive_account.test-cog[each.key].id
  model {
    format = "OpenAI"
    name   = "gpt-4o"
    version = "2024-05-13"
  }
  scale {
    type     = "Global-Standard"
    capacity = "100"
  }
  lifecycle {
    ignore_changes = [model,scale]
  }
}

Debug Output/Panic Output

The following text shows up in my command prompt/terminal session:
test-cog/deployments/companydeployment-gpt-4o";

Nothing changes or displays for a few seconds, then the import command runs as it normally would

Expected Behaviour

There should be some kind of status that indicates Terraform is parsing the command and/or checking the state

Actual Behaviour

The newline with the semicolon displays, with nothing changing for a few seconds, then the import command runs

Steps to Reproduce

  1. Create the resource in Azure
  2. Add the resource to the main.tf of the module
  3. Run terraform import 'module.modulename-openai-test.azurerm_cognitive_deployment.name-test-gpt4o["test"]' "/subscriptions/mysubscription/resourceGroups/test-RG/providers/Microsoft.CognitiveServices/accounts/test-cog/deployments/companydeployment-gpt-4o"

Important Factoids

This is in a Windows system, hence the escape characters

References

No response

@tombuildsstuff
Copy link
Member

Transferring this to hashicorp/terraform since this behaviour comes from Terraform Core

@tombuildsstuff tombuildsstuff transferred this issue from hashicorp/terraform-provider-azurerm May 24, 2024
@apparentlymart
Copy link
Member

Hi @MohnJadden! Sorry for this strange behavior, and thanks for reporting it.

Unfortunately since this issue relates to an object in your Azure account I think we will need more information from you to diagnose it.

It would be helpful if you would repeat the reproduction steps you described but set the environment variable TF_LOG=trace before you perform step 3, which will make Terraform show its internal logs of how it handled the import command. The results are typically too long to be readable in a GitHub issue comment, so I suggest creating a GitHub Gist containing the log text and then sharing a link to it here, which will then allow us to retrieve the full log text without any corruption.

Unfortunately I don't yet have a theory about why Terraform would be printing part of your import ID followed by a semicolon, because that doesn't match any intentional Terraform output I know of, but I'm hoping that the trace log will give some clues as to what part of Terraform is generating that message and then we'll have a better chance of figuring out what's going wrong here.

Thanks!

@MohnJadden
Copy link
Author

@apparentlymart Gist is at https://gist.github.com/MohnJadden/c58cce94528bdade43277ef3aba5dd85 - LMK if I can provide anything further.

@apparentlymart
Copy link
Member

apparentlymart commented May 28, 2024

Thanks for sharing that trace log, @MohnJadden!

Based on that I see that the Terraform interpreted the command line like this (using Go's conventions for printing a slice of strings):

[]string{
    "C:\\ProgramData\\chocolatey\\lib\\terraform\\tools\\terraform.exe",
    "import",
    "-no-color",
    "module.projectname-openai-test.azurerm_cognitive_deployment.projectname-test-gpt4o-gs-project2[\"test\"]",
    "/subscriptions/subscriptionguid/resourceGroups/projectnametest-test-RG/providers/Microsoft.CognitiveServices/accounts/projectnametest-test-cog/deployments/gpt-4o-gs-project2",
}

...which matches what I would've expected for this command line. (Sometimes PowerShell corrupts the command line before running an external command, but it doesn't seem to have done so in this case.)

Unfortunately I wasn't able to find the string test-cog/deployments/companydeployment-gpt-4o"; in the output. I was hoping to be able to correlate that output with some part of the log messages to narrow down what might be printing it, but I'm now wondering if I should conclude from this that the message was being printed by something else in your environment, before running Terraform.

Just to make sure I'm not making an incorrect assumption: can you verify that the errant extra text you mentioned in your original issue doesn't appear anywhere in the unredacted version of the trace log? I notice you deleted some parts before you shared it, which is fine, but I just want to make sure we didn't lose the part that's relevant to this issue as part of that redacting. 馃榾

@MohnJadden
Copy link
Author

@apparentlymart I can confirm that the log has zero mention of the string companydeployment-gpt-4o"; in any part of the log. It only appears when the import is run and it makes no mention or other indication that anything is actually running.

This is a screenshot of what the actual output at issue looks like with details redacted:
image

@apparentlymart
Copy link
Member

Thanks @MohnJadden!

Unfortunately this leaves me quite stumped about what to try next. The fact that this message appears very early after you start running the command makes me wonder if this is being printed by something else in your environment before Terraform even begins running, but I don't know what to ask to try to prove or disprove that hypothesis. 馃

There are lots of messages produced by parts of Terraform's code that involve a quoted string followed by a semicolon, and so I can't feasibly visit them all, but after searching for code that might produce a message like that most of what I found were error messages and unit test assertions. Of those two only error messages would be possible to see in a released version of Terraform, but the behavior you reported doesn't involve any errors.

The fact that we only see what appears to be a fragment of the message is also baffling. Terraform CLI and Terraform Core don't know anything about the Azure provider's import ID syntax, and so would have no reason to split the string just before the test-cog token. Even if it did, the fact that there's no quote symbol at the start suggests that it's the overall message that's been truncated, rather than just the import id.

I'm afraid I've run out of ideas for this one. 馃槚

@crw crw added bug new new issue not yet triaged waiting for reproduction unable to reproduce issue without further information labels Jun 3, 2024
@apparentlymart apparentlymart added the v1.8 Issues (primarily bugs) reported against v1.8 releases label Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug new new issue not yet triaged v1.8 Issues (primarily bugs) reported against v1.8 releases waiting for reproduction unable to reproduce issue without further information
Projects
None yet
Development

No branches or pull requests

4 participants