Skip to content

Commit

Permalink
fix helm scheduler deployment / scheduler logs (#11685)
Browse files Browse the repository at this point in the history
Based on the airflow image entrypoint, we should use airflow commands directly.
The container exits otherwise.

(cherry picked from commit 069b1f7)
  • Loading branch information
Florent Chehab authored and kaxil committed Nov 18, 2020
1 parent 84ac8e1 commit 791f143
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion chart/templates/scheduler/scheduler-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ spec:
- name: scheduler-logs
image: {{ template "airflow_image" . }}
imagePullPolicy: {{ .Values.images.airflow.pullPolicy }}
args: ["airflow", "serve_logs"]
args: ["serve_logs"]
ports:
- name: worker-logs
containerPort: {{ .Values.ports.workerLogs }}
Expand Down
31 changes: 31 additions & 0 deletions chart/tests/test_basic_helm_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.

import unittest
from typing import Any, Dict, List, Union

import jmespath

Expand Down Expand Up @@ -84,3 +85,33 @@ def test_basic_deployment_without_default_users(self):
]
self.assertNotIn(('Job', 'TEST-BASIC-create-user'), list_of_kind_names_tuples)
self.assertEqual(OBJECT_COUNT_IN_BASIC_DEPLOYMENT - 1, len(k8s_objects))

def test_chart_is_consistent_with_official_airflow_image(self):
def get_k8s_objs_with_image(obj: Union[List[Any], Dict[str, Any]]) -> List[Dict[str, Any]]:
"""
Recursive helper to retrieve all the k8s objects that have an "image" key
inside k8s obj or list of k8s obj
"""
out: List[Dict[str, Any]] = []
if isinstance(obj, list):
for item in obj:
out += get_k8s_objs_with_image(item)
if isinstance(obj, dict):
if "image" in obj:
out += [obj]
# include sub objs, just in case
for val in obj.values():
out += get_k8s_objs_with_image(val)
return out

image_repo = "test-airflow-repo/airflow"
k8s_objects = render_chart("TEST-BASIC", {"defaultAirflowRepository": image_repo})

objs_with_image = get_k8s_objs_with_image(k8s_objects)
for obj in objs_with_image:
image: str = obj["image"] # pylint: disable=invalid-sequence-index
if image.startswith(image_repo):
# Make sure that a command is not specified
self.assertNotIn("command", obj)
# Make sure that the first arg is never airflow
self.assertNotEqual(obj["args"][0], "airflow") # pylint: disable=invalid-sequence-index

0 comments on commit 791f143

Please sign in to comment.