Bug #4198
closedCf-execd started by cron is missing environment variables, making the agent unable to run correctly
Description
Created a fresh VM, installed minimal Ubuntu 12.04.3 server, added repo and installed rudder-agent (2.6.9) package.
Even though the installation doesn't start the agent, after a while it will be started by the newly added cron job.
Cron sets a very minimal environment for the started jobs, in particular PATH=/usr/bin:/bin
. And when cron starts cf-agent and therefore cf-execd, they will inherit that PATH. This can be verified with: tr '\0' '\n' < /proc/$(pgrep cf-execd)/environ
(when started from cron).
When cf-agent is running with this PATH setting, any package installations will fail with Bulk package schedule execution failed somewhere - unknown outcome for ... error in the output. This is caused by dpkg failing because required executables are not in the search path, e.g. try (same command as cf-agent would run, but with adjusted PATH):
# /usr/bin/env PATH=/usr/bin:/bin DEBIAN_FRONTEND=noninteractive LC_ALL=C /usr/bin/aptitude \ -o Dpkg::Options::=--force-confold -o Dpkg::Options::=--force-confdef \ -o Aptitude::Delete-Unused=false -o Aptitude::CmdLine::Ignore-Trust-Violations=false \ --assume-yes install dstat The following NEW packages will be installed: dstat 0 packages upgraded, 1 newly installed, 0 to remove and 20 not upgraded. Need to get 0 B/68.1 kB of archives. After unpacking 549 kB will be used. dpkg: warning: 'ldconfig' not found in PATH or not executable. dpkg: warning: 'start-stop-daemon' not found in PATH or not executable. dpkg: error: 2 expected programs not found in PATH or not executable. Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin. E: Sub-process /usr/bin/dpkg returned an error code (2) A package failed to install. Trying to recover: dpkg: warning: 'ldconfig' not found in PATH or not executable. dpkg: warning: 'start-stop-daemon' not found in PATH or not executable. dpkg: error: 2 expected programs not found in PATH or not executable. Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin.
This doesn't happen when started as a service as then the PATH is /sbin:/usr/sbin:/bin:/usr/bin
(when started on boot by /etc/init.d/rc
) or /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
(or similar, when started from an interactive session, i.e. the init script inherits the PATH from calling environment).
A solution could be to add PATH setting to /etc/cron.d/rudder-agent
, or to body agent control in promises.cf (but this will affect all agent executions, not only cron).
Updated by Vincent MEMBRÉ almost 11 years ago
- Assignee set to Vincent MEMBRÉ
- Priority changed from N/A to 3
- Target version set to 2.4.13
Hello Mickael!
Thanks for reporting and the explanations!
As it concerns the cron-agent, it must affect 2.4 too. It must be confirm though.
To reprocuce the procedure seems:
- install rudder-agent
- configure it (/var/rudder/cfengine-community/policy_server.dat)
- wait for cron-agent to start the agent
- fails on installation of package
using rudder-vagrant and modifying provision script to not start the agent at the end should help.
Adding the PATH to cron seems a good idea to me and less invasive than modifying all techniques.
Matthieu or me should take care of this.
Updated by Vincent MEMBRÉ almost 11 years ago
- Target version changed from 2.4.13 to 2.6.11
Since version 2.4 is not maintained anymore, retargeting to branch 2.6
Updated by Matthieu CERDA over 10 years ago
- Category set to System techniques
- Status changed from New to In progress
- Assignee changed from Vincent MEMBRÉ to Matthieu CERDA
Updated by Matthieu CERDA over 10 years ago
- Subject changed from Bulk package schedule execution failed when cf-execd started from cron to Cron is starting cf-execd with missing environment variables
Updated by Matthieu CERDA over 10 years ago
- Status changed from In progress to Pending technical review
- Assignee changed from Matthieu CERDA to Jonathan CLARKE
- % Done changed from 0 to 100
- Pull Request set to https://github.com/Normation/rudder-techniques/pull/297
PR available.
Updated by Jonathan CLARKE over 10 years ago
- Assignee changed from Jonathan CLARKE to Matthieu CERDA
Updated by Matthieu CERDA over 10 years ago
- Assignee changed from Matthieu CERDA to Jonathan CLARKE
Question answered on the PR.
Updated by Matthieu CERDA over 10 years ago
- Status changed from Pending technical review to Pending release
Applied in changeset policy-templates:commit:16c35f55dd88c6a52d455d58ed1b45af4fbc67c1.
Updated by Jonathan CLARKE over 10 years ago
Applied in changeset policy-templates:commit:d61679aa55bfe2eb377d46308e081baea570cd25.
Updated by Vincent MEMBRÉ over 10 years ago
- Subject changed from Cron is starting cf-execd with missing environment variables to Cf-execd started by cron is missing environment variables, making the agent unable to run correctly
Updated by Vincent MEMBRÉ over 10 years ago
- Status changed from Pending release to Released
This bug has been fixed in Rudder 2.6.11, which was released today.
Check out:
- The release announcement: http://www.rudder-project.org/pipermail/rudder-announce/2014-March/000077.html
- The full ChangeLog: http://www.rudder-project.org/foswiki/bin/view/System/Documentation:ChangeLog26
- Download information: https://www.rudder-project.org/site/get-rudder/downloads/