Credential names with spaces are invalid

Bug #1642226 reported by Caio Begotti
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Released
Medium
Anastasia
2.0
Won't Fix
Undecided
Unassigned
2.6
Fix Released
Medium
Anastasia

Bug Description

I just tried to spin up Juju 2.0 on Google Compute Engine and bootstrapping it failed miserably like so, and I assume it was due to the bad credential ID name with a blank space in it. I tested it using the actual project ID string from GCE and it worked alright so I would expect Juju's code to actually test the ID is a valid one before bootstrapping it, maybe by matching what's inside the credentials YAML file and the ID inside my downloaded credentials JSON... either that or updating the docs to make all that clearer, since it requires user input to specify the ID when running juju add-credential.

You can see the version of Juju I am running on Xenial in the output below by the way:

2016-11-16 11:12:08 CRITICAL juju.cmd.jujud main.go:180 Unhandled panic:
"google/admin/Juju GCE" is not a valid cloud credential ID
goroutine 1 [running]:
main.Main.func1()
 /build/juju-core-F4_m6w/juju-core-2.0.1/src/github.com/juju/juju/cmd/jujud/main.go:179 +0xa6
panic(0x2184140, 0xc8200d9ff0)
 /usr/lib/go-1.6/src/runtime/panic.go:443 +0x4e9
gopkg.in/juju/names%2ev2.NewCloudCredentialTag(0xc8205262c0, 0x15, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
 /build/juju-core-F4_m6w/juju-core-2.0.1/src/gopkg.in/juju/names.v2/cloudcredential.go:74 +0x1f8
github.com/juju/juju/agent/agentbootstrap.InitializeState(0x30e3738, 0x5, 0x0, 0x0, 0x7f7de3b8d980, 0xc820418dc0, 0xc8203abbe0, 0xc820337798, 0x6, 0xc820440c20, ...)
 /build/juju-core-F4_m6w/juju-core-2.0.1/src/github.com/juju/juju/agent/agentbootstrap/bootstrap.go:104 +0x816
main.(*BootstrapCommand).Run.func2(0x7f7de3b8d980, 0xc820418dc0, 0x0, 0x0)
 /build/juju-core-F4_m6w/juju-core-2.0.1/src/github.com/juju/juju/cmd/jujud/bootstrap.go:272 +0x510
github.com/juju/juju/cmd/jujud/agent.(*agentConf).ChangeConfig(0xc820351b00, 0xc820175000, 0x0, 0x0)
 /build/juju-core-F4_m6w/juju-core-2.0.1/src/github.com/juju/juju/cmd/jujud/agent/agent.go:101 +0xdc
main.(*BootstrapCommand).Run(0xc820351b30, 0xc820328a50, 0x0, 0x0)
 /build/juju-core-F4_m6w/juju-core-2.0.1/src/github.com/juju/juju/cmd/jujud/bootstrap.go:274 +0x1c99
github.com/juju/cmd.(*SuperCommand).Run(0xc820403c20, 0xc820328a50, 0x0, 0x0)
 /build/juju-core-F4_m6w/juju-core-2.0.1/src/github.com/juju/cmd/supercommand.go:456 +0x688
github.com/juju/cmd.Main(0x7f7de3b76370, 0xc820403c20, 0xc820328a50, 0xc82000a110, 0x7, 0x7, 0x0)
 /build/juju-core-F4_m6w/juju-core-2.0.1/src/github.com/juju/cmd/cmd.go:280 +0x2f0
main.jujuDMain(0xc82000a100, 0x8, 0x8, 0xc820328a50, 0x0, 0x0, 0x0)
 /build/juju-core-F4_m6w/juju-core-2.0.1/src/github.com/juju/juju/cmd/jujud/main.go:162 +0xf89
main.Main(0xc82000a100, 0x8, 0x8, 0x0)
 /build/juju-core-F4_m6w/juju-core-2.0.1/src/github.com/juju/juju/cmd/jujud/main.go:195 +0x675
main.MainWrapper(0xc82000a100, 0x8, 0x8)
 /build/juju-core-F4_m6w/juju-core-2.0.1/src/github.com/juju/juju/cmd/jujud/main.go:170 +0x35
main.main()
 /build/juju-core-F4_m6w/juju-core-2.0.1/src/github.com/juju/juju/cmd/jujud/main_nix.go:22 +0x3b

Changed in juju:
status: New → Triaged
importance: Undecided → Critical
milestone: none → 2.1.0
Changed in juju:
assignee: nobody → Richard Harding (rharding)
importance: Critical → High
Revision history for this message
Anastasia (anastasia-macmood) wrote :

We should not panic but error out gracefully. Lowering priority as it is being tackled right now as part of related work for this milestone.

Changed in juju:
assignee: Richard Harding (rharding) → nobody
Revision history for this message
Anastasia (anastasia-macmood) wrote :

I can reproduce it on 2.1-rc2.

I created a credential with space in the name using 'juju add-credential'

then

$ juju bootstrap google mygoogle --credential="invalid one"

Note that the panic occurs late in bootstrap process, after replicaset is initiated and mongo started. We should validate credential name and exclude spaces.

I will mark this as Won't Fix in 2.0 as we are not planning any further releases of 2.0.x.

Changed in juju:
importance: High → Medium
milestone: 2.1-rc2 → none
tags: added: eda gce-provider requires-functional-test
Revision history for this message
Anastasia (anastasia-macmood) wrote :

Since the last time this report was looked at, things have improved - users can no longer add credentials with a space in the name.

$ juju add-credential google
Enter credential name: new one
Invalid credential name: "new one"

Enter credential name:

And if somehow a credential name with space is already stored locally, 'juju bootstrap' will not panic. It will try to bootstrap and will fail advising the user "ERROR cloud credential ID "google/admin/new one" not valid". However, this failure is late in bootstrap process and can be improved. I'll work on that.

I am also pondering if we should be flagging ti to the user earlier. For example, right now I can still see this credential with an invalid name listed:

$ juju credentials

Cloud Credentials
......
google new one
.......

Although, maybe it is ok to just list whatever credentials users have locally or remotely regardless of whether they are sound or valid. We still prevent users from using badly formed ones and this is more important.

Revision history for this message
Anastasia (anastasia-macmood) wrote :
summary: - Unhandled panic when bootstrapping on Google Compute Engine
+ Credential names with spaces are invalid
Changed in juju:
status: Triaged → In Progress
assignee: nobody → Anastasia (anastasia-macmood)
Changed in juju:
status: In Progress → Fix Committed
milestone: none → 2.7-beta1
Changed in juju:
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.