Skip to content

Commit e1e8bb8

Browse files
authored
Fix postgrescluster list (#94)
Bug: postgrescluster listing would cause support export to fail fatally. This updates that to behave like our other K8s resouce-retrievals, i.e., fail gracefully by surfacing the error but continue. Issue: [PGO-821]
1 parent 3d1b0db commit e1e8bb8

File tree

7 files changed

+79
-5
lines changed

7 files changed

+79
-5
lines changed

docs/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ defaultContentLanguageInSubdir= false
1515
enableMissingTranslationPlaceholders = false
1616

1717
[params]
18-
clientVersion = "0.4.0"
18+
clientVersion = "0.4.1"
1919

2020
# crunchy-hugo-theme params
2121
editURL = "https://github.com/CrunchyData/postgres-operator/edit/master/docs/content/"

docs/content/reference/pgo_support_export.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ PostgresCluster.
3434
services [list]
3535
statefulsets.apps [list]
3636

37-
Note: This RBAC needs to be cluster-scoped to retrieve information on nodes.
37+
Note: This RBAC needs to be cluster-scoped to retrieve information on nodes and postgresclusters.
3838

3939
### Event Capture
4040
Support export captures all Events in the PostgresCluster's Namespace.

docs/content/reference/pgo_version.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pgo version
3131
```
3232
### Example output
3333
```
34-
Client Version: v0.4.0
34+
Client Version: v0.4.1
3535
Operator Version: v5.5.0
3636
```
3737

docs/content/releases/0.4.1.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: "0.4.1"
3+
draft: false
4+
weight: 996
5+
---
6+
7+
[Crunchy Postgres for Kubernetes]: https://www.crunchydata.com/products/crunchy-postgresql-for-kubernetes
8+
[`pgo` CLI documentation]: https://access.crunchydata.com/documentation/postgres-operator-client/latest
9+
10+
Crunchy Data announces the release of `pgo`, Postgres Operator Client from Crunchy Data 0.4.1.
11+
12+
Built as a `kubectl` plugin, the `pgo` CLI facilitates the creation and management of PostgreSQL clusters created using [Crunchy Postgres for Kubernetes][].
13+
14+
For more information about using the CLI and the various commands available, please see the [`pgo` CLI documentation][].
15+
16+
Additionally, please see the [CPK documentation](https://access.crunchydata.com/documentation/postgres-operator/latest) for information about [getting started](https://access.crunchydata.com/documentation/postgres-operator/latest/quickstart/) with Crunchy Postgres for Kubernetes.
17+
18+
## Bug
19+
- The `support export` command would fail fatally if the user didn't have permissions to list postgresclusters at the cluster-scope. This release fixes that so our postgrescluster list fails gracefully (like our other atttempts to gather Kubernetes resources).

internal/cmd/client_version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
package cmd
1616

1717
// store the current PGO CLI version
18-
const clientVersion = "v0.4.0"
18+
const clientVersion = "v0.4.1"

internal/cmd/export.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ PostgresCluster.
180180
services [list]
181181
statefulsets.apps [list]
182182
183-
Note: This RBAC needs to be cluster-scoped to retrieve information on nodes.
183+
Note: This RBAC needs to be cluster-scoped to retrieve information on nodes and postgresclusters.
184184
185185
### Event Capture
186186
Support export captures all Events in the PostgresCluster's Namespace.
@@ -529,6 +529,10 @@ func gatherPostgresClusterNames(clusterName string, ctx context.Context, cmd *co
529529
result, err := client.List(ctx, metav1.ListOptions{})
530530

531531
if err != nil {
532+
if apierrors.IsForbidden(err) {
533+
writeInfo(cmd, err.Error())
534+
return nil
535+
}
532536
return err
533537
}
534538

internal/cmd/export.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
## The support export command
2+
3+
### What is it for?
4+
5+
The `support export` command is meant to give users a simple command to run that will produce a tar file of information that they can then use to debug or send to Crunchy Data to debug.
6+
7+
### What are its invariants?
8+
9+
#### Only work on one cluster at a time
10+
11+
If the cluster doesn't exist, exit without creating a tar.
12+
13+
#### Fail gracefully when forbidden from retrieving K8s API info
14+
15+
If we run into an error getting info for part X, move on to part Y, Z, et al. _while_ also surfacing the error.
16+
17+
### What does it do (in order)?
18+
19+
* Check postgrescluster exists (fail hard)
20+
* Create output tar file & defer close
21+
* Gather CLI version (from code)
22+
* Get all postgrescluster names
23+
* Get Kubernetes context (fail hard)
24+
* Get server version (fail hard)
25+
* Gather node info
26+
* Gather namespace info
27+
* Write cluster spec (gotten in step 1)
28+
* Gather namespaced resources for cluster:
29+
* statefulsets
30+
* deployments
31+
* replicasets
32+
* jobs
33+
* cronjobs
34+
* poddisruptionbudgets
35+
* pods
36+
* persistentvolumeclaims
37+
* configmaps
38+
* services
39+
* endpoints
40+
* serviceaccounts
41+
* ingresses
42+
* limitranges
43+
* Gather events
44+
* Gather logs
45+
* Gather postgresql logs
46+
* Get monitoring logs
47+
* Gather patroni info
48+
* Gather pgBackRest info
49+
* Gather process info
50+
* Gather system time
51+
* Gather list of kubectl plugins

0 commit comments

Comments
 (0)