RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1378091 - atomic scan fails when run in cron
Summary: atomic scan fails when run in cron
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: atomic
Version: 7.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Lokesh Mandvekar
QA Contact: atomic-bugs@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-09-21 13:15 UTC by Marek Haicman
Modified: 2016-12-06 17:41 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-12-06 17:41:59 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:2857 0 normal SHIPPED_LIVE atomic bug fix and enhancement update 2016-12-06 22:40:27 UTC

Description Marek Haicman 2016-09-21 13:15:20 UTC
Description of problem:
When running `atomic scan' in cron, command fails with "[Errno 2] No such file or directory"


Version-Release number of selected component (if applicable):
atomic-1.12.3-2.el7.x86_64

How reproducible:
reliably

Steps to Reproduce:
1. start docker
2. docker pull rhel7 (to have a target)
3. in root cron, add "* * * * * atomic --debug scan --images"
4. wait for 1+ minute
5. look into /var/spool/mail/root


Actual results:
command does not report scan results

Expected results:
command reports scan results

Additional info:
output of `atomic --debug scan --images':


Created /run/atomic/2016-09-21-15-09-01-548951
docker run -t --rm -v /etc/localtime:/etc/localtime -v /run/atomic/2016-09-21-15-09-01-548951:/scanin -v /var/lib/atomic/openscap/2016-09-21-15-09-01-548951:/scanout:rw,Z -v /etc/oscapd:/etc/oscapd:ro rhel7/openscap oscapd-evaluate scan --no-standard-compliance --targets chroots-in-dir:///scanin --output /scanout
Created /run/atomic/2016-09-21-15-09-01-548951/c54a2cc56cbb2f04003c1cd4507e118af7c0d340fe7e2720f70976c4b75237dc
[Errno 2] No such file or directory
Unmounted /run/atomic/2016-09-21-15-09-01-548951/c54a2cc56cbb2f04003c1cd4507e118af7c0d340fe7e2720f70976c4b75237dc
Traceback (most recent call last):
  File "/usr/bin/atomic", line 186, in <module>
    sys.exit(_func())
  File "/usr/lib/python2.7/site-packages/Atomic/scan.py", line 156, in scan
    self._mount_scan_rootfs(scan_list)
  File "/usr/lib/python2.7/site-packages/Atomic/scan.py", line 244, in _mount_scan_rootfs
    self.mount(mountpoint=mount_path, image=docker_object['Id'])
  File "/usr/lib/python2.7/site-packages/Atomic/scan.py", line 455, in mount
    m.mount()
  File "/usr/lib/python2.7/site-packages/Atomic/mount.py", line 141, in mount
    d.mount(self.image, self.options)
  File "/usr/lib/python2.7/site-packages/Atomic/mount.py", line 417, in mount
    driver_mount_fn(identifier, options)
  File "/usr/lib/python2.7/site-packages/Atomic/mount.py", line 503, in _mount_devicemapper
    dm_pool)
  File "/usr/lib/python2.7/site-packages/Atomic/mount.py", line 180, in _activate_thin_device
    r = util.subp(cmd)
  File "/usr/lib/python2.7/site-packages/Atomic/util.py", line 109, in subp
    universal_newlines=newline)
  File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Comment 6 Marek Haicman 2016-09-22 07:53:19 UTC
As the issue was triggered by cron environment, simpler reproducer is:

env -i 'USER=root
PATH=/usr/bin:/bin
PWD=/root
LANG=en_US.UTF-8
SHLVL=1
HOME=/root
LOGNAME=root
XDG_RUNTIME_DIR=/run/user/0
_=/usr/bin/env
' atomic --debug scan --images

Quick workaround is to set cron PATH to
PATH=/usr/bin:/bin:/usr/sbin

But even though user currently can guess there is a problem with PATH [as usual when dealing with cron], there is no indication which binary is actually not found.

So from my perspective, it is sufficient to print clearly worded error, like
"error: dmsetup binary not found" to consider this bug fixed.

Comment 7 Daniel Walsh 2016-09-22 13:26:57 UTC
We should fully path dmsetup then.

Comment 9 Daniel Walsh 2016-10-06 18:05:01 UTC
Fixed in  atomic-1.12.5-2.el7.x86_64

Comment 11 Alex Jia 2016-11-03 02:40:41 UTC
To move the bug to VERIFIED status per Comment 8 and my actual testing in atomic-1.12.5-2.el7.x86_64

Comment 13 errata-xmlrpc 2016-12-06 17:41:59 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2857.html


Note You need to log in before you can comment on or make changes to this bug.