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

Side by Side Diff: cmd/jujud/upgrade.go

Issue 7755045: cmd/jujud: upgrader skips unnecessary downloads
Patch Set: cmd/jujud: upgrader skips unnecessary downloads 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:
View unified diff | Download patch
« no previous file with comments | « [revision details] ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package main 1 package main
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "launchpad.net/juju-core/downloader" 5 "launchpad.net/juju-core/downloader"
6 "launchpad.net/juju-core/environs" 6 "launchpad.net/juju-core/environs"
7 "launchpad.net/juju-core/environs/agent" 7 "launchpad.net/juju-core/environs/agent"
8 "launchpad.net/juju-core/log" 8 "launchpad.net/juju-core/log"
9 "launchpad.net/juju-core/state" 9 "launchpad.net/juju-core/state"
10 "launchpad.net/juju-core/state/watcher" 10 "launchpad.net/juju-core/state/watcher"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 download, downloadTools, downloadDone = nil, nil , nil 168 download, downloadTools, downloadDone = nil, nil , nil
169 } 169 }
170 // Ignore the proposed tools if we're already running th e 170 // Ignore the proposed tools if we're already running th e
171 // proposed version. 171 // proposed version.
172 if vers == version.Current.Number { 172 if vers == version.Current.Number {
173 noDelay() 173 noDelay()
174 break 174 break
175 } 175 }
176 binary := version.Current 176 binary := version.Current
177 binary.Number = vers 177 binary.Number = vers
178
179 if tools, err := agent.ReadTools(u.dataDir, binary); err == nil { 178 if tools, err := agent.ReadTools(u.dataDir, binary); err == nil {
180 » » » » // The tools have already been downloaded, so us e them. 179 » » » » // The exact tools have already been downloaded, so use them.
181 return u.upgradeReady(currentTools, tools) 180 return u.upgradeReady(currentTools, tools)
182 } 181 }
182
183 // Try to find the proposed tools in the environment, an d fall back
184 // to the most recent version no later than the proposed .
183 flags := environs.CompatVersion 185 flags := environs.CompatVersion
184 if cfg.Development() { 186 if cfg.Development() {
185 flags |= environs.DevVersion 187 flags |= environs.DevVersion
186 } 188 }
187 tools, err := environs.FindTools(environ, binary, flags) 189 tools, err := environs.FindTools(environ, binary, flags)
188 if err != nil { 190 if err != nil {
189 log.Errorf("cmd/jujud: upgrader error finding to ols for %v: %v", binary, err) 191 log.Errorf("cmd/jujud: upgrader error finding to ols for %v: %v", binary, err)
190 noDelay() 192 noDelay()
191 // TODO(rog): poll until tools become available. 193 // TODO(rog): poll until tools become available.
192 break 194 break
193 } 195 }
194 if tools.Binary != binary { 196 if tools.Binary != binary {
195 if tools.Number == version.Current.Number { 197 if tools.Number == version.Current.Number {
196 // TODO(rog): poll until tools become av ailable. 198 // TODO(rog): poll until tools become av ailable.
197 log.Warningf("cmd/jujud: upgrader: versi on %v requested but found only current version: %v", binary, tools.Number) 199 log.Warningf("cmd/jujud: upgrader: versi on %v requested but found only current version: %v", binary, tools.Number)
198 noDelay() 200 noDelay()
199 break 201 break
200 } 202 }
201 log.Warningf("cmd/jujud: upgrader cannot find ex act tools match for %s; using %s instead", binary, tools.Binary) 203 log.Warningf("cmd/jujud: upgrader cannot find ex act tools match for %s; using %s instead", binary, tools.Binary)
202 } 204 }
205 if tools, err := agent.ReadTools(u.dataDir, tools.Binary ); err == nil {
206 // The best available tools have already been do wnloaded, so use them.
207 return u.upgradeReady(currentTools, tools)
208 }
209
203 log.Infof("cmd/jujud: upgrader downloading %q", tools.UR L) 210 log.Infof("cmd/jujud: upgrader downloading %q", tools.UR L)
204 download = downloader.New(tools.URL, "") 211 download = downloader.New(tools.URL, "")
205 downloadTools = tools 212 downloadTools = tools
206 downloadDone = download.Done() 213 downloadDone = download.Done()
207 case status := <-downloadDone: 214 case status := <-downloadDone:
208 tools := downloadTools 215 tools := downloadTools
209 download, downloadTools, downloadDone = nil, nil, nil 216 download, downloadTools, downloadDone = nil, nil, nil
210 if status.Err != nil { 217 if status.Err != nil {
211 log.Errorf("cmd/jujud: upgrader download of %v f ailed: %v", tools.Binary, status.Err) 218 log.Errorf("cmd/jujud: upgrader download of %v f ailed: %v", tools.Binary, status.Err)
212 noDelay() 219 noDelay()
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 select { 257 select {
251 case <-t.Dying(): 258 case <-t.Dying():
252 time.Sleep(d) 259 time.Sleep(d)
253 delayed.Kill(nil) 260 delayed.Kill(nil)
254 case <-delayed.Dying(): 261 case <-delayed.Dying():
255 return 262 return
256 } 263 }
257 }() 264 }()
258 return &delayed 265 return &delayed
259 } 266 }
OLDNEW
« no previous file with comments | « [revision details] ('k') | no next file » | no next file with comments »

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