arguments no longer passed to plugins if you don't have an environment set

Bug #1359170 reported by John A Meinel
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Juju Charm Tools
Invalid
Undecided
Unassigned
juju-core
Fix Released
High
Tim Penhey
1.20
Fix Released
Critical
Ian Booth

Bug Description

I'm not sure what the specific bug is, but if I'm running a development version of Juju, I end up with:
$ juju charm create
usage: /usr/bin/juju-charm subcommand

  Available subcommands are:
    admin
    create
    get
    getall
    list
    promulgate
    proof
    review
    review-queue
    search
    subscribers
    unpromulgate
    update
ERROR subprocess encountered error code 1

Note that I ran "juju charm create" and it tells me that it is one of the subcommands, but it doesn't actually work.

Now if I run:
/usr/bin/juju charm create
I get a nice help text:
usage: charm-create [-h] charmname [charmhome]
charm-create: error: too few arguments

Also, even if I use the right syntax, charm create doesn't actually work with Dev juju:
$ juju charm create foobar
usage: /usr/bin/juju-charm subcommand

  Available subcommands are:
    admin
    create
...

It turns out that this is because of environCommandWrapper which *requires* that an environment is set for the command. I don't have a default Environment. If I run it with an environment it works:
$ juju args -e local a b
['/home/jameinel/dev/go/bin/juju-args', '-e', 'local', 'a', 'b']

Revision history for this message
John A Meinel (jameinel) wrote :

So if I hack "juju-charm" to print out sys.argv I get:
$ /usr/bin/juju charm create -h
args ['/usr/bin/juju-charm', 'create', '-h']
vs
$ juju charm create -h
args ['/usr/bin/juju-charm']

So I think this is just a critical regression in core where we used to pass along arguments to plugins, and we stopped doing so.

Changed in juju-core:
importance: Undecided → Critical
status: New → Triaged
milestone: none → 1.21-alpha1
Revision history for this message
John A Meinel (jameinel) wrote :

I just tested juju 1.20 (built from source), and it fails in the same way.

summary: - juju charm create fails in an unhelpful fashion with juju-1.21 in PATH
+ arguments no longer passed to plugins
Changed in charm-tools:
status: New → Invalid
Changed in juju-core:
assignee: nobody → John A Meinel (jameinel)
tags: added: regression
Revision history for this message
John A Meinel (jameinel) wrote : Re: arguments no longer passed to plugins

To test this, I have the following plugin in my path:
$ cat ~/dev/go/bin/juju-args
#!/usr/bin/python

import sys
print sys.argv

$ /usr/bin/juju args a b; /usr/bin/juju --version
['/home/jameinel/dev/go/bin/juju-args', 'a', 'b']
1.18.1-trusty-amd64

$ juju args a b; juju --version
['/home/jameinel/dev/go/bin/juju-args']
1.20.6-trusty-amd64

Revision history for this message
John A Meinel (jameinel) wrote :

So it looks like this is caused by having this code:
line 51 plugin.go:
 plugin := envcmd.Wrap(&PluginCommand{name: cmdName})

Specifically, we are wrapping PluginCommand into an environCommandWrapper, and environCommandWrapper has its own Init function. and in *that* code we have:

func (w *environCommandWrapper) Init(args []string) error {
 if err := w.ensureEnvName(); err != nil {
  return err
 }
 w.SetEnvName(w.envName)
 return w.EnvironCommand.Init(args)
}

And that *only* succeeds if you have an environment set.
I personally do *not* have a default environment, I always specify it when I want to do something (juju bootstrap -e foo, juju deploy -e foo ubuntu, etc).

As such, there is no environment, but these plugins don't *need* an environment, it actually does nothing with them.
Note that not all plugins are ok without an environment (for example juju backup needs an environment), but the plugin should get to decide.

description: updated
Revision history for this message
John A Meinel (jameinel) wrote :

The other issue is that on line 67 of plugin.go we do:
 plugin.Init(args)
Which means we are ignoring the fact that environCommandWrapper is returning an error and assuming everything is ok.

Which it *is* ok except we didn't end up initializing the plugin arguments like we thought we were doing.

John A Meinel (jameinel)
summary: - arguments no longer passed to plugins
+ arguments no longer passed to plugins if you don't have an environment
+ set
Tim Penhey (thumper)
Changed in juju-core:
assignee: John A Meinel (jameinel) → Tim Penhey (thumper)
importance: Critical → High
tags: removed: regression
Revision history for this message
John A Meinel (jameinel) wrote : Re: [Bug 1359170] Re: arguments no longer passed to plugins if you don't have an environment set

FWIW, this *is* a regression.
juju charm create works with 1.18 but *fails* with 1.20.

On Thu, Aug 21, 2014 at 5:05 AM, Tim Penhey <email address hidden>
wrote:

> ** Changed in: juju-core
> Assignee: John A Meinel (jameinel) => Tim Penhey (thumper)
>
> ** Changed in: juju-core
> Importance: Critical => High
>
> ** Changed in: juju-core/1.20
> Importance: Critical => High
>
> ** Tags removed: regression
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1359170
>
> Title:
> arguments no longer passed to plugins if you don't have an environment
> set
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/charm-tools/+bug/1359170/+subscriptions
>

Revision history for this message
John A Meinel (jameinel) wrote :

I suppose you could contend that my method of working doesn't occur in the
wild? And so while it is a clear regression for *me* nobody else would run
into it?

John
=:->

On Thu, Aug 21, 2014 at 11:59 AM, John Meinel <email address hidden>
wrote:

> FWIW, this *is* a regression.
> juju charm create works with 1.18 but *fails* with 1.20.
>
>
>
> On Thu, Aug 21, 2014 at 5:05 AM, Tim Penhey <email address hidden>
> wrote:
>
>> ** Changed in: juju-core
>> Assignee: John A Meinel (jameinel) => Tim Penhey (thumper)
>>
>> ** Changed in: juju-core
>> Importance: Critical => High
>>
>> ** Changed in: juju-core/1.20
>> Importance: Critical => High
>>
>> ** Tags removed: regression
>>
>> --
>> You received this bug notification because you are subscribed to the bug
>> report.
>> https://bugs.launchpad.net/bugs/1359170
>>
>> Title:
>> arguments no longer passed to plugins if you don't have an environment
>> set
>>
>> To manage notifications about this bug go to:
>> https://bugs.launchpad.net/charm-tools/+bug/1359170/+subscriptions
>>
>
>

Revision history for this message
Tim Penhey (thumper) wrote :

On 21/08/14 20:01, John A Meinel wrote:
> I suppose you could contend that my method of working doesn't occur in the
> wild? And so while it is a clear regression for *me* nobody else would run
> into it?
>
> John
> =:->

Sorry, I hadn't realised that it used to work with 1.18. The envcmd
work must have happened during 1.20 then.

My fix has landed on master, but not on the 1.20 branch.

Tim

Ian Booth (wallyworld)
Changed in juju-core:
status: Triaged → Fix Committed
Curtis Hovey (sinzui)
tags: added: charms ci regression
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.