Skip to content

[Bug]: cluster stuck following FailedScheduling after scale up #5285

Closed

Description

@gbartolini

Is there an existing issue already for this bug?

  • I have searched for an existing issue, and could not find anything. I believe this is a new bug.

I have read the troubleshooting guide

  • I have read the troubleshooting guide and I think this is a new bug.

I am running a supported version of CloudNativePG

  • I have read the troubleshooting guide and I think this is a new bug.

Contact Details

No response

Version

trunk (main)

What version of Kubernetes are you using?

1.30 (unsupported)

What is your Kubernetes environment?

Self-managed: kind (evaluation)

How did you install the operator?

YAML manifest

What happened?

I created a new kind environment as follows:

(cat <<EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: multi-node-taints-template
nodes:

# Control Plane node
- role: control-plane

# Infrastructure/Application nodes (2)
- role: worker
  labels:
    infra.node.kubernetes.io:
- role: worker
  labels:
    app.node.kubernetes.io:

# PostgreSQL nodes (3)
- role: worker
  labels:
    postgres.node.kubernetes.io:
  kubeadmConfigPatches:
  - |
    kind: JoinConfiguration
    nodeRegistration:
      taints:
      - key: node-role.kubernetes.io/postgres
        effect: NoSchedule
- role: worker
  labels:
    postgres.node.kubernetes.io:
  kubeadmConfigPatches:
  - |
    kind: JoinConfiguration
    nodeRegistration:
      taints:
      - key: node-role.kubernetes.io/postgres
        effect: NoSchedule
- role: worker
  labels:
    postgres.node.kubernetes.io:
  kubeadmConfigPatches:
  - |
    kind: JoinConfiguration
    nodeRegistration:
      taints:
      - key: node-role.kubernetes.io/postgres
        effect: NoSchedule
EOF
)  | kind create cluster --config - --name cnpg

I then ran:

kubectl label node -l postgres.node.kubernetes.io node-role.kubernetes.io/postgres=
kubectl label node -l infra.node.kubernetes.io node-role.kubernetes.io/infra=
kubectl label node -l app.node.kubernetes.io node-role.kubernetes.io/app=

I installed the latest snapshot of the operator.

Then I created a new cluster using the manifest in the next section.

Once it was up, I ran:

kubectl scale cluster --replicas 4 cluster-example

which produced:

NAME                           READY   STATUS    RESTARTS   AGE
cluster-example-1              1/1     Running   0          25m
cluster-example-2              1/1     Running   0          19m
cluster-example-3              1/1     Running   0          18m
cluster-example-4-join-8pds8   0/1     Pending   0          73s

If I run describe on the pod, I get:

Events:
  Type     Reason            Age                    From               Message
  ----     ------            ----                   ----               -------
  Warning  FailedScheduling  2m54s (x2 over 8m19s)  default-scheduler  0/6 nodes are available: 1 node(s) had untolerated taint {node-role.kubernetes.io/control-plane: }, 2 node(s) didn't match Pod's node affinity/selector, 3 node(s) didn't match pod anti-affinity rules. preemption: 0/6 nodes are available: 3 No preemption victims found for incoming pod, 3 Preemption is not helpful for scheduling.

I tried to scale down again to 3, but the cluster hangs. I even tried to delete the job. Nothing.

Cluster resource

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: cluster-example
spec:
  instances: 3

  storage:
    size: 1Gi

  affinity:
    nodeSelector:
      node-role.kubernetes.io/postgres: ""

    # Set the toleration for the taint
    tolerations:
    - key: node-role.kubernetes.io/postgres
      operator: Exists
      effect: NoSchedule

    # Ensure that instances are scheduled and run on different nodes
    enablePodAntiAffinity: true
    topologyKey: kubernetes.io/hostname
    podAntiAffinityType: required

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    triage
    on Aug 15, 2024
  2. self-assigned this
    on Aug 15, 2024
  3. added
    bug 🐛
    and removed
    bug 🐛
    on Aug 15, 2024
  4. added this to the 1.24.0 milestone on Aug 15, 2024
  5. leonardoce commented on Aug 15, 2024

    @leonardoce
    Contributor

    This happens because you needed to delete the corresponding PVC groups and the Job too.
    I think we can improve our kubectl cnpg destroy <cluster-name> <instance-number> to do that too.

  6. leonardoce commented on Aug 15, 2024

    @leonardoce
    Contributor

    @gbartolini If we want to use kubectl cnpg destroy for that, I filed #5298

  7. jsilvela commented on Aug 15, 2024

    @jsilvela
    Contributor

    I was able to repro this exactly locally

  8. jsilvela commented on Aug 15, 2024

    @jsilvela
    Contributor

    And I confirm that @leonardoce 's fix works well (of course) :)

  9. gbartolini commented on Aug 15, 2024

    @gbartolini
    ContributorAuthor

    Well ... it makes sense now. My fault, I should have deleted the PVC too. However, I think we need to document this, as the behavior is fine, given that we don't delete PVCs at the moment.

    Ultimately in real world we just need to add nodes.

  10. jsilvela commented on Aug 15, 2024

    @jsilvela
    Contributor

    I scaled back to 3 and deleted the job only, didn't have to delete any PVC.
    I agree, even if we update the plugin, you'd have to know to use the plugin to delete the instance.

  11. jsilvela commented on Aug 15, 2024

    @jsilvela
    Contributor

    Interesting. Until I deleted the dangling PVC-4, the cluster was in Creating a new replica

  12. gbartolini commented on Aug 16, 2024

    @gbartolini
    ContributorAuthor

    So essentially, there are two possible ways to exit this impasse:

    1. You add another node
    2. You rollback, specifically running:
    • kubectl scale cluster --replicas 3 cluster-example
    • kubectl delete job cluster-example-4-join
    • kubectl delete pvc cluster-example-4

    Ideally, IMHO, once we scale down to 3, the operator should automate the deletion of the job and the PVC. Thoughts?

  13. added a commit that references this issue on Aug 21, 2024
    07d3d0a
  14. added 2 commits that reference this issue on Aug 21, 2024
    96d8d7d
    998d9fe
  15. added a commit that references this issue on Aug 21, 2024
    9943f69
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

triage

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions