Closed Bug 753291 Opened 12 years ago Closed 7 years ago

mock should fail if it doesn't install a dependency

Categories

(Release Engineering :: General, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: catlee, Unassigned)

References

Details

(Whiteboard: [mock])

right now mock silently passes if it fails to install a specified dependency. e.g. if you want it to install 'libstdc++-static' but that package doesn't exist in the configured yum repositories, then mock should fail instead of passing.
Priority: -- → P3
I did some testing and yum does not return a non-zero exit code if a package is not found because it treats package names as wildcards when they are not found.  Therefore we're going to need to search the yum output for a "No package foo available" message and fail accordingly.

The yumInstall routine doesn't look at the output generated by yum but it does use logger.  While it would be possible to add a filter hook to the log output, this would break if the log level was set to fatal error only, for example (since we wouldn't get the info-level messages containing the yum output).

Perhaps we could add an argument to yumInstall 'failIfNotFound=False' and do some log parsing right in the function.  Other ideas?
Product: mozilla.org → Release Engineering
(In reply to John Hopkins (:jhopkins) from comment #1)

> Perhaps we could add an argument to yumInstall 'failIfNotFound=False' and do
> some log parsing right in the function.  Other ideas?

Thanks to :simone and :dustin for diving into this! Just summarising their results here...

The non-zero return code for failed installs seems to be working at least in yum 3.2.29 (maybe also earlier versions).

If it is possible to upgrade the yum version used in the mock environment, maybe the output of the yum commands does not need to be parsed, after all, and the existing mozharness implementation will work *as is* with no change (?), since it already has "halt_on_failure=True":

http://hg.mozilla.org/build/mozharness/file/2092f46dc264/mozharness/mozilla/mock.py#l43

In other words, a failed install should result in the mozharness script terminating.

If a yum upgrade isn't feasible, I would agree output needs to be parsed, as John suggested.

#### example non-zero exit code using yum 3.2.29 provided by dustin:

dmitchell@releng-puppet2 /etc/puppet/environments/dmitchell [bug1022763] $ sudo su -
[root@releng-puppet2.srv.releng.scl3.mozilla.com ~]# yum install simonebruno
Loaded plugins: security
Setting up Install Process
No package simonebruno available.
Error: Nothing to do
[root@releng-puppet2.srv.releng.scl3.mozilla.com ~]# echo $?
1

##### yum version:

[root@releng-puppet2.srv.releng.scl3.mozilla.com ~]# yum --version
3.2.29
  Installed: rpm-4.8.0-37.el6.x86_64 at 2014-03-18 20:02
  Built    : CentOS BuildSystem <http://bugs.centos.org> at 2013-11-22 11:38
  Committed: Panu Matilainen <pmatilai@redhat.com> at 2013-09-12

  Installed: yum-3.2.29-43.el6.centos.noarch at 2014-03-18 20:02
  Built    : CentOS BuildSystem <http://bugs.centos.org> at 2013-12-17 12:27
  Committed: Johnny Hughes <johnny@centos.org> at 2013-12-17
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INCOMPLETE
Component: General Automation → General
You need to log in before you can comment on or make changes to this bug.