init system discovery script fails with: [[: not found

Bug #1457011 reported by Dimiter Naydenov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
juju-core
Fix Released
High
Eric Snow
1.23
Fix Released
High
Eric Snow
1.24
Fix Released
High
Eric Snow

Bug Description

On 1.24 after https://github.com/juju/juju/pull/2359 has landed (surprisingly not on master, despite the same fix was ported as https://github.com/juju/juju/pull/2358) I see errors during the cloud-init phase: http://paste.ubuntu.com/11243099/ that's due to two things I've discovered:
1. the runcmd script cloud-init generates from the given user-data starts with a "#!/bin/sh" shebang.
2. the init_system=$(...) line contains a bash-specific script, which is just inlined (see an excerpt of the user-data - http://paste.ubuntu.com/11243163/), but the "#!/usr/bin/env bash" shebang coming from juju/utils/shell/bash.go's RenderScript is getting ignored in this case (treated as a comment), and the script actually executes using /bin/sh (the system non-interactive shell dash rather than bash, since 2006).

If I apply the following patch it works without errors: http://paste.ubuntu.com/11243524/

We need to be careful when using "bashisms" in scripts and only do so when we're generating a script file to run, not when inlining scripts run (most likely) by /bin/sh in cloud-init runcmds.

UPDATE: #2359 was reverted from 1.24, but the problem is still there I believe, and master should be affected as well.

Revision history for this message
Eric Snow (ericsnowcurrently) wrote :
Revision history for this message
Eric Snow (ericsnowcurrently) wrote :

That should have been 1.24/master.

Changed in juju-core:
status: Triaged → In Progress
assignee: nobody → Eric Snow (ericsnowcurrently)
Changed in juju-core:
status: In Progress → Fix Committed
Curtis Hovey (sinzui)
tags: added: tech-debt
Curtis Hovey (sinzui)
Changed in juju-core:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.