Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: properly determine running workspaces count #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
ethanndickson merged 1 commit into main from ethan/fix-running-workspaces-count
Sep 9, 2025

Conversation

Copy link
Member

@ethanndickson ethanndickson commented Sep 9, 2025
edited
Loading

Part of the previous query didn't make sense and was completely wrong (though it is admittedly confusing). Here's part of the DB query for retrieving running workspaces:

-- Special case where the provisioner status and workspace status
-- differ. A workspace is "running" if the job is "succeeded" and
-- the transition is "start". This is because a workspace starts
-- running when a job is complete.
WHEN 4ドル = 'running' THEN
 latest_build.job_status = 'succeeded'::provisioner_job_status AND
 latest_build.transition = 'start'::workspace_transition

This new promql query follows this logic, but also uses a max by to handle duplicate metrics from multiple coder replicas:

 count(kube_pod_status_ready{condition="true", namespace=`coder-workspaces`} == 1)
 or
-count(coderd_api_workspace_latest_build{status="running"})
+sum(max by (workspace_owner, template_name, template_version) (coderd_workspace_latest_build_status{status="succeeded", workspace_transition="start"}))
 or
 vector(0)

Tested on dogfood and on my scaletest cluster.

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ethanndickson ethanndickson force-pushed the ethan/fix-running-workspaces-count branch from 06a34d9 to 97edcfc Compare September 9, 2025 04:19
@ethanndickson ethanndickson force-pushed the ethan/fix-running-workspaces-count branch from 97edcfc to 7e99438 Compare September 9, 2025 06:32
@ethanndickson ethanndickson changed the title (削除) fix: use succeeded provisioner jobs when determining running workspace count (削除ここまで) (追記) fix: properly determining running workspaces count (追記ここまで) Sep 9, 2025
@ethanndickson ethanndickson marked this pull request as ready for review September 9, 2025 06:40
@ethanndickson ethanndickson changed the title (削除) fix: properly determining running workspaces count (削除ここまで) (追記) fix: properly determine running workspaces count (追記ここまで) Sep 9, 2025
Copy link
Collaborator

@dannykopping dannykopping left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks!
Can you cut a patch release pls? https://github.com/coder/observability/blob/main/PUBLISH.md

ethanndickson reacted with thumbs up emoji
@ethanndickson ethanndickson merged commit 54cc333 into main Sep 9, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@dannykopping dannykopping dannykopping approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /