mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
fix: add minor fix to reconciliation loop (#17454)
Follow-up PR to https://github.com/coder/coder/pull/17261 I noticed that 1 metrics-related test fails in `dk/prebuilds` after merging my PR into `dk/prebuilds`.
This commit is contained in:
committed by
GitHub
parent
144c60dd87
commit
183146e2c9
@@ -91,9 +91,10 @@ func (p PresetSnapshot) CalculateState() *ReconciliationState {
|
||||
extraneous int32
|
||||
)
|
||||
|
||||
// #nosec G115 - Safe conversion as p.Running slice length is expected to be within int32 range
|
||||
actual = int32(len(p.Running))
|
||||
|
||||
if p.isActive() {
|
||||
// #nosec G115 - Safe conversion as p.Running slice length is expected to be within int32 range
|
||||
actual = int32(len(p.Running))
|
||||
desired = p.Preset.DesiredInstances.Int32
|
||||
eligible = p.countEligible()
|
||||
extraneous = max(actual-desired, 0)
|
||||
|
||||
@@ -146,7 +146,9 @@ func TestOutdatedPrebuilds(t *testing.T) {
|
||||
state := ps.CalculateState()
|
||||
actions, err := ps.CalculateActions(clock, backoffInterval)
|
||||
require.NoError(t, err)
|
||||
validateState(t, prebuilds.ReconciliationState{}, *state)
|
||||
validateState(t, prebuilds.ReconciliationState{
|
||||
Actual: 1,
|
||||
}, *state)
|
||||
validateActions(t, prebuilds.ReconciliationActions{
|
||||
ActionType: prebuilds.ActionTypeDelete,
|
||||
DeleteIDs: []uuid.UUID{outdated.prebuiltWorkspaceID},
|
||||
@@ -208,6 +210,7 @@ func TestDeleteOutdatedPrebuilds(t *testing.T) {
|
||||
actions, err := ps.CalculateActions(clock, backoffInterval)
|
||||
require.NoError(t, err)
|
||||
validateState(t, prebuilds.ReconciliationState{
|
||||
Actual: 1,
|
||||
Deleting: 1,
|
||||
}, *state)
|
||||
|
||||
@@ -530,7 +533,9 @@ func TestDeprecated(t *testing.T) {
|
||||
state := ps.CalculateState()
|
||||
actions, err := ps.CalculateActions(clock, backoffInterval)
|
||||
require.NoError(t, err)
|
||||
validateState(t, prebuilds.ReconciliationState{}, *state)
|
||||
validateState(t, prebuilds.ReconciliationState{
|
||||
Actual: 1,
|
||||
}, *state)
|
||||
validateActions(t, prebuilds.ReconciliationActions{
|
||||
ActionType: prebuilds.ActionTypeDelete,
|
||||
DeleteIDs: []uuid.UUID{current.prebuiltWorkspaceID},
|
||||
|
||||
Reference in New Issue
Block a user