Skip to content

Commit 183146e

Browse files
fix: add minor fix to reconciliation loop (#17454)
Follow-up PR to #17261 I noticed that 1 metrics-related test fails in `dk/prebuilds` after merging my PR into `dk/prebuilds`.
1 parent 144c60d commit 183146e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

coderd/prebuilds/preset_snapshot.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ func (p PresetSnapshot) CalculateState() *ReconciliationState {
9191
extraneous int32
9292
)
9393

94+
// #nosec G115 - Safe conversion as p.Running slice length is expected to be within int32 range
95+
actual = int32(len(p.Running))
96+
9497
if p.isActive() {
95-
// #nosec G115 - Safe conversion as p.Running slice length is expected to be within int32 range
96-
actual = int32(len(p.Running))
9798
desired = p.Preset.DesiredInstances.Int32
9899
eligible = p.countEligible()
99100
extraneous = max(actual-desired, 0)

coderd/prebuilds/preset_snapshot_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ func TestOutdatedPrebuilds(t *testing.T) {
146146
state := ps.CalculateState()
147147
actions, err := ps.CalculateActions(clock, backoffInterval)
148148
require.NoError(t, err)
149-
validateState(t, prebuilds.ReconciliationState{}, *state)
149+
validateState(t, prebuilds.ReconciliationState{
150+
Actual: 1,
151+
}, *state)
150152
validateActions(t, prebuilds.ReconciliationActions{
151153
ActionType: prebuilds.ActionTypeDelete,
152154
DeleteIDs: []uuid.UUID{outdated.prebuiltWorkspaceID},
@@ -208,6 +210,7 @@ func TestDeleteOutdatedPrebuilds(t *testing.T) {
208210
actions, err := ps.CalculateActions(clock, backoffInterval)
209211
require.NoError(t, err)
210212
validateState(t, prebuilds.ReconciliationState{
213+
Actual: 1,
211214
Deleting: 1,
212215
}, *state)
213216

@@ -530,7 +533,9 @@ func TestDeprecated(t *testing.T) {
530533
state := ps.CalculateState()
531534
actions, err := ps.CalculateActions(clock, backoffInterval)
532535
require.NoError(t, err)
533-
validateState(t, prebuilds.ReconciliationState{}, *state)
536+
validateState(t, prebuilds.ReconciliationState{
537+
Actual: 1,
538+
}, *state)
534539
validateActions(t, prebuilds.ReconciliationActions{
535540
ActionType: prebuilds.ActionTypeDelete,
536541
DeleteIDs: []uuid.UUID{current.prebuiltWorkspaceID},

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy