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

Delta Between Two Patch Sets: worker/uniter/uniter.go

Issue 7425044: uniter, state: handle upgrades better (Closed)
Left Patch Set: uniter, state: handle upgrades better Created 12 years, 1 month ago
Right Patch Set: uniter, state: handle upgrades better Created 12 years 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 | « worker/uniter/modes.go ('k') | worker/uniter/uniter_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 uniter 1 package uniter
2 2
3 import ( 3 import (
4 "errors" 4 "errors"
5 "fmt" 5 "fmt"
6 corecharm "launchpad.net/juju-core/charm" 6 corecharm "launchpad.net/juju-core/charm"
7 "launchpad.net/juju-core/charm/hooks" 7 "launchpad.net/juju-core/charm/hooks"
8 "launchpad.net/juju-core/cmd" 8 "launchpad.net/juju-core/cmd"
9 "launchpad.net/juju-core/environs/agent" 9 "launchpad.net/juju-core/environs/agent"
10 "launchpad.net/juju-core/log" 10 "launchpad.net/juju-core/log"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 var hi *hook.Info 174 var hi *hook.Info
175 if u.s != nil && (u.s.Op == RunHook || u.s.Op == Upgrade) { 175 if u.s != nil && (u.s.Op == RunHook || u.s.Op == Upgrade) {
176 // If this upgrade interrupts a RunHook, we need to preserve the hook 176 // If this upgrade interrupts a RunHook, we need to preserve the hook
177 // info so that we can return to the appropriate error state. Ho wever, 177 // info so that we can return to the appropriate error state. Ho wever,
178 // if we're resuming (or have force-interrupted) an Upgrade, we also 178 // if we're resuming (or have force-interrupted) an Upgrade, we also
179 // need to preserve whatever hook info was preserved when we ini tially 179 // need to preserve whatever hook info was preserved when we ini tially
180 // started upgrading, to ensure we still return to the correct s tate. 180 // started upgrading, to ensure we still return to the correct s tate.
181 hi = u.s.Hook 181 hi = u.s.Hook
182 } 182 }
183 if u.s == nil || u.s.OpStep != Done { 183 if u.s == nil || u.s.OpStep != Done {
184 // Set the new charm URL - this returns once it's done and store d.
185 if err := u.f.SetCharm(curl); err != nil {
186 return err
187 }
188 // Refresh to get the new URL.
189 if err := u.unit.Refresh(); err != nil {
190 return err
191 }
192
184 log.Printf("worker/uniter: fetching charm %q", curl) 193 log.Printf("worker/uniter: fetching charm %q", curl)
185 sch, err := u.st.Charm(curl) 194 sch, err := u.st.Charm(curl)
186 if err != nil { 195 if err != nil {
187 return err 196 return err
188 } 197 }
189 bun, err := u.bundles.Read(sch, u.tomb.Dying()) 198 bun, err := u.bundles.Read(sch, u.tomb.Dying())
190 if err != nil { 199 if err != nil {
191 return err 200 return err
192 } 201 }
193 if err = u.deployer.Stage(bun, curl); err != nil { 202 if err = u.deployer.Stage(bun, curl); err != nil {
194 return err 203 return err
195 } 204 }
196 log.Printf("worker/uniter: deploying charm %q", curl) 205 log.Printf("worker/uniter: deploying charm %q", curl)
197 if err = u.writeState(reason, Pending, hi, curl); err != nil { 206 if err = u.writeState(reason, Pending, hi, curl); err != nil {
198 return err 207 return err
199 } 208 }
200 if err = u.deployer.Deploy(u.charm); err != nil { 209 if err = u.deployer.Deploy(u.charm); err != nil {
201 return err 210 return err
202 } 211 }
203 if err = u.writeState(reason, Done, hi, curl); err != nil { 212 if err = u.writeState(reason, Done, hi, curl); err != nil {
204 return err 213 return err
205 } 214 }
206 } 215 }
207 log.Printf("worker/uniter: charm %q is deployed", curl) 216 log.Printf("worker/uniter: charm %q is deployed", curl)
208 // Set the new charm URL - this returns once it's done and stored.
209 if err := u.f.SetCharm(curl); err != nil {
210 return err
211 }
212 // Refresh to get the new URL.
213 u.unit.Refresh()
214 status := Queued 217 status := Queued
215 if hi != nil { 218 if hi != nil {
216 // If a hook operation was interrupted, restore it. 219 // If a hook operation was interrupted, restore it.
217 status = Pending 220 status = Pending
218 } else { 221 } else {
219 // Otherwise, queue the relevant post-deploy hook. 222 // Otherwise, queue the relevant post-deploy hook.
220 hi = &hook.Info{} 223 hi = &hook.Info{}
221 switch reason { 224 switch reason {
222 case Install: 225 case Install:
223 hi.Kind = hooks.Install 226 hi.Kind = hooks.Install
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 } else if err != nil { 454 } else if err != nil {
452 return err 455 return err
453 } 456 }
454 log.Printf("worker/uniter: joined relation %q", rel) 457 log.Printf("worker/uniter: joined relation %q", rel)
455 u.relationers[rel.Id()] = r 458 u.relationers[rel.Id()] = r
456 return nil 459 return nil
457 } 460 }
458 } 461 }
459 panic("unreachable") 462 panic("unreachable")
460 } 463 }
LEFTRIGHT

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