Skip to content

[Feature]: Add ability to debug and resolve out-of-space conditions  #6617

Closed as not planned

Description

@jmealo

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

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-wal

You 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

  1. added
    triage
    on Jan 16, 2025
  2. changed the title [-][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 [/+] on Jan 16, 2025
  3. gbartolini commented on Jan 18, 2025

    @gbartolini
    Contributor

    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.

  4. jmealo commented on Jan 20, 2025

    @jmealo
    ContributorAuthor

    @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.

  5. dosubot commented on Apr 21, 2025

    @dosubot

    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:

    • You proposed a feature to aid in debugging out-of-space conditions in PostgreSQL using single-user mode.
    • The feature includes a kubectl cnpg recovery command to automate the process.
    • @gbartolini requested clarification on the actions within the pod.
    • You clarified the goal is to resolve disk space issues, like dropping replication slots, and emphasized the importance of single-user mode and shell access.

    Next Steps:

    • Please confirm if this issue is still relevant to the latest version of the cloudnative-pg repository by commenting here.
    • If no further input is provided, the issue will be automatically closed in 7 days.

    Thank you for your understanding and contribution!

  6. github-actions commented on Jun 6, 2025

    @github-actions
    Contributor

    This issue was closed because it has been inactive for 14 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Staletriage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions