Project

General

Profile

Bug #25739

katello-rhsm-consumer can fail, breaking the isntallation of katello-ca-consumer.rpm

Added by Evgeni Golov 8 months ago. Updated 8 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Client/Agent
Target version:
Difficulty:
Triaged:
Yes
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

I have a host (well, container), where hostname -f returns an error:

[root@a8cc0652a1a1 ~]# hostname
a8cc0652a1a1
[root@a8cc0652a1a1 ~]# hostname -f
hostname.orig: Unknown host
[root@a8cc0652a1a1 ~]# echo $?
1

This results in katello-rhsm-consumer failing when executed:

[root@a8cc0652a1a1 ~]# /usr/bin/katello-rhsm-consumer
hostname: Unknown host
[root@a8cc0652a1a1 ~]# echo $?
1

Which in turn makes %post of katello-ca-consumer.rpm fail:

# rpm -Uvh http://katello.example.com/pub/katello-ca-consumer-latest.noarch.rpm

Retrieving http://katello.example.com/pub/katello-ca-consumer-latest.noarch.rpm
Preparing...                ##################################################
katello-ca-consumer-katello.##################################################
hostname: Unknown host
error: %post(katello-ca-consumer-katello.example.com-1.0-3.noarch) scriptlet failed, exit status 1

The problem here is that katello-rhsm-consumer is executed with set -e (which is good in general!), which makes it fail on the first subprocess fail instead of allowing us to handle the failure ourself.

Associated revisions

Revision f5397553 (diff)
Added by Evgeni Golov 8 months ago

Fixes #25739 - don't allow statements to fail in an set -e script

When a bash script is executed with `set -e`, it will fail immediately
when a subcommand fails. From bash(1):

-e    Exit immediately if a pipeline (which may consist of a single
simple command), a list, or a compound command (see SHELL
GRAMMAR above), exits with a non-zero status.

Running scripts with `-e` is generally a good idea, but this means that
we can't allow subcommands to fail anymore and then handle the error
case based on `$?`.

This commit replaces the two places where we relied on the value of `$?`
with code that will never fail and at least return a dummy value which
we then can act on.

History

#1 Updated by Evgeni Golov 8 months ago

This was introduced in puppet-certs:f188ea02d18ab8c0db2f1236a61af7a7a5ecd5dc

#2 Updated by Evgeni Golov 8 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/puppet-certs/pull/234 added

#3 Updated by Ewoud Kohl van Wijngaarden 8 months ago

  • Found in Releases Katello 3.11.0 added
  • Fixed in Releases Katello 3.11.0 added

#4 Updated by Evgeni Golov 8 months ago

  • Status changed from Ready For Testing to Closed

#5 Updated by Justin Sherrill 8 months ago

  • Triaged changed from No to Yes
  • Target version set to Katello 3.11.0

Also available in: Atom PDF