Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1239088

Summary: [RFE] python-rdomanager-oscplugin failing as root after a long wait
Product: Red Hat OpenStack Reporter: Attila Fazekas <afazekas>
Component: python-tripleoclientAssignee: RHOS Maint <rhos-maint>
Status: CLOSED ERRATA QA Contact: Alexander Chuzhoy <sasha>
Severity: unspecified Docs Contact:
Priority: low    
Version: 5.0 (RHEL 7)CC: achernet, gtrellu, hbrock, jslagle, kshileev, maufart, mburns, rhel-osp-director-maint, sasha, shardy, vcojot
Target Milestone: gaKeywords: FutureFeature, Triaged, UserExperience, ZStream
Target Release: 8.0 (Liberty)   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-tripleoclient-0.1.1-1.el7ost Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-04-07 21:38:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Attila Fazekas 2015-07-03 13:06:46 UTC
Description of problem:

python-rdomanager-oscplugin is failing as root after a long wait.
The documentation contains a sudo to stack command before this step,
but it's behavior when I try to run it as root is harsh.

The command does almost all step (very long time) and at the close to the end it just stop working.

The usual practice around openstack, is all script which does not meant to be run as root refuses to start at the beginning.


Version-Release number of selected component (if applicable):
python-rdomanager-oscplugin-0.0.8-18.el7ost.noarch

How reproducible:
always

Steps to Reproduce:
1. Login as root
2. openstack undercloud install
 

Actual results:
--------------------- END PROFILING ---------------------
[2015-07-03 08:33:18,241] (os-refresh-config) [INFO] Completed phase post-configure
os-refresh-config completed successfully
Copy stackrc failed: cp: ‘/root/stackrc’ and ‘/root/stackrc’ are the same file

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/instack_undercloud/undercloud.py", line 510, in install
    _configure_ssh_keys()
  File "/usr/lib/python2.7/site-packages/instack_undercloud/undercloud.py", line 476, in _configure_ssh_keys
    _run_command(args, name='Copy stackrc')
  File "/usr/lib/python2.7/site-packages/instack_undercloud/undercloud.py", line 259, in _run_command
    env=env)
  File "/usr/lib64/python2.7/subprocess.py", line 575, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['sudo', 'cp', '/root/stackrc', '/root']' returned non-zero exit status 1
ERROR: openstack Command 'instack-install-undercloud' returned non-zero exit status 1
[root@instack ~]# openstack undercloud install

Expected results:
The command refuses to even start as root.

Additional info:
Example behavior of another os command.:

# instack-virt-setup 
This script cannot be run as root.

Comment 3 chris alfonso 2015-07-06 16:08:10 UTC
Do not run this as root. We should RFE to detect which user is running and exit with a warning.

Comment 5 chris alfonso 2015-07-06 16:08:34 UTC
*** Bug 1239091 has been marked as a duplicate of this bug. ***

Comment 6 Mike Burns 2015-07-17 16:53:08 UTC
*** Bug 1244235 has been marked as a duplicate of this bug. ***

Comment 7 Kirill Shileev 2015-10-08 16:59:33 UTC
sudo openstack undercloud install
leads to the same problem

Comment 9 Gaëtan Trellu 2015-12-01 16:57:48 UTC
By same I mean, logged as stack user and ran the sudo command.

Comment 10 Gaëtan Trellu 2015-12-01 18:39:13 UTC
It seems that we have an issue with sudo ENV variables.
A quick dirty workaround to make it works:

--- undercloud.py	2015-12-01 12:22:27.195251645 -0500
+++ /usr/lib/python2.7/site-packages/instack_undercloud/undercloud.py	2015-12-01 12:33:05.413542296 -0500
@@ -476,21 +476,22 @@
 
 
 def _configure_ssh_keys():
+    username= os.environ["LOGNAME"]
     """Configure default ssh keypair in Nova
 
     Generates a new ssh key for the current user if one does not already
     exist, then uploads that to Nova as the 'default' keypair.
     """
