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

Commit3846a20

Browse files
fix: skipping hard-limited preset
1 parent2d4d2cf commit3846a20

File tree

2 files changed

+41
-9
lines changed

2 files changed

+41
-9
lines changed

‎coderd/prebuilds/global_snapshot.go

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,31 @@ import (
1010

1111
// GlobalSnapshot represents a full point-in-time snapshot of state relating to prebuilds across all templates.
1212
typeGlobalSnapshotstruct {
13-
Presets []database.GetTemplatePresetsWithPrebuildsRow
14-
RunningPrebuilds []database.GetRunningPrebuiltWorkspacesRow
15-
PrebuildsInProgress []database.CountInProgressPrebuildsRow
16-
Backoffs []database.GetPresetsBackoffRow
13+
Presets []database.GetTemplatePresetsWithPrebuildsRow
14+
RunningPrebuilds []database.GetRunningPrebuiltWorkspacesRow
15+
PrebuildsInProgress []database.CountInProgressPrebuildsRow
16+
Backoffs []database.GetPresetsBackoffRow
17+
HardLimitedPresetMapmap[uuid.UUID]database.GetPresetsAtFailureLimitRow
1718
}
1819

1920
funcNewGlobalSnapshot(
2021
presets []database.GetTemplatePresetsWithPrebuildsRow,
2122
runningPrebuilds []database.GetRunningPrebuiltWorkspacesRow,
2223
prebuildsInProgress []database.CountInProgressPrebuildsRow,
2324
backoffs []database.GetPresetsBackoffRow,
25+
hardLimitedPresets []database.GetPresetsAtFailureLimitRow,
2426
)GlobalSnapshot {
27+
hardLimitedPresetMap:=make(map[uuid.UUID]database.GetPresetsAtFailureLimitRow,len(hardLimitedPresets))
28+
for_,preset:=rangehardLimitedPresets {
29+
hardLimitedPresetMap[preset.PresetID]=preset
30+
}
31+
2532
returnGlobalSnapshot{
26-
Presets:presets,
27-
RunningPrebuilds:runningPrebuilds,
28-
PrebuildsInProgress:prebuildsInProgress,
29-
Backoffs:backoffs,
33+
Presets:presets,
34+
RunningPrebuilds:runningPrebuilds,
35+
PrebuildsInProgress:prebuildsInProgress,
36+
Backoffs:backoffs,
37+
HardLimitedPresetMap:hardLimitedPresetMap,
3038
}
3139
}
3240

@@ -64,3 +72,8 @@ func (s GlobalSnapshot) FilterByPreset(presetID uuid.UUID) (*PresetSnapshot, err
6472
Backoff:backoffPtr,
6573
},nil
6674
}
75+
76+
func (sGlobalSnapshot)IsHardLimited(presetID uuid.UUID)bool {
77+
_,ok:=s.HardLimitedPresetMap[presetID]
78+
returnok
79+
}

‎enterprise/coderd/prebuilds/reconcile.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ func (c *StoreReconciler) ReconcileAll(ctx context.Context) error {
243243
vareg errgroup.Group
244244
// Reconcile presets in parallel. Each preset in its own goroutine.
245245
for_,preset:=rangesnapshot.Presets {
246+
ifsnapshot.IsHardLimited(preset.ID) {
247+
logger.Debug(ctx,"skipping hard limited preset",slog.F("id",preset.ID),slog.F("name",preset.Name))
248+
continue
249+
}
250+
246251
ps,err:=snapshot.FilterByPreset(preset.ID)
247252
iferr!=nil {
248253
logger.Warn(ctx,"failed to find preset snapshot",slog.Error(err),slog.F("preset_id",preset.ID.String()))
@@ -292,6 +297,7 @@ func (c *StoreReconciler) SnapshotState(ctx context.Context, store database.Stor
292297
iflen(presetsWithPrebuilds)==0 {
293298
returnnil
294299
}
300+
295301
allRunningPrebuilds,err:=db.GetRunningPrebuiltWorkspaces(ctx)
296302
iferr!=nil {
297303
returnxerrors.Errorf("failed to get running prebuilds: %w",err)
@@ -307,7 +313,20 @@ func (c *StoreReconciler) SnapshotState(ctx context.Context, store database.Stor
307313
returnxerrors.Errorf("failed to get backoffs for presets: %w",err)
308314
}
309315

310-
state=prebuilds.NewGlobalSnapshot(presetsWithPrebuilds,allRunningPrebuilds,allPrebuildsInProgress,presetsBackoff)
316+
// TODO: make hardLimit configurable
317+
hardLimit:=int64(1)
318+
hardLimitedPresets,err:=db.GetPresetsAtFailureLimit(ctx,hardLimit)
319+
iferr!=nil {
320+
returnxerrors.Errorf("failed to get hard limited presets: %w",err)
321+
}
322+
323+
state=prebuilds.NewGlobalSnapshot(
324+
presetsWithPrebuilds,
325+
allRunningPrebuilds,
326+
allPrebuildsInProgress,
327+
presetsBackoff,
328+
hardLimitedPresets,
329+
)
311330
returnnil
312331
},&database.TxOptions{
313332
Isolation:sql.LevelRepeatableRead,// This mirrors the MVCC snapshotting Postgres does when using CTEs

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp