Devtest init script: sourcing tripleorc fails

Bug #1335105 reported by Peter Belanyi on 2014-06-27
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tripleo
High
James Polley
tuskar-ui
Undecided
Unassigned

Bug Description

Running the devtest cloud initialization script after deploying a stack fails when trying to source tripleorc.

# ./postinstall
+ export TRIPLEO_ROOT=/root/tripleo
+ TRIPLEO_ROOT=/root/tripleo
+ cd /root/tripleo
+ source /root/tripleo/tripleorc
++ export TRIPLEO_ROOT=/root/tripleo
++ TRIPLEO_ROOT=/root/tripleo
++ export LIBVIRT_DEFAULT_URI=qemu:///system
++ LIBVIRT_DEFAULT_URI=qemu:///system
++ export LIBVIRT_NIC_DRIVER=virtio
++ LIBVIRT_NIC_DRIVER=virtio
++ export 'NODE_DIST=fedora selinux-permissive'
++ NODE_DIST='fedora selinux-permissive'
++ export 'DIB_COMMON_ELEMENTS=stackuser common-venv use-ephemeral'
++ DIB_COMMON_ELEMENTS='stackuser common-venv use-ephemeral'
++ SCRIPTS_PATH=/root/tripleo/tripleo-incubator/scripts
++ [[ ! /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin =~ (^|:)/root/tripleo/tripleo-incubator/scripts(:|$) ]]
++ export PATH=/root/tripleo/tripleo-incubator/scripts:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
++ PATH=/root/tripleo/tripleo-incubator/scripts:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
++ TIE_PATH=/root/tripleo/tripleo-image-elements/elements
/root/tripleo/tripleorc: line 13: ELEMENTS_PATH: unbound variable

James Slagle (james-slagle) wrote :

what's postinstall? is that something specific to tuskar-ui?

devtest is not typically run as root, so $TRIPLEO_ROOT also looks suspect.

Changed in tripleo:
status: New → Incomplete
Peter Belanyi (pbelanyi) wrote :

I have installed the devtest environment, then added tuskar, horizon and tuskar-ui.

From tuskar-ui I have deployed a stack, and after the successful deployment, tuskar-ui shows the "Devtest cloud initialization script" which should be used to initialize the deployment. I've copied that to "postinstall" and run it.

ELEMENTS_PATH is not defined when tripleorc is sourced, which is usually silently ignored, but postinstall uses "set -u" which makes bash report an error about the unbound variable.

Adding export ELEMENTS_PATH="" to the postinstall script before importing tripleorc seems to solve the problem, but I'm not sure that's the right solution.

Fix proposed to branch: master
Review: https://review.openstack.org/105968

Changed in tripleo:
assignee: nobody → James Polley (tchaypo)
status: Incomplete → In Progress
James Polley (tchaypo) wrote :

Most of our scripts use -u so I think it makes sense that tripleorc should be safe to use in that context.

pushed a patch which I *think* should fix the issue. However, I don't think it won't edit an existing .tripleorc, so you'll have to move the existing file aside before this can work.

Changed in tripleo:
importance: Undecided → High

Reviewed: https://review.openstack.org/105968
Committed: https://git.openstack.org/cgit/openstack/tripleo-incubator/commit/?id=47e80890d43d4319a32c3fe6f3d550f5808159a0
Submitter: Jenkins
Branch: master

commit 47e80890d43d4319a32c3fe6f3d550f5808159a0
Author: James Polley <email address hidden>
Date: Thu Jul 10 07:35:18 2014 +0200

    Make the tripleorc file set -u safe

    We have had reports that when tripleorc is sourced by scripts which are
    set -u (such as the "Devtest cloud initialization script" created by
    Tuskar), execution is aborted because $ELEMENT_PATH is referenced before
    it is set.

    This change makes the first reference to $ELEMENT_PATH set -u safe - if
    it's not set an empty string will be returned and the next line of code
    will set it.

    Change-Id: I0329fd4bdb6b5e360cf2464def6bace655827944
    Closes-Bug: #1335105

Changed in tripleo:
status: In Progress → Fix Released
Ana Krivokapić (akrivoka) wrote :

This is no longer an issue in the UI.

Changed in tuskar-ui:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers