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

Commit975358c

Browse files
minor fixes
1 parentf7d3634 commit975358c

File tree

2 files changed

+17
-49
lines changed

2 files changed

+17
-49
lines changed

‎coderd/prebuilds/global_snapshot.go‎

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import (
1212

1313
// GlobalSnapshot represents a full point-in-time snapshot of state relating to prebuilds across all templates.
1414
typeGlobalSnapshotstruct {
15-
Presets []database.GetTemplatePresetsWithPrebuildsRow
16-
RunningPrebuilds []database.GetRunningPrebuiltWorkspacesRow
17-
PrebuildsInProgress []database.CountInProgressPrebuildsRow
18-
Backoffs []database.GetPresetsBackoffRow
19-
HardLimitedPresets []database.GetPresetsAtFailureLimitRow
15+
Presets[]database.GetTemplatePresetsWithPrebuildsRow
16+
RunningPrebuilds[]database.GetRunningPrebuiltWorkspacesRow
17+
PrebuildsInProgress[]database.CountInProgressPrebuildsRow
18+
Backoffs[]database.GetPresetsBackoffRow
19+
HardLimitedPresetsMapmap[uuid.UUID]database.GetPresetsAtFailureLimitRow
2020
}
2121

2222
funcNewGlobalSnapshot(
@@ -26,12 +26,17 @@ func NewGlobalSnapshot(
2626
backoffs []database.GetPresetsBackoffRow,
2727
hardLimitedPresets []database.GetPresetsAtFailureLimitRow,
2828
)GlobalSnapshot {
29+
hardLimitedPresetsMap:=make(map[uuid.UUID]database.GetPresetsAtFailureLimitRow,len(hardLimitedPresets))
30+
for_,preset:=rangehardLimitedPresets {
31+
hardLimitedPresetsMap[preset.PresetID]=preset
32+
}
33+
2934
returnGlobalSnapshot{
30-
Presets:presets,
31-
RunningPrebuilds:runningPrebuilds,
32-
PrebuildsInProgress:prebuildsInProgress,
33-
Backoffs:backoffs,
34-
HardLimitedPresets:hardLimitedPresets,
35+
Presets:presets,
36+
RunningPrebuilds:runningPrebuilds,
37+
PrebuildsInProgress:prebuildsInProgress,
38+
Backoffs:backoffs,
39+
HardLimitedPresetsMap:hardLimitedPresetsMap,
3540
}
3641
}
3742

@@ -66,9 +71,7 @@ func (s GlobalSnapshot) FilterByPreset(presetID uuid.UUID) (*PresetSnapshot, err
6671
backoffPtr=&backoff
6772
}
6873

69-
_,isHardLimited:=slice.Find(s.HardLimitedPresets,func(row database.GetPresetsAtFailureLimitRow)bool {
70-
returnrow.PresetID==preset.ID
71-
})
74+
_,isHardLimited:=s.HardLimitedPresetsMap[preset.ID]
7275

7376
return&PresetSnapshot{
7477
Preset:preset,
@@ -81,9 +84,7 @@ func (s GlobalSnapshot) FilterByPreset(presetID uuid.UUID) (*PresetSnapshot, err
8184
}
8285

8386
func (sGlobalSnapshot)IsHardLimited(presetID uuid.UUID)bool {
84-
_,isHardLimited:=slice.Find(s.HardLimitedPresets,func(row database.GetPresetsAtFailureLimitRow)bool {
85-
returnrow.PresetID==presetID
86-
})
87+
_,isHardLimited:=s.HardLimitedPresetsMap[presetID]
8788

8889
returnisHardLimited
8990
}

‎enterprise/coderd/prebuilds/reconcile.go‎

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -299,21 +299,6 @@ func (c *StoreReconciler) ReconcileAll(ctx context.Context) error {
299299
returnerr
300300
}
301301

302-
// Report a metric only if the preset uses the latest version of the template and the template is not deleted.
303-
// This avoids conflicts between metrics from old and new template versions.
304-
//
305-
// NOTE: Multiple versions of a preset can exist with the same orgName, templateName, and presetName,
306-
// because templates can have multiple versions — or deleted templates can share the same name.
307-
//
308-
// The safest approach is to report the metric only for the latest version of the preset.
309-
// When a new template version is released, the metric for the new preset should overwrite
310-
// the old value in Prometheus.
311-
//
312-
// However, there’s one edge case: if an admin creates a template, it becomes hard-limited,
313-
// then deletes the template and never creates another with the same name,
314-
// the old preset will continue to be reported as hard-limited —
315-
// even though it’s deleted. This will persist until `coderd` is restarted.
316-
317302
func (c*StoreReconciler)reportHardLimitedPresets(snapshot*prebuilds.GlobalSnapshot) {
318303
// presetsMap is a map from key (orgName:templateName:presetName) to list of corresponding presets.
319304
// Multiple versions of a preset can exist with the same orgName, templateName, and presetName,
@@ -414,24 +399,6 @@ func (c *StoreReconciler) ReconcilePreset(ctx context.Context, ps prebuilds.Pres
414399
slog.F("preset_name",ps.Preset.Name),
415400
)
416401

417-
// Report a metric only if the preset uses the latest version of the template and the template is not deleted.
418-
// This avoids conflicts between metrics from old and new template versions.
419-
//
420-
// NOTE: Multiple versions of a preset can exist with the same orgName, templateName, and presetName,
421-
// because templates can have multiple versions — or deleted templates can share the same name.
422-
//
423-
// The safest approach is to report the metric only for the latest version of the preset.
424-
// When a new template version is released, the metric for the new preset should overwrite
425-
// the old value in Prometheus.
426-
//
427-
// However, there’s one edge case: if an admin creates a template, it becomes hard-limited,
428-
// then deletes the template and never creates another with the same name,
429-
// the old preset will continue to be reported as hard-limited —
430-
// even though it’s deleted. This will persist until `coderd` is restarted.
431-
//if ps.Preset.UsingActiveVersion && !ps.Preset.Deleted {
432-
//c.metrics.trackHardLimitedStatus(ps.Preset.OrganizationName, ps.Preset.TemplateName, ps.Preset.Name, ps.IsHardLimited)
433-
//}
434-
435402
// If the preset reached the hard failure limit for the first time during this iteration:
436403
// - Mark it as hard-limited in the database
437404
// - Send notifications to template admins

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp