Skip to content

feat: log resource drift warnings in all workspace builds #18355

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

dannykopping
Copy link
Contributor

@dannykopping dannykopping commented Jun 13, 2025

Closes #16999

image

#17571 added the ability to detect and log Terraform state drift in workspace builds. We decided to only display these logs for prebuilds, initially, since prebuilds are most likely to be negatively impacted by state drift.

All output from Terraform is shown, and lines including # forces replacement will be marked as WARN.

This PR removes the above condition and improves test coverage.

We might consider adding a hidden flag to disable this logging, in case some operators find this objectionable?


Disclaimer: credit to Claude Code for initial draft of the tests.

Signed-off-by: Danny Kopping <dannykopping@gmail.com>
Signed-off-by: Danny Kopping <dannykopping@gmail.com>
Signed-off-by: Danny Kopping <dannykopping@gmail.com>
Copy link
Contributor

@spikecurtis spikecurtis left a comment

Choose a reason for hiding this comment

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

We have to be careful about sending logs with elevated level. Provisionerd logs them directly at the level we get from the provisioner, which then will end up in operators log streams. That's especially problematic if provisionerd is embedded in Coderd.

I get that, arguably, if there is drift while you are claiming a prebuild then you are doing something wrong. But that isn't true of builds generally, and it's a bad idea for us to emit a bunch of WARN logs to core Coder operators based on stuff happening down in templates and builds, as template authorship might be delegated out to teams that are clients of the Coder platform.

The quickest way forward is to just not emit at WARN for this kind of stuff.

A more flexible and general solution would be to introduce some sort of log scope, to distinguish warnings and errors with builds and templates from warnings and errors with the provisioner. Only the latter should be emitted at WARN/ERROR level into the provisioner's log stream. The former can be emitted into the build logs at the given level so we display them appropriately in the UI.

@coder coder deleted a comment from blink-so bot Jun 18, 2025
@dannykopping
Copy link
Contributor Author

@spikecurtis thanks for your thoughts; I'll get back to this hopefully tomorrow or early next week.

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.

bug: build terraform logs don't include which fields have changed
2 participants