You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ketozhang (via GitHub)" <gi...@apache.org> on 2025/04/30 19:52:31 UTC

[D] Working around KubernetesPodOperator decorator "argument list too long" [airflow]

GitHub user ketozhang created a discussion: Working around KubernetesPodOperator decorator "argument list too long"

I am hitting the error `base exec /usr/bin/bash: argument list too long` when passing in a large argument to the KubernetesPodOperator (KPO) decorator. I can't figure out from the K8s pod definition why this is happening

The relevant portions to the KPO pod is defined as:

```yaml
- command:                                                                                                                                                                                                                                                                         
  - bash                                                                                                                                                                                                                                                                           
  - -cx                                                                                                                                                                                                                                                                            
  - python -c "import base64, os;x = base64.b64decode(os.environ[\"__PYTHON_SCRIPT\"]);f                                                                                                                                                                                           
    = open(\"/tmp/script.py\", \"wb\"); f.write(x); f.close()" && python -c "import                                                                                                                                                                                                
    base64, os;x = base64.b64decode(os.environ[\"__PYTHON_INPUT\"]);f = open(\"/tmp/script.in\",                                                                                                                                                                                   
    \"wb\"); f.write(x); f.close()" && mkdir -p /airflow/xcom && python /tmp/script.py                                                                                                                                                                                             
    /tmp/script.in /airflow/xcom/return.json                                                                                                                                                                                                                                       
  env:                                                                                                                                                                                                                                                                             
  - name: __PYTHON_SCRIPT                                                                                                                                                                                                                                                          
    value: ...
  - name: __PYTHON_INPUT
    value: ...
```

The command itself is of constant size. Only the environment variable, `__PYTHON_INPUT` grows with argument size. I speculate the error is complaining that the environment variable is too large.

In the KPO decorator, it easy to come up with a very long argument (e.g., `list[str]`) that that causes `base exec /usr/bin/bash: argument list too long` error.

```
@task.kubernetes()
def foobar(x: list[str]):
    print(x)

foobar(["a"*100]*1000)
```

GitHub link: https://github.com/apache/airflow/discussions/50054

----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@airflow.apache.org