fix(cli,support,scaletest): terminate workspace paging on server count - #28027
Closed
jscottmiller wants to merge 2 commits into
Closed
fix(cli,support,scaletest): terminate workspace paging on server count#28027jscottmiller wants to merge 2 commits into
jscottmiller wants to merge 2 commits into
Conversation
The workspaces endpoint applies its limit in SQL and then drops rows whose build or template the caller cannot read, so a page can be shorter than the requested limit without the result set being exhausted. Terminating on a short page truncated the results, and advancing the offset by the number of rows returned re-requested rows that had already been collected. Each loop now advances the offset by the requested page size and stops once it reaches the total the response reports.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
convertWorkspacesincoderd/workspaces.godrops rows whose build or templatethe caller cannot read, but
/api/v2/workspacesapplies its limit in SQL andreports
Countfrom before the limit and offset. A page can therefore be shorterthan the requested limit while rows remain.
Five paging loops assumed the opposite. Four stopped on a short or fully filtered
page and truncated their results;
support/support.goalso advanced the offset bythe number of rows returned, re-requesting rows it had already collected. Each loop
now advances the offset by the requested page size and stops once it reaches
Count.support/support.gocli/configssh.go(--no-wildcard)cli/exp_scaletest.go(getScaletestPrebuildWorkspaces,getScaletestWorkspaces)scaletest/prebuilds/run.go(allWorkspacesForTemplate)convertWorkspacesalso now warns with the dropped count split by reason. Thediscrepancy was previously invisible: nothing logged it, and no response field
distinguished a filtered page from an exhausted one.
Testing
make pre-commitgo test ./support/ -run TestRungo test ./cli/ -run TestConfigSSHReachable drop paths
workspaceDatafetches builds and app statuses asAsSystemRestricted, and aworkspace and its first build are inserted in one transaction, so a missing build
is not reachable in practice. Templates come from
GetTemplatesWithFilter, whichis authz-filtered and hardcodes
deleted = false, giving two real causes:deleteTemplatepermitsdeletion when only prebuild workspaces remain and defers cleanup to the
reconciler, so for that window a deployment-wide listing counts prebuilds that
conversion then drops.
template.read, somember access comes from the default everyone-group ACL. Disabling that access,
editing the ACL, removing a user from a group, or sharing a workspace with a user
who lacks template access strands existing workspaces permanently.
A single dropped row anywhere before the last page was enough to truncate the rest,
so the impact does not scale with the number of unreadable rows. It requires the
caller's authorized set to exceed the page size: 100 for
config-ssh, 200 forsupport bundle.This pull request was created by Coder Agents on behalf of @jscottmiller.