Plugin API fails with multiple juju binaries

Bug #1567296 reported by Stuart Bishop
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Released
High
Unassigned

Bug Description

No matter if I run 'juju1 wait' or 'juju2 wait' or 'juju wait', the juju-wait executable on the path is invoked. It has no idea which juju executable invoked it, so it has no idea what juju binary to use to actually do anything useful. It will likely run the wrong one, and fail.

One approach is to provide a way for the plugin to know which juju to use, such as an environment variable. This approach requires all plugins to be updated.

An alternative approach is to mess with the path, so the first 'juju' found in the $PATH is the correct one. This approach means many plugins will continue to work unmodified. Note that this could be done with a temporary directory and a symlink.

Yet another approach is to make juju(1) a thin wrapper that invokes the correct juju based on some user configuration (eg. an environment variable). This not only would fix the plugin API, but would also allow test suites, deployment scripts and CI systems to continue to work unmodified in many cases.

Changed in juju-core:
status: New → Triaged
importance: Undecided → High
milestone: none → 2.0-beta4
Changed in juju-core:
milestone: 2.0-beta4 → 2.0-rc1
Revision history for this message
Stuart Bishop (stub) wrote :

As a work around, Python plugins can do the following to discover the juju executable and juju version in play by introspecting the parent process id:

import psutil
import subprocess
juju_exe = psutil.Process(os.getppid()).exe()
juju_ver = subprocess.check_output([juju_exe, '--version'], universal_newlines=True).strip()

Revision history for this message
Stuart Bishop (stub) wrote :

The second option I listed already seems to be implemented, and when I run 'juju-1 foo', the PATH is updated before invoking the juju-foo script and the correct 'juju' binary is found.

Which may be considered good enough to close this bug.

Revision history for this message
Cheryl Jennings (cherylj) wrote :

stub - we're going to have slightly different packaging for the next release. Once we release beta5, can you reconfirm that it works for you? (it should be today)

Curtis Hovey (sinzui)
Changed in juju-core:
milestone: 2.0-beta5 → 2.0-rc1
Revision history for this message
Stuart Bishop (stub) wrote :

I can confirm this is still working with 2.0beta5 and 1.25:

$ cat juju-ver
#!/bin/sh
juju --version
$ juju-1 ver
1.25.5-xenial-amd64
$ juju ver
2.0-beta5-xenial-amd64

As long as this behaviour is preserved, plugins have what they need to support juju1, juju2 or both and existing juju plugins will continue to work using juju-1 under Xenial.

Changed in juju-core:
status: Triaged → Fix Released
affects: juju-core → juju
Changed in juju:
milestone: 2.0-beta6 → none
milestone: none → 2.0-beta6
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.