Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 092F6200D5E for ; Sat, 9 Dec 2017 01:32:51 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 07C34160C1F; Sat, 9 Dec 2017 00:32:51 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4BD4F160BFD for ; Sat, 9 Dec 2017 01:32:50 +0100 (CET) Received: (qmail 52060 invoked by uid 500); 9 Dec 2017 00:32:44 -0000 Mailing-List: contact dev-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 dev@airflow.incubator.apache.org Received: (qmail 52048 invoked by uid 99); 9 Dec 2017 00:32:44 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Dec 2017 00:32:44 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id AE5ABC343A for ; Sat, 9 Dec 2017 00:32:43 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.821 X-Spam-Level: X-Spam-Status: No, score=-0.821 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id MTCv2voWZtJc for ; Sat, 9 Dec 2017 00:32:40 +0000 (UTC) Received: from mail-qt0-f178.google.com (mail-qt0-f178.google.com [209.85.216.178]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 364885F39F for ; Sat, 9 Dec 2017 00:32:40 +0000 (UTC) Received: by mail-qt0-f178.google.com with SMTP id r39so28883911qtr.13 for ; Fri, 08 Dec 2017 16:32:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id; bh=9YYL1GJ8Lgt1bbW8/ZtGlx1/sheNmJzgLXVLmP4GH+I=; b=npJ8BbZdamv1lvBJMa+rihYr5I9xe0Z3/McZr15mGxYPWnGGH0riFz1lEUHTyavAiB axiHqOVVHdfop4vG1DDt4yNLIDBSsajp7lLFzrzzehDGUUWKC6lO4Y4OFNoF69nZqp7N s9HJqeCVVKj8uroOcpNiuJN/TdMYVNezsnD/2oU4s6xAeltQS71LnJvWYUNLInlzhY/6 yH4MM53MgdVZdaslVRudbujFxU6F10AIdR5GRyN0L+5aHGV56HPH89C31qFVfbovwYkc qmqhIFMCnANV/+Ng/Qe9x2fa+tDN61LAdAv2iLtyjnAbIV2MXSheMbpj/Xzf0KZp81X6 /qcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:date:references:to:in-reply-to:message-id; bh=9YYL1GJ8Lgt1bbW8/ZtGlx1/sheNmJzgLXVLmP4GH+I=; b=BRtgFyT41I6j93XYd3amngqPoGznnrr9Kk/BkYjhuc6SNtul8nH8R+3YMxjoT71hMd CPBLSuhOK5IU4cqx2RtsCJdATw+9et6VSJGbdFBtA1KMQUmH5xi1+/wpWZ3f9qr9HEgI RwQYNlSWW76SgrB+G+5Fh+h53feAX4+n8bCXPSgi1HqrRYMS84m9GNNZp3ZFJi6AexS5 mPOm+vkR6EsJ75W3dwnG+tk33Y40fIjsy9HZ/Vl/zy9/YxIwsTujD7ajmbl80ZnD6Zkk SKuAmMSSz0oMwDb43VWgUlD61bRS7vuQbjhQ24JiPK8z0v4WrDSVmgWEPRpwhHlqswKs HVOg== X-Gm-Message-State: AKGB3mLW5FKzBf5WaQhfSS/VBsk0gOAyrdck1QgtnZ2kQzi2G1zKaMk7 7LxtoSQ6uWJYhh7p9iHeKMG0KPVC X-Google-Smtp-Source: AGs4zMZbhTkO5UQ8NSQjLdKT6QMcRQlUqyNJ+QoPU5Dz7fK0rRxAtGY6dx85FQdJQTmr5m+ilvYR0Q== X-Received: by 10.237.58.67 with SMTP id n61mr18101765qte.171.1512779558980; Fri, 08 Dec 2017 16:32:38 -0800 (PST) Received: from rajeshs-mbp.home (ool-2f125712.dyn.optonline.net. [47.18.87.18]) by smtp.gmail.com with ESMTPSA id t204sm757429qke.72.2017.12.08.16.32.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Dec 2017 16:32:38 -0800 (PST) From: Rajesh Chamarthi Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 11.0 \(3445.1.7\)) Subject: Re: Environment variables - Oracle LD_LIBRARY_PATH Date: Fri, 8 Dec 2017 19:32:37 -0500 References: <77E58FF4-5A1C-4472-9018-C97E0A4F7295@gmail.com> To: dev@airflow.incubator.apache.org In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.3445.1.7) archived-at: Sat, 09 Dec 2017 00:32:51 -0000 Hi Joy, Thank you, =E2=80=9Cairflow test=E2=80=9D does not seem like a good way = to test environment in that case :) Yes, I am running using celery executor and running the tasks in a = distributed manner. I currently set the environment variable in the hook = just before it tries to get a DB connection. We also use supervisord to manage the worker, scheduler and web server = processes and I have changed the worker=E2=80=99s env profile to set the = environment variable, but it does not work either.=20 > On Dec 8, 2017, at 2:50 PM, Joy Gao wrote: >=20 > Hi Rajesh, >=20 > `airflow test` executes the task synchronously in the same python = process > (without touching the scheduler), which is probably why it went down = the > happy path. >=20 > Are you using celery executor and running the tasks in a distributed > manner? It* sounds like* the task execution env doesn't know about the > variable. >=20 > Also depending on where you added the code to your custom hook, it may = be > in a different process from which the task is executed, since = os.environ > sets variable only for the scope/duration of the python process (and = its > children). >=20 >=20 > On Fri, Dec 8, 2017 at 7:55 AM, Rajesh Chamarthi = > wrote: >=20 >> Hi all, >>=20 >> What is the right way to set environment variables to be used in = DAGS. >> Also, is it possible to export them such that currently running = scheduler >> and worker processes can use it? >>=20 >> Context : >>=20 >> I am working on a DAG that involves making an Oracle connection, = which >> requires the LD_LIBRARY_PATH variable to be set. I added it to >> /etc/profile.d of the airflow user. When I start a new shell + python >> virtualenv and run =E2=80=9Cairflow test dag_name task_name=E2=80=9D, = the task is able to >> use the path variable above and make the necessary connection. >>=20 >> However, when it runs through the scheduler, the task fails with the >> following error : =E2=80=9COracle client library cannot be loaded=E2=80= =9D, presumably >> because it cannot read the LD_LIBRARY_PATH. >>=20 >> 2) I have also tried the following code in my custom hook, to = explicitly >> set the path. I see the same error. >>=20 >> if 'LD_LIBRARY_PATH' not in os.environ.keys(): >> os.environ['LD_LIBRARY_PATH']=3D"/opt/oracle/instantclient_11_2" >> logging.info("added ld library path", = os.environ['LD_LIBRARY_PATH']) >>=20 >> Any pointers on how I can resolve this? >>=20 >> Thanks, >> Rajesh >>=20 >>=20