more than 10 upgrades to a charm causes horrible infinite loop

Bug #1197369 reported by David Jones
30
This bug affects 4 people
Affects Status Importance Assigned to Milestone
juju-core
Fix Released
High
Roger Peppe

Bug Description

Over the course of a few days, one of our machines had its charm upgraded, turns out that the 11th upgrade went wrong and resulted in an infinite loop which was pretty tricky to recover from.

Got this in my juju debug-log

custard-dev-0:2013/07/03 10:18:17 INFO worker/uniter/charm: download verified
custard-dev-0:2013/07/03 10:18:17 DEBUG worker/uniter: ModeUpgrading local:raring/custard-302 exiting
custard-dev-0:2013/07/03 10:18:17 NOTICE worker/uniter: unit "custard-dev/0" shutting down: ModeUpgrading local:raring/custard-302: failed to create "/var/lib/juju/agents/unit-custard-dev-0/state/deployer/update-%Y%m%d-%H%M%S-9": mkdir /var/lib/juju/agents/unit-custard-dev-0/state/deployer/update-%Y%m%d-%H%M%S-9: file exists

The strftime() style formatting in the filename is suspicious.

I think the newDir function in the deployer.go file is wrong: http://bazaar.launchpad.net/~go-bot/juju-core/trunk/view/head:/worker/uniter/charm/deployer.go#L188

instead of

time.Now().Format("-%Y%m%d-%H%M%S")

the following would be better:

time.Now().UTC().Format(time.RFC3339)

Here's the go code I used to work out how the Time class works (it's my first go program): https://gist.github.com/drj11/5917057

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

A nice place to test out go code is at: http:play.golang.org

It will run queries server side and let you share the results.
http://play.golang.org/p/1C5k3aFKmI

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

If we want to preserve the existing format, this also works:

prefix = prefix + time.Now().Format("-20060102-150405")

http://play.golang.org/p/tzf_9lEcZx

I don't think the specific format matters, though. And I really don't understand why we don't just use ioutil.TempDir

Changed in juju-core:
importance: Undecided → High
status: New → Triaged
Revision history for this message
Kapil Thangavelu (hazmat) wrote :

This looks like a simple logic error, time.Format doesn't use strftime but a sample layout, ie. http://golang.org/pkg/time/#pkg-constants. As a result it barfs after the 10th retry.

Revision history for this message
Kapil Thangavelu (hazmat) wrote :

seems to be rather hard to actually generate with the time.Format conventions, falling back to fmt.Sprintf works fine though.

x := fmt.Sprintf("%d%d%d-%d%d%d", t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second);

Mark Ramm (mark-ramm)
Changed in juju-core:
assignee: nobody → Roger Peppe (rogpeppe)
William Reade (fwereade)
Changed in juju-core:
status: Triaged → Fix Committed
milestone: none → 1.11.3
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.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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