Skip to content

Change error when draining a node with Pod Disruption Budget #797

@OttaviaB

Description

@OttaviaB
SUMMARY

When k8s_drain tries to evict a pod which cannot be evicted due to a pod disruption budget an error "Too Many Requests" is returned.
Changing this message to something more meaningful would make it easier to work with retries/until loops in an Ansible playbook to drain the node.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

kubernetes.core.k8s_drain

ADDITIONAL INFORMATION

Current behaviour:

TASK [Drain node] *************************************************************************
Montag 25 November 2024  09:37:09 +0100 (0:00:00.015)       0:00:00.015 ******* 
fatal: [host -> localhost]: FAILED! => {"changed": false, "msg": "Failed to delete pod kube-public/draintest-6b84677b99-c6s5w due to: Too Many Requests"}

Proposed behaviour:

TASK [Drain node] *************************************************************************
Montag 25 November 2024  09:20:28 +0100 (0:00:00.014)       0:00:00.014 ******* 
fatal: [host -> localhost]: FAILED! => {"changed": false, "msg": "Failed to delete pod kube-public/draintest-6b84677b99-9jf7m due to: Cannot evict pod as it would violate the pod's disruption budget."}
---
- hosts: "{{ target }}"
  serial: 1
  gather_facts: false
  tasks:
    - name: Drain node
        kubernetes.core.k8s_drain:
        kubeconfig: "{{ kubeconfig_path }}"
        name: "{{ inventory_hostname }}"
        delete_options:
            ignore_daemonsets: true
            delete_emptydir_data: true
            wait_timeout: 100
            disable_eviction: false
            wait_sleep: 1
        delegate_to: localhost

See also:

#711

kubernetes/kubernetes#106286

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions