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: implement expiration policy logic for prebuilds#17996

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
Merged
Changes from1 commit
Commits
Show all changes
15 commits
Select commitHold shift + click to select a range
a38ee7c
feat: implement cache invalidation logic for prebuilds
ssncferreiraMay 22, 2025
a904d3f
chore: add preset_id to log messages in reconciliation cycle
ssncferreiraMay 23, 2025
b0abd30
Merge remote-tracking branch 'origin/main' into ssncferreira/feat-pre…
ssncferreiraMay 23, 2025
f43ea2c
docs: add documentation regarding cache_invalidation to Prebuilt work…
ssncferreiraMay 23, 2025
c7e442c
fix: update code according to latest terraform schema expiration_poli…
ssncferreiraMay 23, 2025
28a6274
fix: proto comment
ssncferreiraMay 23, 2025
7482bfb
fix: preset_snapshot_test to create Preset with TTL via options
ssncferreiraMay 23, 2025
04c0e7c
chore: update Actual state count to include both expired and non-expi…
ssncferreiraMay 26, 2025
8e5caae
chore: update terraform-provider-coder to version v2.5.0
ssncferreiraMay 26, 2025
4b1fbb5
fix: run terraform generate.sh to update preset files
ssncferreiraMay 26, 2025
30771cf
fix: update resources_test to include ApiKeyScope parameter
ssncferreiraMay 26, 2025
266c445
Merge remote-tracking branch 'origin/main' into ssncferreira/feat-pre…
ssncferreiraMay 26, 2025
14be03f
chore: update Provisioner API version 1.6 with prebuilds' expiration …
ssncferreiraMay 26, 2025
7a24eea
chore: update preset snapshot tests test data for consistency
ssncferreiraMay 26, 2025
7666090
Merge remote-tracking branch 'origin/main' into ssncferreira/feat-pre…
ssncferreiraMay 26, 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
NextNext commit
fix: preset_snapshot_test to create Preset with TTL via options
  • Loading branch information
@ssncferreira
ssncferreira committedMay 23, 2025
commit7482bfb8902452ab4cc16c91af8990ecb940844f
73 changes: 29 additions & 44 deletionscoderd/prebuilds/preset_snapshot_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,6 +23,7 @@ type options struct {
presetName string
prebuiltWorkspaceID uuid.UUID
workspaceName string
ttl int32
}

// templateID is common across all option sets.
Expand All@@ -34,6 +35,7 @@ const (
optionSet0 = iota
optionSet1
optionSet2
optionSet3
)

var opts = map[uint]options{
Expand DownExpand Up@@ -61,6 +63,15 @@ var opts = map[uint]options{
prebuiltWorkspaceID: uuid.UUID{33},
workspaceName: "prebuilds2",
},
optionSet3: {
templateID: templateID,
templateVersionID: uuid.UUID{31},
presetID: uuid.UUID{32},
presetName: "my-preset",
prebuiltWorkspaceID: uuid.UUID{33},
workspaceName: "prebuilds2",
ttl: 5, // seconds
},
}

// A new template version with a preset without prebuilds configured should result in no prebuilds being created.
Expand DownExpand Up@@ -249,11 +260,7 @@ func TestInProgressActions(t *testing.T) {
inProgress: 1,
checkFn: func(state prebuilds.ReconciliationState, actions []*prebuilds.ReconciliationActions) {
validateState(t, prebuilds.ReconciliationState{Desired: 1, Starting: 1}, state)
validateActions(t, []*prebuilds.ReconciliationActions{
{
ActionType: prebuilds.ActionTypeCreate,
},
}, actions)
validateActions(t, nil, actions)
},
},
// With one running prebuild and one starting, no creations/deletions should occur since we're approaching the correct state.
Expand All@@ -265,11 +272,7 @@ func TestInProgressActions(t *testing.T) {
inProgress: 1,
checkFn: func(state prebuilds.ReconciliationState, actions []*prebuilds.ReconciliationActions) {
validateState(t, prebuilds.ReconciliationState{Actual: 1, Desired: 2, Starting: 1}, state)
validateActions(t, []*prebuilds.ReconciliationActions{
{
ActionType: prebuilds.ActionTypeCreate,
},
}, actions)
validateActions(t, nil, actions)
},
},
// With one running prebuild and one starting, no creations/deletions should occur
Expand All@@ -282,11 +285,7 @@ func TestInProgressActions(t *testing.T) {
inProgress: 1,
checkFn: func(state prebuilds.ReconciliationState, actions []*prebuilds.ReconciliationActions) {
validateState(t, prebuilds.ReconciliationState{Actual: 2, Desired: 2, Starting: 1}, state)
validateActions(t, []*prebuilds.ReconciliationActions{
{
ActionType: prebuilds.ActionTypeCreate,
},
}, actions)
validateActions(t, nil, actions)
},
},
// With one prebuild desired and one stopping, a new prebuild will be created.
Expand DownExpand Up@@ -332,11 +331,7 @@ func TestInProgressActions(t *testing.T) {
inProgress: 1,
checkFn: func(state prebuilds.ReconciliationState, actions []*prebuilds.ReconciliationActions) {
validateState(t, prebuilds.ReconciliationState{Actual: 3, Desired: 3, Stopping: 1}, state)
validateActions(t, []*prebuilds.ReconciliationActions{
{
ActionType: prebuilds.ActionTypeCreate,
},
}, actions)
validateActions(t, nil, actions)
},
},
// With one prebuild desired and one deleting, a new prebuild will be created.
Expand DownExpand Up@@ -382,11 +377,7 @@ func TestInProgressActions(t *testing.T) {
inProgress: 1,
checkFn: func(state prebuilds.ReconciliationState, actions []*prebuilds.ReconciliationActions) {
validateState(t, prebuilds.ReconciliationState{Actual: 2, Desired: 2, Deleting: 1}, state)
validateActions(t, []*prebuilds.ReconciliationActions{
{
ActionType: prebuilds.ActionTypeCreate,
},
}, actions)
validateActions(t, nil, actions)
},
},
// With 3 prebuilds desired, 1 running, and 2 starting, no creations should occur since the builds are in progress.
Expand DownExpand Up@@ -534,7 +525,7 @@ func TestExtraneous(t *testing.T) {
// specified in the preset's cache invalidation invalidate_after_secs parameter.
func TestExpiredPrebuilds(t *testing.T) {
t.Parallel()
current := opts[optionSet0]
current := opts[optionSet3]
clock := quartz.NewMock(t)

cases := []struct {
Expand DownExpand Up@@ -676,8 +667,8 @@ func TestExpiredPrebuilds(t *testing.T) {
require.NoError(t, err)
prebuildCreateAt := time.Now()
if int(tc.expired) > expiredCount {
// Update the prebuild workspace createdAt to exceed its TTL
prebuildCreateAt = prebuildCreateAt.Add(-ttlDuration -2*time.Second)
// Update the prebuild workspace createdAt to exceed its TTL (5 seconds)
prebuildCreateAt = prebuildCreateAt.Add(-ttlDuration -10*time.Second)
expiredCount++
}
running = append(running, database.GetRunningPrebuiltWorkspacesRow{
Expand DownExpand Up@@ -810,12 +801,7 @@ func TestLatestBuildFailed(t *testing.T) {
validateState(t, prebuilds.ReconciliationState{
Actual: 1, Desired: 1, Eligible: 1,
}, *state)
validateActions(t, []*prebuilds.ReconciliationActions{
{
ActionType: prebuilds.ActionTypeCreate,
BackoffUntil: time.Time{},
},
}, actions)
validateActions(t, nil, actions)

// WHEN: the clock is advanced a backoff interval.
clock.Advance(backoffInterval + time.Microsecond)
Expand DownExpand Up@@ -894,12 +880,7 @@ func TestMultiplePresetsPerTemplateVersion(t *testing.T) {
Starting: 1,
Desired: 1,
}, *state)
validateActions(t, []*prebuilds.ReconciliationActions{
{
ActionType: prebuilds.ActionTypeCreate,
Create: 0,
},
}, actions)
validateActions(t, nil, actions)
}

// One prebuild has to be created for preset 2. Make sure preset 1 doesn't block preset 2.
Expand All@@ -925,6 +906,13 @@ func TestMultiplePresetsPerTemplateVersion(t *testing.T) {
}

func preset(active bool, instances int32, opts options, muts ...func(row database.GetTemplatePresetsWithPrebuildsRow) database.GetTemplatePresetsWithPrebuildsRow) database.GetTemplatePresetsWithPrebuildsRow {
ttl := sql.NullInt32{}
if opts.ttl > 0 {
ttl = sql.NullInt32{
Valid: true,
Int32: opts.ttl,
}
}
entry := database.GetTemplatePresetsWithPrebuildsRow{
TemplateID: opts.templateID,
TemplateVersionID: opts.templateVersionID,
Expand All@@ -937,10 +925,7 @@ func preset(active bool, instances int32, opts options, muts ...func(row databas
},
Deleted: false,
Deprecated: false,
Ttl: sql.NullInt32{
Valid: true,
Int32: 2,
},
Ttl: ttl,
}

for _, mut := range muts {
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp