From commits-return-17503-archive-asf-public=cust-asf.ponee.io@airflow.incubator.apache.org Mon Aug 6 22:45:05 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 5444D180627 for ; Mon, 6 Aug 2018 22:45:04 +0200 (CEST) Received: (qmail 23997 invoked by uid 500); 6 Aug 2018 20:45:03 -0000 Mailing-List: contact commits-help@airflow.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airflow.incubator.apache.org Delivered-To: mailing list commits@airflow.incubator.apache.org Received: (qmail 23988 invoked by uid 99); 6 Aug 2018 20:45:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Aug 2018 20:45:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 1141EC026F for ; Mon, 6 Aug 2018 20:45:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.501 X-Spam-Level: X-Spam-Status: No, score=-109.501 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 2JJCHkCYdZea for ; Mon, 6 Aug 2018 20:45:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 8AC7E5F431 for ; Mon, 6 Aug 2018 20:45:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id EC46CE25B0 for ; Mon, 6 Aug 2018 20:45:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 6155223FA1 for ; Mon, 6 Aug 2018 20:45:00 +0000 (UTC) Date: Mon, 6 Aug 2018 20:45:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: commits@airflow.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (AIRFLOW-2755) k8s workers think DAGs are always in `/tmp/dags` MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/AIRFLOW-2755?page=3Dcom.atlassi= an.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D16= 570751#comment-16570751 ]=20 ASF GitHub Bot commented on AIRFLOW-2755: ----------------------------------------- Fokko closed pull request #3612: [AIRFLOW-2755] Added `kubernetes.worker_da= gs_folder` configuration URL: https://github.com/apache/incubator-airflow/pull/3612 =20 =20 =20 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/airflow/config_templates/default_airflow.cfg b/airflow/config_= templates/default_airflow.cfg index be286ea3dc..d4a7242118 100644 --- a/airflow/config_templates/default_airflow.cfg +++ b/airflow/config_templates/default_airflow.cfg @@ -562,6 +562,7 @@ elasticsearch_end_of_log_mark =3D end_of_log worker_container_repository =3D worker_container_tag =3D worker_container_image_pull_policy =3D IfNotPresent +worker_dags_folder =3D =20 # If True (default), worker pods will be deleted upon termination delete_worker_pods =3D True diff --git a/airflow/contrib/executors/kubernetes_executor.py b/airflow/con= trib/executors/kubernetes_executor.py index 788d925c38..66c600ba65 100644 --- a/airflow/contrib/executors/kubernetes_executor.py +++ b/airflow/contrib/executors/kubernetes_executor.py @@ -115,6 +115,8 @@ def __init__(self): self.kubernetes_section, 'worker_container_repository') self.worker_container_tag =3D configuration.get( self.kubernetes_section, 'worker_container_tag') + self.worker_dags_folder =3D configuration.get( + self.kubernetes_section, 'worker_dags_folder') self.kube_image =3D '{}:{}'.format( self.worker_container_repository, self.worker_container_tag) self.kube_image_pull_policy =3D configuration.get( diff --git a/airflow/contrib/kubernetes/worker_configuration.py b/airflow/c= ontrib/kubernetes/worker_configuration.py index c9f86b047a..88a5cf0a40 100644 --- a/airflow/contrib/kubernetes/worker_configuration.py +++ b/airflow/contrib/kubernetes/worker_configuration.py @@ -81,12 +81,14 @@ def _get_init_containers(self, volume_mounts): def _get_environment(self): """Defines any necessary environment variables for the pod executo= r""" env =3D { - 'AIRFLOW__CORE__DAGS_FOLDER': '/tmp/dags', - 'AIRFLOW__CORE__EXECUTOR': 'LocalExecutor', - 'AIRFLOW__CORE__SQL_ALCHEMY_CONN': conf.get('core', 'SQL_ALCHE= MY_CONN') + "AIRFLOW__CORE__EXECUTOR": "LocalExecutor", + "AIRFLOW__CORE__SQL_ALCHEMY_CONN": conf.get("core", "SQL_ALCHE= MY_CONN"), } + if self.kube_config.airflow_configmap: env['AIRFLOW__CORE__AIRFLOW_HOME'] =3D self.worker_airflow_hom= e + if self.kube_config.worker_dags_folder: + env['AIRFLOW__CORE__DAGS_FOLDER'] =3D self.kube_config.worker_= dags_folder return env =20 def _get_secrets(self): diff --git a/scripts/ci/kubernetes/kube/configmaps.yaml b/scripts/ci/kubern= etes/kube/configmaps.yaml index 97556bf840..3e64ae4e47 100644 --- a/scripts/ci/kubernetes/kube/configmaps.yaml +++ b/scripts/ci/kubernetes/kube/configmaps.yaml @@ -179,6 +179,7 @@ data: worker_container_repository =3D airflow worker_container_tag =3D latest worker_container_image_pull_policy =3D IfNotPresent + worker_dags_folder =3D /tmp/dags delete_worker_pods =3D True git_repo =3D https://github.com/apache/incubator-airflow.git git_branch =3D master diff --git a/tests/contrib/executors/test_kubernetes_executor.py b/tests/co= ntrib/executors/test_kubernetes_executor.py index 963efcb03b..d9da48ce3b 100644 --- a/tests/contrib/executors/test_kubernetes_executor.py +++ b/tests/contrib/executors/test_kubernetes_executor.py @@ -133,6 +133,22 @@ def test_worker_with_subpaths(self): "subPath should've been passed to volumeMount configur= ation" ) =20 + def test_worker_environment_no_dags_folder(self): + self.kube_config.worker_dags_folder =3D '' + worker_config =3D WorkerConfiguration(self.kube_config) + env =3D worker_config._get_environment() + + self.assertNotIn('AIRFLOW__CORE__DAGS_FOLDER', env) + + def test_worker_environment_when_dags_folder_specified(self): + dags_folder =3D '/workers/path/to/dags' + self.kube_config.worker_dags_folder =3D dags_folder + + worker_config =3D WorkerConfiguration(self.kube_config) + env =3D worker_config._get_environment() + + self.assertEqual(dags_folder, env['AIRFLOW__CORE__DAGS_FOLDER']) + =20 if __name__ =3D=3D '__main__': unittest.main() =20 ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. =20 For queries about this service, please contact Infrastructure at: users@infra.apache.org > k8s workers think DAGs are always in `/tmp/dags` > ------------------------------------------------ > > Key: AIRFLOW-2755 > URL: https://issues.apache.org/jira/browse/AIRFLOW-2755 > Project: Apache Airflow > Issue Type: Bug > Components: configuration, worker > Reporter: Aldo > Assignee: Aldo > Priority: Minor > Fix For: 2.0.0 > > > We have Airflow configured to use the `KubernetesExecutor` and run=C2=A0t= asks in newly created pods. > I tried to use the `PythonOperator` to import the python callable from a = python module=C2=A0located=C2=A0in the DAGs directory as [that should be po= ssible|https://github.com/apache/incubator-airflow/blob/c7a472ed6b0d8a4720f= 57ba1140c8cf665757167/airflow/__init__.py#L42]. Airflow complained that the= =C2=A0module was not found. > After a fair amount of=C2=A0digging we found that the issue was that the = workers have=C2=A0the `AIRFLOW__CORE__DAGS_FOLDER` environment variable set= to `/tmp/dags` as [you can see from the code|https://github.com/apache/inc= ubator-airflow/blob/master/airflow/contrib/kubernetes/worker_configuration.= py#L84]. > Unset that environment variable from within the task's pod and running th= e task manually worked as expected. I=C2=A0think that this=C2=A0path should= be configurable (I'll give it a try to add a `kubernetes.worker_dags_folde= r` configuration). -- This message was sent by Atlassian JIRA (v7.6.3#76005)