Skip to content

Commit 7f0e366

Browse files
Jonathan S. Katzjkatz
authored andcommitted
Safely error if "pgo df" does not find any clusters
In this case previously, "pgo df" would actually time out and return an error that read like a Go debug message. Issue: [ch9202]
1 parent 3f5d2e4 commit 7f0e366

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

docs/content/releases/4.5.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ To remove an annotation, one follows the format:
143143
- The pgBackRest URI style defaults to `host` if it is not set.
144144
- pgBackRest commands can now be executed even if there are multiple pgBackRest Pods available in a Deployment, so long as there is only one "running" pgBackRest Pod.
145145
- Ensure pgBackRest S3 Secrets can be upgraded from PostgreSQL Operator 4.3.
146+
- Return an error if a cluster is not found when using `pgo df` instead of timing out.
146147
- pgBadger now has a default memory limit of 64Mi, which should help avoid a visit from the OOM killer.
147148
- Fix `pgo label` when applying multiple labels at once.
148149
- Fix `pgo create pgorole` so that the expression `--permissions=*` works.

internal/apiserver/dfservice/dfimpl.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,18 @@ func DfCluster(request msgs.DfRequest) msgs.DfResponse {
5757
return CreateErrorResponse(err.Error())
5858
}
5959

60-
log.Debugf("df clusters found len is %d", len(clusterList.Items))
60+
totalClusters := len(clusterList.Items)
61+
62+
log.Debugf("df clusters found len is %d", totalClusters)
63+
64+
// if there are no clusters found, exit early
65+
if totalClusters == 0 {
66+
response.Status = msgs.Status{
67+
Code: msgs.Error,
68+
Msg: fmt.Sprintf("no clusters found for selector %q in namespace %q", selector, namespace),
69+
}
70+
return response
71+
}
6172

6273
// iterate through each cluster and get the information about the disk
6374
// utilization. As there could be a lot of clusters doing this, we opt for
@@ -76,7 +87,6 @@ func DfCluster(request msgs.DfRequest) msgs.DfResponse {
7687

7788
// track the progress / completion, so we know when to exit
7889
processed := 0
79-
totalClusters := len(clusterList.Items)
8090

8191
loop:
8292
for {

0 commit comments

Comments
 (0)