src-cli
src-cli copied to clipboard
Improve performance of `src users clean` in instances with many users
In instances with many users the graphQL request to get all users and compute their lastActiveUsage
can timeout going over the network --
In the example below the command is used on an instance with 29 users, then pointed at an instance with 186, this shows an example of the failure.
warrengifford@Warrens-MacBook-Pro ~ % src users clean
Users to remove from instance at https://cse-k8s.sgdev.org
╭───────────────────┬──────────────────────────────────┬────────────────────────╮
│ USERNAME │ EMAIL │ DAYS SINCE LAST ACTIVE │
├───────────────────┼──────────────────────────────────┼────────────────────────┤
│ sourcegraph │ [email protected] │ 302 │
├───────────────────┼──────────────────────────────────┼────────────────────────┤
│ g-bot │ [email protected] │ 282 │
├───────────────────┼──────────────────────────────────┼────────────────────────┤
│ testAtSourcegraph │ [email protected] │ 253 │
├───────────────────┼──────────────────────────────────┼────────────────────────┤
│ Malo │ [email protected] │ 221 │
├───────────────────┼──────────────────────────────────┼────────────────────────┤
│ ErikSeliger │ [email protected] │ 191 │
├───────────────────┼──────────────────────────────────┼────────────────────────┤
│ support │ │ 132 │
├───────────────────┼──────────────────────────────────┼────────────────────────┤
│ gab2 │ │ 64 │
╰───────────────────┴──────────────────────────────────┴────────────────────────╯
Do you wish to proceed with user removal [y/N]: n
Aborting removal
warrengifford@Warrens-MacBook-Pro ~ % vim ~/.zshrc
warrengifford@Warrens-MacBook-Pro ~ % source ~/.zshrc
warrengifford@Warrens-MacBook-Pro ~ % src login
✔️ Authenticated as warren on https://k8s.sgdev.org
warrengifford@Warrens-MacBook-Pro ~ % src users clean
error: 504 Gateway Timeout
<html>
<head><title>504 Gateway Time-out</title></head>
<body>
<center><h1>504 Gateway Time-out</h1></center>
<hr><center>nginx</center>
</body>
</html>
This problem was foreseen in the original release PR by @mrnugget
Since then @mrnugget has added a new graphQL field that should improve performance here, and users clean
needs to be rewritten to incorperate this more efficient query https://github.com/sourcegraph/sourcegraph/pull/42352/files