Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(754)

Delta Between Two Patch Sets: cmd/juju/upgradecharm.go

Issue 8540050: cmd/juju: upgrade-charm --switch support (Closed)
Left Patch Set: cmd/juju: upgrade-charm --switch support Created 10 years, 11 months ago
Right Patch Set: cmd/juju: upgrade-charm --switch support Created 10 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « [revision details] ('k') | cmd/juju/upgradecharm_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 package main 1 package main
2 2
3 import ( 3 import (
4 "errors" 4 "errors"
5 "fmt" 5 "fmt"
6 "launchpad.net/gnuflag" 6 "launchpad.net/gnuflag"
7 "launchpad.net/juju-core/charm" 7 "launchpad.net/juju-core/charm"
8 "launchpad.net/juju-core/cmd" 8 "launchpad.net/juju-core/cmd"
9 "launchpad.net/juju-core/juju" 9 "launchpad.net/juju-core/juju"
10 "launchpad.net/juju-core/state" 10 "launchpad.net/juju-core/state"
(...skipping 30 matching lines...) Expand all
41 different one. The new charm's URL and revision are inferred as they 41 different one. The new charm's URL and revision are inferred as they
42 would be when running a deploy command. 42 would be when running a deploy command.
43 43
44 Please note that --switch is dangerous, because juju only has limited 44 Please note that --switch is dangerous, because juju only has limited
45 information with which to determine compatibility; the operation will 45 information with which to determine compatibility; the operation will
46 succeed, regardless of potential havoc, so long as the following 46 succeed, regardless of potential havoc, so long as the following
47 conditions hold: 47 conditions hold:
48 48
49 - The new charm must declare all relations that the service is 49 - The new charm must declare all relations that the service is
50 currently participating in. 50 currently participating in.
51 - All config settings shared by the old and new charms must have the 51 - All config settings shared by the old and new charms must have the
rog 2013/04/29 16:11:51 that's not quite right, is it? i believe the new c
52 same types. 52 same types.
53 53
54 The new charm may add new relations and configuration settings. 54 The new charm may add new relations and configuration settings.
fwereade 2013/04/29 15:45:18 I think we can drop this line.
55 55
56 --switch and --revision are mutually exclusive. To specify a given 56 --switch and --revision are mutually exclusive. To specify a given
57 revision number with --switch, give it in the charm URL, for instance 57 revision number with --switch, give it in the charm URL, for instance
58 "cs:wordpress-5" would specify revision number 5 of the wordpress 58 "cs:wordpress-5" would specify revision number 5 of the wordpress
59 charm. 59 charm.
60 60
61 Use of the --force flag is not generally recommended; units upgraded 61 Use of the --force flag is not generally recommended; units upgraded
62 while in an error state will not have upgrade-charm hooks executed, 62 while in an error state will not have upgrade-charm hooks executed,
63 and may cause unexpected behavior. 63 and may cause unexpected behavior.
64 ` 64 `
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 explicitRevision := true 135 explicitRevision := true
136 if newURL.Revision == -1 { 136 if newURL.Revision == -1 {
137 explicitRevision = false 137 explicitRevision = false
138 latest, err := repo.Latest(newURL) 138 latest, err := repo.Latest(newURL)
139 if err != nil { 139 if err != nil {
140 return err 140 return err
141 } 141 }
142 newURL = newURL.WithRevision(latest) 142 newURL = newURL.WithRevision(latest)
143 } 143 }
144 bumpRevision := false 144 bumpRevision := false
145 » if *newURL == *oldURL && !explicitRevision { 145 » if *newURL == *oldURL {
fwereade 2013/04/29 15:45:18 If newURL matches oldURL, we have to take this bra
rog 2013/04/29 16:11:51 as discussed online, i'm not sure this is quite ri
146 » » // Only try bumping the revision when necessary 146 » » if explicitRevision {
147 » » // (local dir charm and no explicit revision). 147 » » » return fmt.Errorf("already running specified charm %q", newURL)
148 » » }
149 » » // Only try bumping the revision when necessary (local dir charm ).
148 if _, isLocal := repo.(*charm.LocalRepository); !isLocal { 150 if _, isLocal := repo.(*charm.LocalRepository); !isLocal {
149 // TODO(dimitern): If the --force flag is set to somethi ng 151 // TODO(dimitern): If the --force flag is set to somethi ng
150 // different to before, we might actually want to allow this 152 // different to before, we might actually want to allow this
151 // case (and the other error below). LP bug #1174287 153 // case (and the other error below). LP bug #1174287
152 return fmt.Errorf("already running latest charm %q", new URL) 154 return fmt.Errorf("already running latest charm %q", new URL)
153 } 155 }
154 // This is a local repository. 156 // This is a local repository.
155 if ch, err := repo.Get(newURL); err != nil { 157 if ch, err := repo.Get(newURL); err != nil {
156 return err 158 return err
157 } else if _, bumpRevision = ch.(*charm.Dir); !bumpRevision { 159 } else if _, bumpRevision = ch.(*charm.Dir); !bumpRevision {
158 // Only bump the revision when it's a directory. 160 // Only bump the revision when it's a directory.
159 » » » return fmt.Errorf("already running latest charm %q", new URL) 161 » » » return fmt.Errorf("cannot increment revision of charm %q : not a directory", newURL)
160 } 162 }
161 } 163 }
162 sch, err := conn.PutCharm(newURL, repo, bumpRevision) 164 sch, err := conn.PutCharm(newURL, repo, bumpRevision)
fwereade 2013/04/29 15:45:18 It's somewhat crazy that we can specify a URL with
163 if err != nil { 165 if err != nil {
164 return err 166 return err
165 } 167 }
166 return service.SetCharm(sch, c.Force) 168 return service.SetCharm(sch, c.Force)
167 } 169 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b