forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mount DAGs read only when using
gitsync
(apache#15953)
We will mount the DAGs as read only when we are using gitsync, but not when we are only using persistence. This also moves the whole mount definition into helpers instead of just the mount path, making it easier to modify the DAGs mount everywhere it is used in the future.
- Loading branch information
1 parent
6fd6712
commit e01b4e6
Showing
9 changed files
with
126 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,6 @@ repository | |
|
||
# Chart dependencies | ||
**/charts/*.tgz | ||
|
||
# Never check in tmpcharts | ||
tmpcharts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# 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 unittest | ||
|
||
import jmespath | ||
from parameterized import parameterized | ||
|
||
from tests.helm_template_generator import render_chart | ||
|
||
|
||
class AirflowCommon(unittest.TestCase): | ||
""" | ||
This class holds tests that apply to more than 1 Airflow component so | ||
we don't have to repeat tests everywhere | ||
The one general exception will be the KubernetesExecutor PodTemplateFile, | ||
as it requires extra test setup. | ||
""" | ||
|
||
@parameterized.expand( | ||
[ | ||
({"gitSync": {"enabled": True}}, True), | ||
({"persistence": {"enabled": True}}, False), | ||
( | ||
{ | ||
"gitSync": {"enabled": True}, | ||
"persistence": {"enabled": True}, | ||
}, | ||
True, | ||
), | ||
] | ||
) | ||
def test_dags_mount(self, dag_values, expected_read_only): | ||
docs = render_chart( | ||
values={ | ||
"dags": dag_values, | ||
"airflowVersion": "1.10.15", | ||
}, # airflowVersion is present so webserver gets the mount | ||
show_only=[ | ||
"templates/scheduler/scheduler-deployment.yaml", | ||
"templates/workers/worker-deployment.yaml", | ||
"templates/webserver/webserver-deployment.yaml", | ||
], | ||
) | ||
|
||
assert 3 == len(docs) | ||
for doc in docs: | ||
expected_mount = { | ||
"mountPath": "/opt/airflow/dags", | ||
"name": "dags", | ||
"readOnly": expected_read_only, | ||
} | ||
assert expected_mount in jmespath.search("spec.template.spec.containers[0].volumeMounts", doc) | ||
|
||
def test_annotations(self): | ||
""" | ||
Test Annotations are correctly applied on all pods created Scheduler, Webserver & Worker | ||
deployments. | ||
""" | ||
release_name = "TEST-BASIC" | ||
k8s_objects = render_chart( | ||
name=release_name, | ||
values={"airflowPodAnnotations": {"test-annotation/safe-to-evict": "true"}}, | ||
show_only=[ | ||
"templates/scheduler/scheduler-deployment.yaml", | ||
"templates/workers/worker-deployment.yaml", | ||
"templates/webserver/webserver-deployment.yaml", | ||
"templates/flower/flower-deployment.yaml", | ||
], | ||
) | ||
|
||
assert 4 == len(k8s_objects) | ||
|
||
for k8s_object in k8s_objects: | ||
annotations = k8s_object["spec"]["template"]["metadata"]["annotations"] | ||
assert "test-annotation/safe-to-evict" in annotations | ||
assert "true" in annotations["test-annotation/safe-to-evict"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters