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

Commite88e301

Browse files
refactor: CR's fixes
1 parent701e2a8 commite88e301

File tree

3 files changed

+30
-33
lines changed

3 files changed

+30
-33
lines changed

‎coderd/prebuilds/global_snapshot.go

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ 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
17-
HardLimitedPresetMapmap[uuid.UUID]database.GetPresetsAtFailureLimitRow
13+
Presets []database.GetTemplatePresetsWithPrebuildsRow
14+
RunningPrebuilds []database.GetRunningPrebuiltWorkspacesRow
15+
PrebuildsInProgress []database.CountInProgressPrebuildsRow
16+
Backoffs []database.GetPresetsBackoffRow
17+
HardLimitedPresets []database.GetPresetsAtFailureLimitRow
1818
}
1919

2020
funcNewGlobalSnapshot(
@@ -24,17 +24,12 @@ func NewGlobalSnapshot(
2424
backoffs []database.GetPresetsBackoffRow,
2525
hardLimitedPresets []database.GetPresetsAtFailureLimitRow,
2626
)GlobalSnapshot {
27-
hardLimitedPresetMap:=make(map[uuid.UUID]database.GetPresetsAtFailureLimitRow,len(hardLimitedPresets))
28-
for_,preset:=rangehardLimitedPresets {
29-
hardLimitedPresetMap[preset.PresetID]=preset
30-
}
31-
3227
returnGlobalSnapshot{
33-
Presets:presets,
34-
RunningPrebuilds:runningPrebuilds,
35-
PrebuildsInProgress:prebuildsInProgress,
36-
Backoffs:backoffs,
37-
HardLimitedPresetMap:hardLimitedPresetMap,
28+
Presets:presets,
29+
RunningPrebuilds:runningPrebuilds,
30+
PrebuildsInProgress:prebuildsInProgress,
31+
Backoffs:backoffs,
32+
HardLimitedPresets:hardLimitedPresets,
3833
}
3934
}
4035

@@ -65,15 +60,16 @@ func (s GlobalSnapshot) FilterByPreset(presetID uuid.UUID) (*PresetSnapshot, err
6560
backoffPtr=&backoff
6661
}
6762

63+
_,found=slice.Find(s.HardLimitedPresets,func(row database.GetPresetsAtFailureLimitRow)bool {
64+
returnrow.PresetID==preset.ID
65+
})
66+
isHardLimited:=found
67+
6868
return&PresetSnapshot{
69-
Preset:preset,
70-
Running:running,
71-
InProgress:inProgress,
72-
Backoff:backoffPtr,
69+
Preset:preset,
70+
Running:running,
71+
InProgress:inProgress,
72+
Backoff:backoffPtr,
73+
IsHardLimited:isHardLimited,
7374
},nil
7475
}
75-
76-
func (sGlobalSnapshot)IsHardLimited(presetID uuid.UUID)bool {
77-
_,ok:=s.HardLimitedPresetMap[presetID]
78-
returnok
79-
}

‎coderd/prebuilds/preset_snapshot.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ const (
3232
// It contains the raw data needed to calculate the current state of a preset's prebuilds,
3333
// including running prebuilds, in-progress builds, and backoff information.
3434
typePresetSnapshotstruct {
35-
Preset database.GetTemplatePresetsWithPrebuildsRow
36-
Running []database.GetRunningPrebuiltWorkspacesRow
37-
InProgress []database.CountInProgressPrebuildsRow
38-
Backoff*database.GetPresetsBackoffRow
35+
Preset database.GetTemplatePresetsWithPrebuildsRow
36+
Running []database.GetRunningPrebuiltWorkspacesRow
37+
InProgress []database.CountInProgressPrebuildsRow
38+
Backoff*database.GetPresetsBackoffRow
39+
IsHardLimitedbool
3940
}
4041

4142
// ReconciliationState represents the processed state of a preset's prebuilds,

‎enterprise/coderd/prebuilds/reconcile.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,6 @@ 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("preset_id",preset.ID),slog.F("name",preset.Name))
248-
continue
249-
}
250-
251246
ps,err:=snapshot.FilterByPreset(preset.ID)
252247
iferr!=nil {
253248
logger.Warn(ctx,"failed to find preset snapshot",slog.Error(err),slog.F("preset_id",preset.ID.String()))
@@ -345,6 +340,11 @@ func (c *StoreReconciler) ReconcilePreset(ctx context.Context, ps prebuilds.Pres
345340
slog.F("preset_name",ps.Preset.Name),
346341
)
347342

343+
ifps.IsHardLimited {
344+
logger.Debug(ctx,"skipping hard limited preset",slog.F("preset_id",ps.Preset.ID),slog.F("name",ps.Preset.Name))
345+
returnnil
346+
}
347+
348348
state:=ps.CalculateState()
349349
actions,err:=c.CalculateActions(ctx,ps)
350350
iferr!=nil {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp