Skip to content

Commit 2bf6fab

Browse files
🐞TFECO-11466 Add new user interaction status and unit tests (#694)
* TFECO-11466 Add new user interaction status and unit tests * Add change log
1 parent d0a961c commit 2bf6fab

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
kind: BUG FIXES
2+
body: 'PendingRuns: This change fixes the unnecessary agent pods created for pending runs by adding a missing status in the user interaction statuses map'
3+
time: 2026-01-14T20:30:20.800288-08:00
4+
custom:
5+
PR: "694"

internal/controller/agentpool_controller_autoscaling.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var userInteractionRunStatuses = map[tfc.RunStatus]struct{}{
2626
tfc.RunPolicyOverride: {},
2727
tfc.RunPostPlanAwaitingDecision: {},
2828
tfc.RunPostPlanCompleted: {},
29+
tfc.RunPending: {},
2930
}
3031

3132
// matchWildcardName checks if a given string matches a specified wildcard pattern.
@@ -80,6 +81,7 @@ func pendingRuns(ctx context.Context, ap *agentPoolInstance) (int32, error) {
8081
if err != nil {
8182
return 0, err
8283
}
84+
8385
for _, run := range runsList.Items {
8486
// Skip runs that require user interaction
8587
if _, ok := userInteractionRunStatuses[run.Status]; ok {

internal/controller/agentpool_controller_autoscaling_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,30 @@ func TestPendingRuns(t *testing.T) {
126126
expectedCount: 4,
127127
expectError: false,
128128
},
129+
{
130+
name: "plan-only runs that might have a pending status",
131+
mockRuns: []*tfc.Run{
132+
{ID: "run1", PlanOnly: true, Status: tfc.RunPending, Workspace: &tfc.Workspace{ID: "ws2"}},
133+
{ID: "run2", PlanOnly: true, Status: tfc.RunPlanning, Workspace: &tfc.Workspace{ID: "ws2"}},
134+
{ID: "run3", PlanOnly: true, Status: tfc.RunPlanning, Workspace: &tfc.Workspace{ID: "ws2"}},
135+
{ID: "run4", PlanOnly: true, Status: tfc.RunPlanning, Workspace: &tfc.Workspace{ID: "ws2"}},
136+
{ID: "run5", PlanOnly: true, Status: tfc.RunPending, Workspace: &tfc.Workspace{ID: "ws2"}},
137+
},
138+
expectedCount: 3,
139+
expectError: false,
140+
},
141+
{
142+
name: "mix of plan-only and apply runs that might have user interaction statuses",
143+
mockRuns: []*tfc.Run{
144+
{ID: "run1", PlanOnly: true, Status: tfc.RunPlanning, Workspace: &tfc.Workspace{ID: "ws1"}},
145+
{ID: "run2", PlanOnly: false, Status: tfc.RunPlanned, Workspace: &tfc.Workspace{ID: "ws1"}},
146+
{ID: "run3", PlanOnly: true, Status: tfc.RunPending, Workspace: &tfc.Workspace{ID: "ws1"}},
147+
{ID: "run4", PlanOnly: false, Status: tfc.RunCostEstimated, Workspace: &tfc.Workspace{ID: "ws1"}},
148+
{ID: "run5", PlanOnly: false, Status: tfc.RunPending, Workspace: &tfc.Workspace{ID: "ws1"}},
149+
},
150+
expectedCount: 1,
151+
expectError: false,
152+
},
129153
}
130154

131155
for _, tt := range tests {

0 commit comments

Comments
 (0)