Skip to content

Commit ff97909

Browse files
committed
Accurate event recording by support export
This update corrects the current behavior of the support export command's event capture, adds relevant Kuttl checks and documents Kubernetes Event storage duration. Issue: [sc-17993]
1 parent 189b265 commit ff97909

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

docs/content/reference/pgo_support_export.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ PostgresCluster.
3434

3535
Note: This RBAC needs to be cluster-scoped to retrieve information on nodes.
3636

37+
#### Event Capture
38+
Support export captures all Events in the PostgresCluster's Namespace.
39+
Event duration is determined by the '--event-ttl' setting of the Kubernetes
40+
API server. Default is 1 hour.
41+
- https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/
42+
3743
```
3844
pgo support export CLUSTER_NAME [flags]
3945
```

internal/cmd/export.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,13 @@ PostgresCluster.
134134
services [get list]
135135
statefulsets.apps [get list]
136136
137-
Note: This RBAC needs to be cluster-scoped to retrieve information on nodes.`,
137+
Note: This RBAC needs to be cluster-scoped to retrieve information on nodes.
138+
139+
#### Event Capture
140+
Support export captures all Events in the PostgresCluster's Namespace.
141+
Event duration is determined by the '--event-ttl' setting of the Kubernetes
142+
API server. Default is 1 hour.
143+
- https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/`,
138144
}
139145

140146
// Set output to log and write to buffer for writing to file
@@ -616,6 +622,9 @@ func gatherEvents(ctx context.Context,
616622
strings.TrimSpace(event.Message),
617623
)
618624
}
625+
if err := p.Flush(); err != nil {
626+
return err
627+
}
619628

620629
path := clusterName + "/events"
621630
if err := writeTar(tw, buf.Bytes(), path, cmd); err != nil {

testing/kuttl/e2e/support-export/01--support_export.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,22 @@ commands:
3232
exit 1
3333
fi
3434
35+
# check that the events file exist and is not empty
36+
EVENTS="./kuttl-support-cluster/events"
37+
38+
if [[ ! -s $EVENTS ]]
39+
then
40+
echo "Expected Events file to not be empty"
41+
eval "$CLEANUP"
42+
exit 1
43+
fi
44+
45+
# check that the events file contains the expected string
46+
if ! grep -Fq "Created container postgres-startup" $EVENTS
47+
then
48+
echo "Events file does not contain expected string"
49+
eval "$CLEANUP"
50+
exit 1
51+
fi
52+
3553
- script: rm -r ./kuttl-support-cluster ./crunchy_k8s_support_export_*.tar

0 commit comments

Comments
 (0)