Skip to content

Commit ccf7c6e

Browse files
authored
chore: Update the Airflow entrypoint script and remove the UID & GID check (#1138)
chore: Update the Airflow entrypoint script and remove the UID & GID check
1 parent d933e1e commit ccf7c6e

File tree

2 files changed

+38
-19
lines changed

2 files changed

+38
-19
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ All notable changes to this project will be documented in this file.
6969
- containerdebug updated to 0.2.0 ([#1128])
7070
- Build Hadoop as `stackable` and configure the Stackable Nexus build-repo for the `root` user ([#1133])
7171
- patchable: The base branch is now configured as the git upstream branch ([#1131]).
72+
- airflow: Updates the entrypoint script and removes the check for GID == 0 ([#1138])
7273

7374
### Fixed
7475

@@ -158,6 +159,7 @@ All notable changes to this project will be documented in this file.
158159
[#1131]: https://github.com/stackabletech/docker-images/pull/1131
159160
[#1133]: https://github.com/stackabletech/docker-images/pull/1133
160161
[#1137]: https://github.com/stackabletech/docker-images/pull/1137
162+
[#1138]: https://github.com/stackabletech/docker-images/pull/1138
161163

162164
## [25.3.0] - 2025-03-21
163165

airflow/stackable/utils/entrypoint.sh

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
# Stackable notes:
2121
# Source of this file is the upstream Apache Airflow project
22-
# https://github.com/apache/airflow/blob/main/scripts/docker/entrypoint_prod.sh
23-
# It was last synced from the upstream repo on 2023-07-31 and is up-to-date as of commit 86193f5
24-
22+
# https://github.com/apache/airflow/blob/dc271d0c604ca1836ee4f943726b2d436547700f/scripts/docker/entrypoint_prod.sh
23+
# It was last synced from the upstream repo on 2025-06-01 and is up-to-date as of commit dc271d0c604ca1836ee4f943726b2d436547700f
24+
# Changes we made are denoted with a comment "STACKABLE PATCH BEGIN" and # STACKABLE PATCH END
2525

2626
AIRFLOW_COMMAND="${1:-}"
2727

@@ -34,9 +34,12 @@ set -euo pipefail
3434
# The side effect of this is slightly (in the range of 100s of milliseconds) slower load for any
3535
# binary started and a little memory used for Heap allocated by initialization of libstdc++
3636
# This overhead is not happening for binaries that already link dynamically libstdc++
37+
38+
# STACKABLE PATCH BEGIN
39+
# The path to this file is different on UBI
3740
# LD_PRELOAD="/usr/lib/$(uname -m)-linux-gnu/libstdc++.so.6"
38-
# Stackable: The path to this file is different on UBI
3941
LD_PRELOAD=/usr/lib64/libstdc++.so.6
42+
# STACKABLE PATCH END
4043
export LD_PRELOAD
4144

4245
function run_check_with_retries {
@@ -161,13 +164,17 @@ function create_www_user() {
161164
exit 1
162165
fi
163166

164-
airflow users create \
165-
--username "${_AIRFLOW_WWW_USER_USERNAME="admin"}" \
166-
--firstname "${_AIRFLOW_WWW_USER_FIRSTNAME="Airflow"}" \
167-
--lastname "${_AIRFLOW_WWW_USER_LASTNAME="Admin"}" \
168-
--email "${_AIRFLOW_WWW_USER_EMAIL="airflowadmin@example.com"}" \
169-
--role "${_AIRFLOW_WWW_USER_ROLE="Admin"}" \
170-
--password "${local_password}" || true
167+
if airflow config get-value core auth_manager | grep -q "FabAuthManager"; then
168+
airflow users create \
169+
--username "${_AIRFLOW_WWW_USER_USERNAME="admin"}" \
170+
--firstname "${_AIRFLOW_WWW_USER_FIRSTNAME="Airflow"}" \
171+
--lastname "${_AIRFLOW_WWW_USER_LASTNAME="Admin"}" \
172+
--email "${_AIRFLOW_WWW_USER_EMAIL="airflowadmin@example.com"}" \
173+
--role "${_AIRFLOW_WWW_USER_ROLE="Admin"}" \
174+
--password "${local_password}" || true
175+
else
176+
echo "Skipping user creation as auth manager different from Fab is used"
177+
fi
171178
}
172179

173180
function create_system_user_if_missing() {
@@ -193,7 +200,7 @@ function set_pythonpath_for_root_user() {
193200
# Now also adds applications installed as local user "airflow".
194201
if [[ $UID == "0" ]]; then
195202
local python_major_minor
196-
python_major_minor="$(python --version | cut -d " " -f 2 | cut -d "." -f 1-2)"
203+
python_major_minor=$(python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
197204
export PYTHONPATH="${AIRFLOW_USER_HOME_DIR}/.local/lib/python${python_major_minor}/site-packages:${PYTHONPATH:-}"
198205
>&2 echo "The container is run as root user. For security, consider using a regular user account."
199206
fi
@@ -204,9 +211,9 @@ function wait_for_airflow_db() {
204211
run_check_with_retries "airflow db check"
205212
}
206213

207-
function upgrade_db() {
208-
# Runs airflow db upgrade
209-
airflow db upgrade || true
214+
function migrate_db() {
215+
# Runs airflow db migrate
216+
airflow db migrate || true
210217
}
211218

212219
function wait_for_celery_broker() {
@@ -272,7 +279,10 @@ function check_uid_gid() {
272279
# not set when PIP is run by Airflow later on
273280
unset PIP_USER
274281

275-
check_uid_gid
282+
# STACKABLE PATCH BEGIN
283+
# Disable check for uid & gid (https://github.com/stackabletech/issues/issues/645)
284+
# check_uid_gid
285+
# STACKABLE PATCH END
276286

277287
# Set umask to 0002 to make all the directories created by the current user group-writeable
278288
# This allows the same directories to be writeable for any arbitrary user the image will be
@@ -292,8 +302,12 @@ if [[ "${CONNECTION_CHECK_MAX_COUNT}" -gt "0" ]]; then
292302
wait_for_airflow_db
293303
fi
294304

305+
if [[ -n "${_AIRFLOW_DB_UPGRADE=}" ]] || [[ -n "${_AIRFLOW_DB_MIGRATE=}" ]] ; then
306+
migrate_db
307+
fi
308+
295309
if [[ -n "${_AIRFLOW_DB_UPGRADE=}" ]] ; then
296-
upgrade_db
310+
>&2 echo "WARNING: Environment variable '_AIRFLOW_DB_UPGRADE' is deprecated please use '_AIRFLOW_DB_MIGRATE' instead"
297311
fi
298312

299313
if [[ -n "${_AIRFLOW_WWW_USER_CREATE=}" ]] ; then
@@ -310,10 +324,13 @@ if [[ -n "${_PIP_ADDITIONAL_REQUIREMENTS=}" ]] ; then
310324
>&2 echo " https://airflow.apache.org/docs/docker-stack/build.html"
311325
>&2 echo
312326
>&2 echo " Adding requirements at container startup is fragile and is done every time"
313-
>&2 echo " the container starts, so it is onlny useful for testing and trying out"
327+
>&2 echo " the container starts, so it is only useful for testing and trying out"
314328
>&2 echo " of adding dependencies."
315329
>&2 echo
316-
pip install --root-user-action ignore --no-cache-dir "${_PIP_ADDITIONAL_REQUIREMENTS}"
330+
# STACKABLE PATCH BEGIN
331+
# Add double quotes to silence Shellcheck warning SC2086
332+
pip install --root-user-action ignore "${_PIP_ADDITIONAL_REQUIREMENTS}"
333+
# STACKABLE PATCH END
317334
fi
318335

319336

0 commit comments

Comments
 (0)