Skip to content

fix(provisioner/terraform): detect text file busy in init -json output - #31688

Open
ethanndickson wants to merge 2 commits into
mainfrom
fix-init-text-file-busy-detector
Open

ethanndickson wants to merge 2 commits into
mainfrom
fix-init-text-file-busy-detector

Conversation

@ethanndickson

Copy link
Copy Markdown
Member

Relates to #14726
Relates to https://linear.app/codercom/issue/CORE-807

#15078 added a CRITICAL log, with a stack trace from terraform-provider-coder, for when terraform init fails with text file busy. It's been dead since #20503 started running init with -json. In JSON mode, terraform writes the error as a diagnostic on stdout and leaves stderr empty, and we only ever checked stderr:

{"@level":"error","@message":"Error: Failed to install provider","@module":"terraform.ui","diagnostic":{"severity":"error","summary":"Failed to install provider","detail":"Error while installing coder/coder v2.13.1: open .../terraform-provider-coder_v2.13.1: text file busy"},"type":"diagnostic"}

To fix, we'll just check stdout as well, and include it in the log. The existing test missed this because its fake terraform always wrote the error to stderr. It now writes the JSON diagnostic to stdout when it's passed -json, and the test also runs against a pre-1.9 version, which still reports the error on stderr.

Terraform 1.9 and later run init with -json. In that mode, Terraform
writes the "Failed to install provider ... text file busy" diagnostic
to stdout as JSON, and stderr stays empty. The detector from #15078
only scanned stderr, so since #20503 it never logs the CRITICAL
"init: text file busy" message or the provider stack trace.

Scan both stdout and stderr, and log stdout with the stack trace.
The fake terraform in TestProvision_TextFileBusy now emits the JSON
diagnostic on stdout when it gets -json, and the test covers a
pre-1.9 version (stderr) and the bundled version (stdout).
@linear-code

linear-code Bot commented Nov 3, 2026

Copy link
Copy Markdown

CORE-807

@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T06:07:38.058211Z da467dc Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: da467dc694

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ethanndickson
ethanndickson marked this pull request as ready for review November 3, 2026 05:57

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da467dc694

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread provisioner/terraform/executor.go Resolved
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

re: Bound the stdout captured during initialization

Declining this one. The stdout copy is bounded by the size of terraform init -json output, which is small: measured with Terraform 1.16.2, it is about 340 bytes per module call and about 0.7 KB per provider, with no download progress in JSON mode. A 300-module test template produced 103 KB, while terraform show -json of the same plan, which parsePlan already reads fully into memory, was 7.5 MB. The buffer only lives for the duration of init, each provisioner daemon runs one job at a time, and every one of those lines is already forwarded as a job log. A streaming matcher with a bounded tail would add complexity without a meaningful memory saving. The stderr copy has been unbounded in the same way since #15078.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: da467dc694

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant