Skip to content

Commit 80c89fe

Browse files
refactor: CR's fixes
1 parent 3100e01 commit 80c89fe

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

enterprise/coderd/prebuilds/metricscollector.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,5 +286,9 @@ func (mc *MetricsCollector) trackHardLimitedStatus(orgName, templateName, preset
286286

287287
key := hardLimitedPresetKey{orgName: orgName, templateName: templateName, presetName: presetName}
288288

289-
mc.isPresetHardLimited[key] = isHardLimited
289+
if isHardLimited {
290+
mc.isPresetHardLimited[key] = true
291+
} else {
292+
delete(mc.isPresetHardLimited, key)
293+
}
290294
}

enterprise/coderd/prebuilds/reconcile_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,17 +1036,15 @@ func TestHardLimitedPresetShouldNotBlockDeletion(t *testing.T) {
10361036
require.Equal(t, database.WorkspaceTransitionDelete, workspaceBuilds[0].Transition)
10371037
require.Equal(t, database.WorkspaceTransitionStart, workspaceBuilds[1].Transition)
10381038

1039-
// Metric is reset to zero after preset became outdated.
1039+
// Metric is deleted after preset became outdated.
10401040
mf, err = registry.Gather()
10411041
require.NoError(t, err)
10421042
metric = findMetric(mf, prebuilds.MetricPresetHardLimitedGauge, map[string]string{
10431043
"template_name": template.Name,
10441044
"preset_name": preset.Name,
10451045
"org_name": org.Name,
10461046
})
1047-
require.NotNil(t, metric)
1048-
require.NotNil(t, metric.GetGauge())
1049-
require.EqualValues(t, 0, metric.GetGauge().GetValue())
1047+
require.Nil(t, metric)
10501048
})
10511049
}
10521050
}

0 commit comments

Comments
 (0)