- Notifications
You must be signed in to change notification settings - Fork1.1k
feat: add filtering options to provisioners list#19378
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
brettkolodny commentedAug 20, 2025
@rafrdz Going to take a look no! For the chromatic tests we typically self check those to make sure we didn't accidentally introduce some glaring UI bug. So you can go through those yourself when you have a chance, but feel free to ping me if you're having issues on that front |
brettkolodny left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Just a few small changes on the TS side. The backend changes look good to me but@Emyrk may want to take another look as well
...s/OrganizationSettingsPage/OrganizationProvisionersPage/OrganizationProvisionersPageView.tsx OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...pages/OrganizationSettingsPage/OrganizationProvisionersPage/OrganizationProvisionersPage.tsx OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...pages/OrganizationSettingsPage/OrganizationProvisionersPage/OrganizationProvisionersPage.tsx OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...pages/OrganizationSettingsPage/OrganizationProvisionersPage/OrganizationProvisionersPage.tsx OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...pages/OrganizationSettingsPage/OrganizationProvisionersPage/OrganizationProvisionersPage.tsx OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Emyrk left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
backend 👍
| AND ( | ||
| sqlc.narg('max_age_ms')::bigint ISNULL | ||
| ORpd.last_seen_at ISNULL | ||
| ORpd.last_seen_at>= (NOW()- (sqlc.narg('max_age_ms')::bigint||' ms')::interval) | ||
| ) | ||
| AND ( | ||
| -- Always include online daemons | ||
| (pd.last_seen_atIS NOT NULLANDpd.last_seen_at>= (NOW()- (@stale_interval_ms::bigint||' ms')::interval)) | ||
| -- Include offline daemons if offline param is true or 'offline' status is requested | ||
| OR ( | ||
| (pd.last_seen_at ISNULLORpd.last_seen_at< (NOW()- (@stale_interval_ms::bigint||' ms')::interval)) | ||
| AND ( | ||
| COALESCE(sqlc.narg('offline')::bool, false)= true | ||
| OR'offline'::provisioner_daemon_status= ANY(@statuses::provisioner_daemon_status[]) | ||
| ) | ||
| ) | ||
| ) | ||
| AND ( | ||
| -- Filter daemons by any statuses if provided | ||
| COALESCE(array_length(@statuses::provisioner_daemon_status[],1),0)=0 | ||
| OR (current_job.idIS NOT NULLAND'busy'::provisioner_daemon_status= ANY(@statuses::provisioner_daemon_status[])) | ||
| OR (current_job.id ISNULLAND'idle'::provisioner_daemon_status= ANY(@statuses::provisioner_daemon_status[])) | ||
| OR ( | ||
| 'offline'::provisioner_daemon_status= ANY(@statuses::provisioner_daemon_status[]) | ||
| AND (pd.last_seen_at ISNULLORpd.last_seen_at< (NOW()- (@stale_interval_ms::bigint||' ms')::interval)) | ||
| ) | ||
| OR ( | ||
| COALESCE(sqlc.narg('offline')::bool, false)= true | ||
| AND (pd.last_seen_at ISNULLORpd.last_seen_at< (NOW()- (@stale_interval_ms::bigint||' ms')::interval)) | ||
| ) | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We usually doCASE ... WHEN, but this works
| // Package sdk2db provides common conversion routines from codersdk types to database types | ||
| package sdk2db | ||
| import ( | ||
| "github.com/coder/coder/v2/coderd/database" | ||
| "github.com/coder/coder/v2/coderd/database/db2sdk" | ||
| "github.com/coder/coder/v2/codersdk" | ||
| ) | ||
| funcProvisionerDaemonStatus(status codersdk.ProvisionerDaemonStatus) database.ProvisionerDaemonStatus { | ||
| returndatabase.ProvisionerDaemonStatus(status) | ||
| } | ||
| funcProvisionerDaemonStatuses(params []codersdk.ProvisionerDaemonStatus) []database.ProvisionerDaemonStatus { | ||
| returndb2sdk.List(params,ProvisionerDaemonStatus) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
👍
I bet we can move some things here later
aslilac left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
frontend code looks good!
ad5e678 intomainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Summary
In this pull request we're adding support for additional filtering options to the
provisioners listCLI command and the/provisionerdaemonsAPI endpoint.Resolves:#18783
Changes
Added CLI Options
--show-offline: When this option is provided, all provisioner daemons will be returned. This means that when--show-offlineis not provided onlyidleandbusyprovisioner daemons will be returned.--status=<list_of_statuses>: When this option is provided with a comma-separated list of valid statuses (idle,busy, oroffline) only provisioner daemons that have these statuses will be returned.--max-age=<duration>: When this option is provided with a valid duration value (e.g.,24h,30s) only provisioner daemons with alast_seen_attimestamp within the provided max age will be returned.Query Params
?offline=true: Include offline provisioner daemons in the results. Offline provisioner daemons will be excluded if?offline=falseor if offline is not provided.?status=<list_of_statuses>: Include provisioner daemons with the specified statuses.?max_age=<duration>: Include provisioner daemons with alast_seen_attimestamp within the max age duration.Frontend
--show-offlinehas to be provided to see them), a checkbox was added to the provisioners list page to allow for offline provisioners to be displayedCurrent provisioners page (without checkbox)
Provisioners page with checkbox (unchecked)
Provisioner page with checkbox (checked) and URL updated with query parameters
Show Offline vs Offline Status
To list offline provisioner daemons, users can either:
--show-offlineoptionOR
offlinein the list of values provided to the--statusoption