jedcunningham commented on a change in pull request #18249:
URL: https://github.com/apache/airflow/pull/18249#discussion_r740594865
##########
File path: chart/values.schema.json
##########
@@ -1629,6 +1666,18 @@
"description": "Annotations to add to the triggerer pods.",
"type": "object",
"default": {}
+ },
+ "securityContext": {
+ "description": "Global Pod security context as defined in
`Pod Security Context
<https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#podsecuritycontext-v1-core>`_.
If not set, the values from `securityContext` will be used.",
Review comment:
```suggestion
"description": "Triggerer Pod security context as
defined in `Pod Security Context
<https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#podsecuritycontext-v1-core>`_.
If not set, the values from `securityContext` will be used.",
```
Or similar, and for all the others that aren't actually global?
##########
File path: chart/tests/test_security_context.py
##########
@@ -0,0 +1,206 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import jmespath
+
+from tests.helm_template_generator import render_chart
+
+
+class TestSCBackwardsCompatibility:
+ def test_check_deployments_and_jobs(self):
+ docs = render_chart(
+ values={
+ "uid": 3000,
+ "gid": 30,
+ "webserver": {"defaultUser": {"enabled": True}},
+ "flower": {"enabled": True},
+ "airflowVersion": "2.2.0",
+ "executor": "CeleryKubernetesExecutor",
+ },
+ show_only=[
+ "templates/flower/flower-deployment.yaml",
+ "templates/scheduler/scheduler-deployment.yaml",
+ "templates/triggerer/triggerer-deployment.yaml",
+ "templates/webserver/webserver-deployment.yaml",
+ "templates/workers/worker-deployment.yaml",
+ "templates/jobs/create-user-job.yaml",
+ "templates/jobs/migrate-database-job.yaml",
+ ],
+ )
+
+ for index in range(len(docs)):
+ assert 3000 ==
jmespath.search("spec.template.spec.securityContext.runAsUser", docs[index])
+ assert 30 ==
jmespath.search("spec.template.spec.securityContext.fsGroup", docs[index])
+
+ def test_check_statsd_uid(self):
+ docs = render_chart(
+ values={"statsd": {"enabled": True, "uid": 3000}},
+ show_only=["templates/statsd/statsd-deployment.yaml"],
+ )
+
+ for index in range(len(docs)):
+ assert 3000 ==
jmespath.search("spec.template.spec.securityContext.runAsUser", docs[index])
Review comment:
```suggestion
assert 3000 ==
jmespath.search("spec.template.spec.securityContext.runAsUser", docs[0])
```
Both here and elsewhere.
##########
File path: chart/tests/test_security_context.py
##########
@@ -0,0 +1,206 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import jmespath
+
+from tests.helm_template_generator import render_chart
+
+
+class TestSCBackwardsCompatibility:
+ def test_check_deployments_and_jobs(self):
+ docs = render_chart(
+ values={
+ "uid": 3000,
+ "gid": 30,
+ "webserver": {"defaultUser": {"enabled": True}},
+ "flower": {"enabled": True},
+ "airflowVersion": "2.2.0",
+ "executor": "CeleryKubernetesExecutor",
+ },
+ show_only=[
+ "templates/flower/flower-deployment.yaml",
+ "templates/scheduler/scheduler-deployment.yaml",
+ "templates/triggerer/triggerer-deployment.yaml",
+ "templates/webserver/webserver-deployment.yaml",
+ "templates/workers/worker-deployment.yaml",
+ "templates/jobs/create-user-job.yaml",
+ "templates/jobs/migrate-database-job.yaml",
+ ],
+ )
+
+ for index in range(len(docs)):
+ assert 3000 ==
jmespath.search("spec.template.spec.securityContext.runAsUser", docs[index])
+ assert 30 ==
jmespath.search("spec.template.spec.securityContext.fsGroup", docs[index])
Review comment:
```suggestion
for doc in docs:
assert 3000 ==
jmespath.search("spec.template.spec.securityContext.runAsUser", doc)
assert 30 ==
jmespath.search("spec.template.spec.securityContext.fsGroup", doc)
```
Both here and elsewhere.
##########
File path: chart/templates/workers/worker-deployment.yaml
##########
@@ -111,7 +110,7 @@ spec:
command:
- chown
- -R
- - "{{ .Values.uid }}:{{ .Values.gid }}"
+ - "{{ pluck "runAsUser" $securityContext | first }}:{{ pluck
"fsGroup" $securityContext | first }}"
Review comment:
Is this pluck the only reason we use the `mustFromJson | toYaml` pattern
everywhere?
Might be better to simplify the common case and just handle this case
slightly differently? Haven't experimented with this at all, just my off the
cuff thoughts.
--
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]