- Notifications
You must be signed in to change notification settings - Fork1.1k
feat: track resource replacements when claiming a prebuilt workspace#17571
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
38 commits Select commitHold shift + click to select a range
b32923a feat: log resource replacements
dannykopping0b0830f feat: show terraform state drift diff in build logs
dannykopping256395a feat: only highlight lines which mention replacement
dannykopping61ef61a feat: notify template admins when prebuild claim results in resource …
dannykoppinga66559f chore: appease linter
dannykopping222892b chore: fix notifications test
dannykoppingf34e011 fix: don't panic
dannykopping5168c01 fix: renaming type
dannykopping41e5e0c chore: updating migration numbers
dannykoppingb29e8fa chore: minor touch-ups
dannykoppingb31ed5e feat: add resource replacements metric
dannykoppingadf98d2 feat: add resource replacement notification
dannykoppingf24aef0 make lint; make fmt
dannykopping70f9a53 chore: adding tests
dannykopping1e8385d feat: pass flag to terraform provider when prebuilt workspace claimed
dannykoppingd0f00ce chore: update provider, add test for is_prebuild_claim
dannykopping11a2c5a Merge branch 'main' of github.com:/coder/coder into dk/logreplacements
dannykoppingce63b24 Merge branch 'dk/is-prebuild-claim' of github.com:/coder/coder into d…
dannykoppingd2c5d43 chore: replace GetTemplatePresetsByID with GetPresetByID
dannykopping22d82a4 chore: correcting docs link
dannykopping5209aae Merge branch 'main' of github.com:/coder/coder into dk/logreplacement
dannykopping39ce658 Merge branch 'main' of github.com:/coder/coder into dk/logreplacements
dannykoppingac5655f Merge branch 'main' of github.com:/coder/coder into dk/logreplacements
dannykopping82c3f58 chore: note provisioner API change
dannykopping7577a90 chore: fixups
dannykoppinga893b79 chore: adding note about immutable resources
dannykoppingd9c906a chore: review feedback
dannykopping471198a Merge branch 'main' of github.com:/coder/coder into dk/logreplacements
dannykopping7d694e6 chore: merge conflicts
dannykopping6b7a8b7 chore: fix 'is not iterable' bullshit
dannykopping5df2cb3 Merge branch 'main' of github.com:/coder/coder into dk/logreplacements
dannykopping6d1c3ea chore: rename migrations
dannykopping5f62702 chore: set notifications manager before enterprise server initializes…
dannykoppingf74d799 chore: completing refactor since https://github.com/coder/coder/pull/…
dannykopping971f65c chore: remove unnecessary atomicity since map is protected by mutex a…
dannykoppingbc362b0 chore: appeasing linter's Very Important Suggestion
dannykopping4fbd356 Merge branch 'main' of github.com:/coder/coder into dk/logreplacements
dannykoppingb9eb8be chore: remove old replacement logging
dannykoppingFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
chore: review feedback
Signed-off-by: Danny Kopping <dannykopping@gmail.com>
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commitd9c906a49331da79f2ee8af982b563f448ac28b7
There are no files selected for viewing
5 changes: 3 additions & 2 deletionscoderd/provisionerdserver/provisionerdserver.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -26,6 +26,7 @@ import ( | ||
| protobuf "google.golang.org/protobuf/proto" | ||
| "cdr.dev/slog" | ||
| "github.com/coder/coder/v2/codersdk/drpcsdk" | ||
| "github.com/coder/quartz" | ||
| @@ -1729,8 +1730,8 @@ func (s *server) CompleteJob(ctx context.Context, completed *proto.CompletedJob) | ||
| // Track resource replacements, if there are any. | ||
| orchestrator := s.PrebuildsOrchestrator.Load() | ||
| if resourceReplacements := completed.GetWorkspaceBuild().GetResourceReplacements(); orchestrator != nil && len(resourceReplacements) > 0 { | ||
| // Fire and forget. Bind to the lifecycle of the server so shutdowns are handled gracefully. | ||
| go (*orchestrator).TrackResourceReplacement(s.lifecycleCtx, workspace.ID, workspaceBuild.ID, resourceReplacements) | ||
dannykopping marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| } | ||
| } | ||
9 changes: 4 additions & 5 deletionsenterprise/coderd/prebuilds/reconcile.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
9 changes: 6 additions & 3 deletionsprovisioner/terraform/executor.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -416,7 +416,7 @@ func (e *executor) parsePlan(ctx, killCtx context.Context, planfilePath string) | ||
| // logDrift must only be called while the lock is held. | ||
| // It will log the output of `terraform show`, which will show which resources have drifted from the known state. | ||
| func (e *executor) logDrift(ctx, killCtx context.Context, planfilePath string, logr logSink) { | ||
| stdout, stdoutDone := resourceReplaceLogWriter(logr, e.logger) | ||
| stderr, stderrDone := logWriter(logr, proto.LogLevel_ERROR) | ||
| defer func() { | ||
| _ = stdout.Close() | ||
| @@ -436,9 +436,9 @@ func (e *executor) logDrift(ctx, killCtx context.Context, planfilePath string, l | ||
| // | ||
| // The WriteCloser must be closed by the caller to end logging, after which the returned channel will be closed to | ||
| // indicate that logging of the written data has finished. Failure to close the WriteCloser will leak a goroutine. | ||
| func resourceReplaceLogWriter(sink logSink, logger slog.Logger) (io.WriteCloser, <-chanstruct{}) { | ||
| r, w := io.Pipe() | ||
| done := make(chanstruct{}) | ||
| go func() { | ||
| defer close(done) | ||
| @@ -455,6 +455,9 @@ func resourceReplaceLogWriter(sink logSink) (io.WriteCloser, <-chan any) { | ||
| sink.ProvisionLog(level, string(line)) | ||
| } | ||
dannykopping marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| if err := scanner.Err(); err != nil { | ||
| logger.Error(context.Background(), "failed to read terraform log", slog.Error(err)) | ||
| } | ||
| }() | ||
| return w, done | ||
| } | ||
21 changes: 11 additions & 10 deletionsprovisioner/terraform/resource_replacements.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.