-    id_path = os.path.expanduser('~/.ssh/id_rsa')
+    id_path = os.path.expanduser('/home/stack/.ssh/id_rsa')
     if not os.path.isfile(id_path):
         args = ['ssh-keygen', '-t', 'rsa', '-N', '', '-f', id_path]
         _run_command(args)
         LOG.info('Generated new ssh key in ~/.ssh/id_rsa')
 
-    args = ['sudo', 'cp', '/root/stackrc', os.path.expanduser('~')]
+    args = ['sudo', 'cp', '/root/stackrc', os.path.expanduser('/home/stack/')]
     _run_command(args, name='Copy stackrc')
     args = ['sudo', 'chown', getpass.getuser() + ':',
-            os.path.expanduser('~/stackrc')]
+            os.path.expanduser('/home/stack/stackrc')]
     _run_command(args, name='Chown stackrc')
     password = _run_command(['sudo', 'hiera', 'admin_password']).rstrip()
     user = _extract_from_stackrc('OS_USERNAME')

Comment 13 Alexander Chuzhoy 2016-03-09 17:34:50 UTC
Verified:
Environment:
python-tripleoclient-0.1.1-4.el7ost.noarch

openstack undercloud install
This command cannot run under root user. Switch to a normal user.

Comment 14 Vincent S. Cojot 2016-03-24 04:45:06 UTC
Hello,
I am seeing that with the latest 7-director puddle (as today 20160323).
I am running 'openstack undercloud install' as the 'stack' user.
I am getting this output at the end of the unercloud install run:

----------------------- PROFILING -----------------------

Target: post-configure.d

Script                                     Seconds
---------------------------------------  ----------

10-tftp-iptables                              1.160
100-tuskar-api                                0.380
101-plan-add-roles                           58.665
68-ironic-conductor                           1.152
80-seedstack-masquerade                       0.041
98-undercloud-setup                          73.938
99-admin-swiftoperator-role                   2.647
99-refresh-completed                          0.774
99-restart-discovery                          0.651

--------------------- END PROFILING ---------------------
[2016-03-24 00:37:02,932] (os-refresh-config) [INFO] Completed phase post-configure
os-refresh-config completed successfully
Generated new ssh key in ~/.ssh/id_rsa
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/instack_undercloud/undercloud.py", line 527, in install
    _configure_ssh_keys()
  File "/usr/lib/python2.7/site-packages/instack_undercloud/undercloud.py", line 503, in _configure_ssh_keys
    nova.keypairs.get('default')
  File "/usr/lib/python2.7/site-packages/novaclient/v2/keypairs.py", line 66, in get
    "keypair")
  File "/usr/lib/python2.7/site-packages/novaclient/base.py", line 156, in _get
    _resp, body = self.api.client.get(url)
  File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 444, in get
    return self._cs_request(url, 'GET', **kwargs)
  File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 398, in _cs_request
    self.authenticate()
  File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 553, in authenticate
    auth_url = self._v2_auth(auth_url)
  File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 644, in _v2_auth
    return self._authenticate(url, body)
  File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 657, in _authenticate
    **kwargs)
  File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 393, in _time_request
    resp, body = self.request(url, method, **kwargs)
  File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 387, in request
    raise exceptions.from_response(resp, body, url, method)
novaclient.exceptions.ClientException: Unknown Error (HTTP 504)
ERROR: openstack Command 'instack-install-undercloud' returned non-zero exit status 1

Comment 15 Vincent S. Cojot 2016-03-24 04:45:34 UTC
[stack@instack ~]$ rpm -q python-rdomanager-oscplugin
python-rdomanager-oscplugin-0.0.10-28.el7ost.noarch

Comment 16 Vincent S. Cojot 2016-03-24 04:45:42 UTC
[stack@instack ~]$ rpm -q python-rdomanager-oscplugin
python-rdomanager-oscplugin-0.0.10-28.el7ost.noarch

Comment 17 Vincent S. Cojot 2016-03-24 04:47:30 UTC
SElinux was in 'permissive' mode.

Comment 19 errata-xmlrpc 2016-04-07 21:38:10 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/RHEA-2016-0604.html