Repository navigation
Closed as not planned
Closed as not planned
Copy link
Description
Is there an existing issue already for this feature request/idea?
- I have searched for an existing issue, and could not find anything. I believe this is a new feature request to be evaluated.
What problem is this feature going to solve? Why should it be added?
I would like to add the ability to debug why an out-of-disk situation occurs and resolve it.
Describe the solution you'd like
- By default, instead of exiting immediately, postgres starts in single-user mode and dumps stats about orphaned base files, replication slots, wal files, etc so we have information to debug the conditions that caused the out-of-space situation.
kubectl cnpg recoverycommand that automates starting up a pod in single user mode to debug the situation (I'm working on a temporary bash version of that here: https://gist.github.com/jmealo/ef191db24ee94edf3d71b3b1d63ad755)
I'm not sure if we can do both as one may conflict with the other :) It's possible that we only need to record the debug information once, and then we can go back into the crash loop.
Describe alternatives you've considered
You can manually create a pod that runs on the same node and mount the volumes manually. You can use a different image, or the same, but you need to change the entry point.
We could add a kubectl cnpg command to automate this process?
apiVersion: v1
kind: Pod
metadata:
name: production-pg-etl-1-debug
namespace: db
spec:
nodeName: <same-node-as-original-pod> # Force it to the same node
containers:
- name: debug
image: ubuntu:latest
command: ["sleep", "infinity"]
resources:
requests:
memory: "100Mi"
cpu: "100m"
limits:
memory: "200Mi"
cpu: "200m"
volumeMounts:
- name: pgdata
mountPath: /var/lib/postgresql/data
- name: pg-wal
mountPath: /var/lib/postgresql/wal
volumes:
- name: pgdata
persistentVolumeClaim:
claimName: production-pg-etl-1
- name: pg-wal
persistentVolumeClaim:
claimName: production-pg-etl-1-walYou can then exec to get a shell in the container to do post-mortem.
❯ kubectl apply -f debug-pod.yaml
pod/production-pg-etl-1-debug created
❯ kubectl exec -n db production-pg-etl-1-debug -it -- /bin/bash
root@production-pg-etl-1-debug:/# df -h
Filesystem Size Used Avail Use% Mounted on
overlay 248G 24G 225G 10% /
tmpfs 64M 0 64M 0% /dev
/dev/root 248G 24G 225G 10% /etc/hosts
shm 64M 0 64M 0% /dev/shm
/dev/sdc 1007G 529G 479G 53% /var/lib/postgresql/data
/dev/sdb 383G 4.1G 379G 2% /var/lib/postgresql/wal
tmpfs 200M 12K 200M 1% /run/secrets/kubernetes.io/serviceaccount
tmpfs 16G 0 16G 0% /proc/acpi
tmpfs 16G 0 16G 0% /proc/scsi
tmpfs 16G 0 16G 0% /sys/firmware
Additional context
No response
Backport?
Yes
Are you willing to actively contribute to this feature?
Yes
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
[-][Feature]: Add ability to disable instance manager check for wal space to debug out-of-space conditions.[/-][+][Feature]: Add ability to debug and resolve out-of-space conditions [/+]gbartolini commentedon Jan 18, 2025
I'm still unclear about your plans once you are in the pod. Could you please list some of the actions you intend to perform? This would help us better understand the broader goals of this command. Thank you.
jmealo commentedon Jan 20, 2025
@gbartolini: To be able to resolve the out of disk space scenario (drop replication slots to non-existent instances, or failed backups) ... that's why dropping into single user mode seems like the most important consideration. Some folks might want to get a shell as well.
dosubot commentedon Apr 21, 2025
Hi, @jmealo. I'm Dosu, and I'm helping the cloudnative-pg team manage their backlog. I'm marking this issue as stale.
Issue Summary:
kubectl cnpg recoverycommand to automate the process.Next Steps:
Thank you for your understanding and contribution!
github-actions commentedon Jun 6, 2025
This issue was closed because it has been inactive for 14 days since being marked as stale.