Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
dannykopping merged 38 commits intomainfromdk/logreplacements
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
38 commits
Select commitHold shift + click to select a range
b32923a
feat: log resource replacements
dannykoppingApr 25, 2025
0b0830f
feat: show terraform state drift diff in build logs
dannykoppingApr 25, 2025
256395a
feat: only highlight lines which mention replacement
dannykoppingApr 25, 2025
61ef61a
feat: notify template admins when prebuild claim results in resource …
dannykoppingApr 25, 2025
a66559f
chore: appease linter
dannykoppingApr 25, 2025
222892b
chore: fix notifications test
dannykoppingApr 25, 2025
f34e011
fix: don't panic
dannykoppingApr 28, 2025
5168c01
fix: renaming type
dannykoppingApr 28, 2025
41e5e0c
chore: updating migration numbers
dannykoppingMay 6, 2025
b29e8fa
chore: minor touch-ups
dannykoppingMay 6, 2025
b31ed5e
feat: add resource replacements metric
dannykoppingMay 7, 2025
adf98d2
feat: add resource replacement notification
dannykoppingMay 7, 2025
f24aef0
make lint; make fmt
dannykoppingMay 7, 2025
70f9a53
chore: adding tests
dannykoppingMay 8, 2025
1e8385d
feat: pass flag to terraform provider when prebuilt workspace claimed
dannykoppingMay 9, 2025
d0f00ce
chore: update provider, add test for is_prebuild_claim
dannykoppingMay 12, 2025
11a2c5a
Merge branch 'main' of github.com:/coder/coder into dk/logreplacements
dannykoppingMay 12, 2025
ce63b24
Merge branch 'dk/is-prebuild-claim' of github.com:/coder/coder into d…
dannykoppingMay 12, 2025
d2c5d43
chore: replace GetTemplatePresetsByID with GetPresetByID
dannykoppingMay 12, 2025
22d82a4
chore: correcting docs link
dannykoppingMay 12, 2025
5209aae
Merge branch 'main' of github.com:/coder/coder into dk/logreplacement
dannykoppingMay 12, 2025
39ce658
Merge branch 'main' of github.com:/coder/coder into dk/logreplacements
dannykoppingMay 12, 2025
ac5655f
Merge branch 'main' of github.com:/coder/coder into dk/logreplacements
dannykoppingMay 12, 2025
82c3f58
chore: note provisioner API change
dannykoppingMay 12, 2025
7577a90
chore: fixups
dannykoppingMay 13, 2025
a893b79
chore: adding note about immutable resources
dannykoppingMay 13, 2025
d9c906a
chore: review feedback
dannykoppingMay 13, 2025
471198a
Merge branch 'main' of github.com:/coder/coder into dk/logreplacements
dannykoppingMay 13, 2025
7d694e6
chore: merge conflicts
dannykoppingMay 13, 2025
6b7a8b7
chore: fix 'is not iterable' bullshit
dannykoppingMay 13, 2025
5df2cb3
Merge branch 'main' of github.com:/coder/coder into dk/logreplacements
dannykoppingMay 14, 2025
6d1c3ea
chore: rename migrations
dannykoppingMay 14, 2025
5f62702
chore: set notifications manager before enterprise server initializes…
dannykoppingMay 14, 2025
f74d799
chore: completing refactor since https://github.com/coder/coder/pull/…
dannykoppingMay 14, 2025
971f65c
chore: remove unnecessary atomicity since map is protected by mutex a…
dannykoppingMay 14, 2025
bc362b0
chore: appeasing linter's Very Important Suggestion
dannykoppingMay 14, 2025
4fbd356
Merge branch 'main' of github.com:/coder/coder into dk/logreplacements
dannykoppingMay 14, 2025
b9eb8be
chore: remove old replacement logging
dannykoppingMay 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
chore: remove old replacement logging
Signed-off-by: Danny Kopping <dannykopping@gmail.com>
  • Loading branch information
@dannykopping
dannykopping committedMay 14, 2025
commitb9eb8bee69fda550ea41c466d684641ccbd9ab3c
3 changes: 2 additions & 1 deletioncoderd/provisionerdserver/provisionerdserver_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -45,6 +45,7 @@ import (
"github.com/coder/coder/v2/coderd/telemetry"
"github.com/coder/coder/v2/coderd/wspubsub"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/agentsdk"
"github.com/coder/coder/v2/provisionerd/proto"
"github.com/coder/coder/v2/provisionersdk"
sdkproto "github.com/coder/coder/v2/provisionersdk/proto"
Expand DownExpand Up@@ -1887,7 +1888,7 @@ func TestCompleteJob(t *testing.T) {

// GIVEN something is listening to process workspace reinitialization:
reinitChan := make(chan agentsdk.ReinitializationEvent, 1) // Buffered to simplify test structure
cancel, err :=prebuilds.NewPubsubWorkspaceClaimListener(ps, testutil.Logger(t)).ListenForWorkspaceClaims(ctx, workspace.ID, reinitChan)
cancel, err :=agplprebuilds.NewPubsubWorkspaceClaimListener(ps, testutil.Logger(t)).ListenForWorkspaceClaims(ctx, workspace.ID, reinitChan)
require.NoError(t, err)
defer cancel()

Expand Down
64 changes: 0 additions & 64 deletionsprovisioner/terraform/executor.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -382,68 +382,6 @@ func onlyDataResources(sm tfjson.StateModule) tfjson.StateModule {
return filtered
}

func (e *executor) logResourceReplacements(ctx context.Context, plan *tfjson.Plan) {
if plan == nil {
return
}

if len(plan.ResourceChanges) == 0 {
return
}
var (
count int
replacements = make(map[string][]string, len(plan.ResourceChanges))
)

for _, ch := range plan.ResourceChanges {
// No change, no problem!
if ch.Change == nil {
continue
}

// No-op change, no problem!
if ch.Change.Actions.NoOp() {
continue
}

// No replacements, no problem!
if len(ch.Change.ReplacePaths) == 0 {
continue
}

// Replacing our resources, no problem!
if strings.Index(ch.Type, "coder_") == 0 {
continue
}

for _, p := range ch.Change.ReplacePaths {
var path string
switch p := p.(type) {
case []interface{}:
segs := p
list := make([]string, 0, len(segs))
for _, s := range segs {
list = append(list, fmt.Sprintf("%v", s))
}
path = strings.Join(list, ".")
default:
path = fmt.Sprintf("%v", p)
}

replacements[ch.Address] = append(replacements[ch.Address], path)
}

count++
}

if count > 0 {
e.server.logger.Warn(ctx, "plan introduces resource changes", slog.F("count", count))
for n, p := range replacements {
e.server.logger.Warn(ctx, "resource will be replaced", slog.F("name", n), slog.F("replacement_paths", strings.Join(p, ",")))
}
}
}

// planResources must only be called while the lock is held.
func (e *executor) planResources(ctx, killCtx context.Context, planfilePath string) (*State, *tfjson.Plan, error) {
ctx, span := e.server.startTrace(ctx, tracing.FuncName())
Expand All@@ -454,8 +392,6 @@ func (e *executor) planResources(ctx, killCtx context.Context, planfilePath stri
return nil, nil, xerrors.Errorf("show terraform plan file: %w", err)
}

e.logResourceReplacements(ctx, plan)

rawGraph, err := e.graph(ctx, killCtx)
if err != nil {
return nil, nil, xerrors.Errorf("graph: %w", err)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp