Skip to content

kubernetes cleanup-pods CLI command only available when using KubernetesExecutor #46978

@jedcunningham

Description

@jedcunningham

Apache Airflow version

main (development)

If "Other Airflow 2 version" selected, which one?

No response

What happened?

Currently, the k8s cleanup command is directly tied to the KubernetesExecutor, but the command is helpful for and documented to be used for KubernetesPodOperator users as well.

What you think should happen instead?

The command should work regardless of executor choice, if you have the kubernetes provider installed.

How to reproduce

With LocalExecutor:

$ AIRFLOW__CORE__EXECUTOR=LocalExecutor airflow kubernetes cleanup-pods --help
Usage: airflow [-h] GROUP_OR_COMMAND ...
...
airflow command error: argument GROUP_OR_COMMAND: invalid choice: 'kubernetes' (choose from 'assets', 'backfill', 'cheat-sheet', 'config', 'connections', 'd
ag-processor', 'dags', 'db', 'fab-db', 'fastapi-api', 'info', 'jobs', 'kerberos', 'plugins', 'pools', 'providers', 'roles', 'rotate-fernet-key', 'scheduler'
, 'standalone', 'sync-perm', 'tasks', 'triggerer', 'users', 'variables', 'version', 'webserver'), see help above.

With KubernetesExecutor:

$ AIRFLOW__CORE__EXECUTOR=KubernetesExecutor airflow kubernetes cleanup-pods --help
Usage: airflow kubernetes cleanup-pods [-h] [--min-pending-minutes MIN_PENDING_MINUTES] [--namespace NAMESPACE] [-v]

Clean up Kubernetes pods (created by KubernetesExecutor/KubernetesPodOperator) in evicted/failed/succeeded/pending states

Options:
  -h, --help            show this help message and exit
  --min-pending-minutes MIN_PENDING_MINUTES
                        Pending pods created before the time interval are to be cleaned up, measured in minutes. Default value is 30(m). The minimum value is 5(m).
  --namespace NAMESPACE
                        Kubernetes Namespace. Default value is ` namespace` in configuration.
  -v, --verbose         Make logging output more verbose

Operating System

macos

Versions of Apache Airflow Providers

No response

Deployment

Virtualenv installation

Deployment details

No response

Anything else?

This likely means that providers generally need to be able to add cli commands, not just things in providers (e.g. executors).

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions