Aaryan123456679 commented on code in PR #70238:
URL: https://github.com/apache/airflow/pull/70238#discussion_r3743720831
##########
chart/values.schema.json:
##########
@@ -126,6 +126,12 @@
"allowPrivilegeEscalation": false
}
]
+ },
+ "disableDefaults": {
+ "description": "If `true`, the chart will not set any
default `securityContext` values when `securityContexts.pod` /
`securityContexts.containers` (or the equivalent per-component overrides) are
left empty. (Default `false` is deprecated and will change to `true` in a
future release.)",
Review Comment:
Done.
---
Drafted-by: Claude Code (Sonnet 5) (no human review before posting)
##########
chart/values.yaml:
##########
@@ -47,6 +47,11 @@ gid: 0
securityContexts:
pod: {}
containers: {}
+ # If `true`, the chart will not set any default `securityContext` values when
+ # securityContexts.pod / securityContexts.containers (or the equivalent
per-component
+ # overrides) are left empty. (Default `false` is deprecated and will change
to `true`
+ # in a future release.)
Review Comment:
Done.
---
Drafted-by: Claude Code (Sonnet 5) (no human review before posting)
##########
chart/tests/helm_tests/security/test_security_context.py:
##########
@@ -422,6 +422,239 @@ def test_main_pod_setting(self):
for doc in docs[1:]:
assert ctx_value ==
jmespath.search("spec.template.spec.securityContext", doc)
+ def test_disable_defaults_pod_and_container(self):
+ """
+ securityContexts.disableDefaults suppresses the chart's hard-coded
runAsUser/fsGroup
+ and allowPrivilegeEscalation/capabilities defaults, e.g. for OpenShift
SCC compatibility.
+ """
Review Comment:
Done.
---
Drafted-by: Claude Code (Sonnet 5) (no human review before posting)
##########
chart/tests/helm_tests/security/test_security_context.py:
##########
@@ -422,6 +422,239 @@ def test_main_pod_setting(self):
for doc in docs[1:]:
assert ctx_value ==
jmespath.search("spec.template.spec.securityContext", doc)
+ def test_disable_defaults_pod_and_container(self):
Review Comment:
Done.
---
Drafted-by: Claude Code (Sonnet 5) (no human review before posting)
##########
chart/tests/helm_tests/security/test_security_context.py:
##########
@@ -422,6 +422,239 @@ def test_main_pod_setting(self):
for doc in docs[1:]:
assert ctx_value ==
jmespath.search("spec.template.spec.securityContext", doc)
+ def test_disable_defaults_pod_and_container(self):
+ """
+ securityContexts.disableDefaults suppresses the chart's hard-coded
runAsUser/fsGroup
+ and allowPrivilegeEscalation/capabilities defaults, e.g. for OpenShift
SCC compatibility.
+ """
+ docs = render_chart(
+ values={
+ "securityContexts": {"disableDefaults": True},
+ "executor": "CeleryExecutor,KubernetesExecutor",
+ "cleanup": {"enabled": True},
+ "flower": {"enabled": True},
+ "pgbouncer": {"enabled": True},
+ "statsd": {"enabled": True},
+ },
+ show_only=[
+ "templates/cleanup/cleanup-cronjob.yaml",
+ "templates/flower/flower-deployment.yaml",
+ "templates/scheduler/scheduler-deployment.yaml",
+ "templates/api-server/api-server-deployment.yaml",
+ "templates/dag-processor/dag-processor-deployment.yaml",
+ "templates/workers/worker-deployment.yaml",
+ "templates/jobs/create-user-job.yaml",
+ "templates/jobs/migrate-database-job.yaml",
+ "templates/triggerer/triggerer-deployment.yaml",
+ "templates/pgbouncer/pgbouncer-deployment.yaml",
+ "templates/statsd/statsd-deployment.yaml",
+ "templates/redis/redis-statefulset.yaml",
+ ],
+ )
+
+ assert
jmespath.search("spec.jobTemplate.spec.template.spec.securityContext", docs[0])
is None
+ assert (
+
jmespath.search("spec.jobTemplate.spec.template.spec.containers[0].securityContext",
docs[0])
+ is None
+ )
+
+ for doc in docs[1:]:
Review Comment:
Done.
---
Drafted-by: Claude Code (Sonnet 5) (no human review before posting)
##########
chart/tests/helm_tests/security/test_security_context.py:
##########
@@ -422,6 +422,239 @@ def test_main_pod_setting(self):
for doc in docs[1:]:
assert ctx_value ==
jmespath.search("spec.template.spec.securityContext", doc)
+ def test_disable_defaults_pod_and_container(self):
+ """
+ securityContexts.disableDefaults suppresses the chart's hard-coded
runAsUser/fsGroup
+ and allowPrivilegeEscalation/capabilities defaults, e.g. for OpenShift
SCC compatibility.
+ """
+ docs = render_chart(
+ values={
+ "securityContexts": {"disableDefaults": True},
+ "executor": "CeleryExecutor,KubernetesExecutor",
+ "cleanup": {"enabled": True},
+ "flower": {"enabled": True},
+ "pgbouncer": {"enabled": True},
+ "statsd": {"enabled": True},
+ },
+ show_only=[
+ "templates/cleanup/cleanup-cronjob.yaml",
+ "templates/flower/flower-deployment.yaml",
+ "templates/scheduler/scheduler-deployment.yaml",
+ "templates/api-server/api-server-deployment.yaml",
+ "templates/dag-processor/dag-processor-deployment.yaml",
+ "templates/workers/worker-deployment.yaml",
+ "templates/jobs/create-user-job.yaml",
+ "templates/jobs/migrate-database-job.yaml",
+ "templates/triggerer/triggerer-deployment.yaml",
+ "templates/pgbouncer/pgbouncer-deployment.yaml",
+ "templates/statsd/statsd-deployment.yaml",
+ "templates/redis/redis-statefulset.yaml",
+ ],
+ )
+
+ assert
jmespath.search("spec.jobTemplate.spec.template.spec.securityContext", docs[0])
is None
+ assert (
+
jmespath.search("spec.jobTemplate.spec.template.spec.containers[0].securityContext",
docs[0])
+ is None
+ )
+
+ for doc in docs[1:]:
+ assert jmespath.search("spec.template.spec.securityContext", doc)
is None
+ assert
jmespath.search("spec.template.spec.containers[0].securityContext", doc) is None
+
+ def test_disable_defaults_gitsync_containers(self):
+ docs = render_chart(
+ values={
+ "securityContexts": {"disableDefaults": True},
+ "dags": {"gitSync": {"enabled": True}},
+ },
+ show_only=[
+ "templates/workers/worker-deployment.yaml",
+ "templates/triggerer/triggerer-deployment.yaml",
+ "templates/dag-processor/dag-processor-deployment.yaml",
+ ],
+ )
+
+ for doc in docs:
+ assert (
+ jmespath.search(
+
"spec.template.spec.initContainers[?name=='git-sync-init'].securityContext |
[0]",
+ doc,
+ )
+ is None
+ )
+ assert (
+ jmespath.search(
+
"spec.template.spec.containers[?name=='git-sync'].securityContext | [0]",
+ doc,
+ )
+ is None
+ )
+
+ def test_disable_defaults_volume_permissions_init_container_skipped(self):
+ """With no explicit uid/gid override, the volume-permissions init
container is omitted entirely."""
+ docs = render_chart(
+ values={
+ "securityContexts": {"disableDefaults": True},
+ "workers": {
+ "celery": {
+ "persistence": {"enabled": True, "fixPermissions":
True},
+ }
+ },
+ },
+ show_only=["templates/workers/worker-deployment.yaml"],
+ )
+
+ init_container_names = [
+ c["name"] for c in
jmespath.search("spec.template.spec.initContainers", docs[0])
+ ]
Review Comment:
Done.
---
Drafted-by: Claude Code (Sonnet 5) (no human review before posting)
##########
chart/tests/helm_tests/security/test_security_context.py:
##########
@@ -422,6 +422,239 @@ def test_main_pod_setting(self):
for doc in docs[1:]:
assert ctx_value ==
jmespath.search("spec.template.spec.securityContext", doc)
+ def test_disable_defaults_pod_and_container(self):
+ """
+ securityContexts.disableDefaults suppresses the chart's hard-coded
runAsUser/fsGroup
+ and allowPrivilegeEscalation/capabilities defaults, e.g. for OpenShift
SCC compatibility.
+ """
+ docs = render_chart(
+ values={
+ "securityContexts": {"disableDefaults": True},
+ "executor": "CeleryExecutor,KubernetesExecutor",
+ "cleanup": {"enabled": True},
+ "flower": {"enabled": True},
+ "pgbouncer": {"enabled": True},
+ "statsd": {"enabled": True},
+ },
+ show_only=[
+ "templates/cleanup/cleanup-cronjob.yaml",
+ "templates/flower/flower-deployment.yaml",
+ "templates/scheduler/scheduler-deployment.yaml",
+ "templates/api-server/api-server-deployment.yaml",
+ "templates/dag-processor/dag-processor-deployment.yaml",
+ "templates/workers/worker-deployment.yaml",
+ "templates/jobs/create-user-job.yaml",
+ "templates/jobs/migrate-database-job.yaml",
+ "templates/triggerer/triggerer-deployment.yaml",
+ "templates/pgbouncer/pgbouncer-deployment.yaml",
+ "templates/statsd/statsd-deployment.yaml",
+ "templates/redis/redis-statefulset.yaml",
+ ],
+ )
+
+ assert
jmespath.search("spec.jobTemplate.spec.template.spec.securityContext", docs[0])
is None
+ assert (
+
jmespath.search("spec.jobTemplate.spec.template.spec.containers[0].securityContext",
docs[0])
+ is None
+ )
+
+ for doc in docs[1:]:
+ assert jmespath.search("spec.template.spec.securityContext", doc)
is None
+ assert
jmespath.search("spec.template.spec.containers[0].securityContext", doc) is None
+
+ def test_disable_defaults_gitsync_containers(self):
+ docs = render_chart(
+ values={
+ "securityContexts": {"disableDefaults": True},
+ "dags": {"gitSync": {"enabled": True}},
+ },
+ show_only=[
+ "templates/workers/worker-deployment.yaml",
+ "templates/triggerer/triggerer-deployment.yaml",
+ "templates/dag-processor/dag-processor-deployment.yaml",
+ ],
+ )
+
+ for doc in docs:
+ assert (
+ jmespath.search(
+
"spec.template.spec.initContainers[?name=='git-sync-init'].securityContext |
[0]",
+ doc,
+ )
+ is None
+ )
+ assert (
+ jmespath.search(
+
"spec.template.spec.containers[?name=='git-sync'].securityContext | [0]",
+ doc,
+ )
+ is None
+ )
+
+ def test_disable_defaults_volume_permissions_init_container_skipped(self):
+ """With no explicit uid/gid override, the volume-permissions init
container is omitted entirely."""
+ docs = render_chart(
+ values={
+ "securityContexts": {"disableDefaults": True},
+ "workers": {
+ "celery": {
+ "persistence": {"enabled": True, "fixPermissions":
True},
+ }
+ },
+ },
+ show_only=["templates/workers/worker-deployment.yaml"],
+ )
+
+ init_container_names = [
+ c["name"] for c in
jmespath.search("spec.template.spec.initContainers", docs[0])
+ ]
+ assert "volume-permissions" not in init_container_names
+
+ def test_disable_defaults_explicit_override_still_applied(self):
+ """Explicit securityContexts overrides take priority over
disableDefaults."""
Review Comment:
Done.
---
Drafted-by: Claude Code (Sonnet 5) (no human review before posting)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]