Allow mounting the Airflow config as a directory to avoid the subPath mount race - #70180
Allow mounting the Airflow config as a directory to avoid the subPath mount race#70180diegoalvarez-clarity wants to merge 4 commits into
Conversation
… mount race
The chart mounts airflow.cfg (and airflow_local_settings.py) into every component and
the KubernetesExecutor pod template via a subPath bind-mount of the config ConfigMap.
subPath + ConfigMap hits a known Kubernetes race: on node/volume lifecycle events
(kubelet volume reconstruction, node autoscaling) the pre-computed subPath source inode
goes stale and runc fails the mount at container init with a StartError and no
application log. It is intermittent, cross-component, and runtime-version-independent.
Add an opt-in mountConfigAsDir (default false, existing behaviour unchanged). When true,
the config ConfigMap is mounted as a directory at {airflowHome}/config and AIRFLOW_CONFIG
is set to {airflowHome}/config/airflow.cfg. A directory-projected ConfigMap volume has no
pre-computed subPath bind source, so it is immune to the race. airflow_local_settings.py
keeps its existing path.
Refs: apache#33788
Co-authored-by: diego15ag <11668493+diego15ag@users.noreply.github.com>
Sphinx spellcheck (chart docs) flagged "inode" and "runc". Reword "stale-inode" to "stale-mount" and backtick ``runc`` so both are accepted, keeping the description precise. Co-authored-by: diego15ag <11668493+diego15ag@users.noreply.github.com>
|
+1 |
The solution to the issue mentioned here is basically not to mount the |
|
Thanks @Miretpl — I think we're describing two different cases, so let me draw the line clearly. The whole The race this PR targets is on the chart's own config mount. The shared
The container never starts, so the task hard-fails with no application log. A values-level extraVolumeMounts at
|
|
Hi @jedcunningham @hussein-awala @jscheffl @bugraoz93 @Miretpl 👋 Gentle nudge on this one when you get a chance. To recap where it stands: the PR adds an opt-in mountConfigAsDir flag (default false, so existing behavior is unchanged) that mounts the config ConfigMap as a directory instead of via subPath binds, which avoids the stale-inode StartError race we hit during node reconstruction / autoscaling. @Miretpl — I followed up on your question about #33788 above: this targets the chart's own airflow.cfg / airflow_local_settings.py subPath mounts rather than user-supplied ones, since values-only extraVolumeMounts can't remove the helper's subPath mounts. Happy to expand or adjust if that framing doesn't fully address your concern. Tests cover both the new directory-mount path and the preserved subPath behavior. I'm glad to rebase or make changes to help this move forward — thanks for taking a look! 🙏 |
Why
The chart mounts
airflow.cfg(andairflow_local_settings.py) into every component and the KubernetesExecutor pod template via asubPathbind-mount of theconfigConfigMap.subPath+ ConfigMap hits a known Kubernetes race: on node/volume lifecycle events (kubelet volume reconstruction, node autoscaling) the pre-computed subPath source inode goes stale and runc fails the mount at container init:The task fails with
StartErrorand no application log (the container never starts). It's intermittent, cross-component, multi-node, and runtime-version-independent. See #33788.What
Add an opt-in
mountConfigAsDir(defaultfalse; existing behaviour unchanged). Whentrue, theconfigConfigMap is mounted as a directory at{airflowHome}/config(no subPath) andAIRFLOW_CONFIGis set to{airflowHome}/config/airflow.cfg. A directory-projected ConfigMap volume has no pre-computed subPath bind source, so it's immune to the race.airflow_local_settings.pykeeps its default path, so local-settings loading is unaffected. The separatepod_template_file.yamlsubPath mount is out of scope.Tests
test_mount_config_as_dir— flag on: directory mount, no cfg/local-settings subPath,AIRFLOW_CONFIGset, across all components.test_config_mounted_via_subpath_by_default— default behaviour preserved.Notes
Backward compatible (default off).
This PR was created with the assistance of generative AI tools.
Refs: #33788