@@ -74,7 +74,7 @@ func pendingWorkspaceRuns(ctx context.Context, ap *agentPoolInstance) (int32, er
7474 PageNumber : initPageNumber ,
7575 },
7676 }
77-
77+ runCount := 0
7878 for {
7979 runsList , err := ap .tfClient .Client .Runs .ListForOrganization (ctx , ap .instance .Spec .Organization , listOpts )
8080 if err != nil {
@@ -87,6 +87,10 @@ func pendingWorkspaceRuns(ctx context.Context, ap *agentPoolInstance) (int32, er
8787 awaitingUserInteractionRuns [string (run .Status )]++
8888 continue
8989 }
90+ if _ , exists := runs [run .Workspace .ID ]; exists && run .PlanOnly {
91+ runCount ++
92+ continue
93+ }
9094 runs [run .Workspace .ID ] = struct {}{}
9195 }
9296 if runsList .NextPage == 0 {
@@ -97,8 +101,10 @@ func pendingWorkspaceRuns(ctx context.Context, ap *agentPoolInstance) (int32, er
97101
98102 // TODO:
99103 // Add metric(s) for runs awaiting user interaction
100-
101- return int32 (len (runs )), nil
104+ ap .log .Info ("Runs" , "msg" , fmt .Sprintf ("Runs: %+v" , runs ))
105+ ap .log .Info ("Run count" , "msg" , fmt .Sprintf ("RunCount: %+v" , runCount ))
106+ runCount = len (runs ) + runCount
107+ return int32 (runCount ), nil
102108}
103109
104110// computeRequiredAgents is a legacy algorithm that is used to compute the number of agents needed.
0 commit comments