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

Issue 10617043: deployer: Refactor, remove watchers (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 10 months ago by dimitern
Modified:
10 years, 10 months ago
Reviewers:
mp+171587, jtv.canonical, fwereade
Visibility:
Public.

Description

deployer: Refactor, remove watchers This is the first of several CLs which will enable the Deployer to use the API instead of state package directly. As a preliminary step, and to reduce the number of API objects (watchers) that need implementing later, we remove the UnitsWatcher argument from NewDeployer and pass machine id instead. Then the machine is retrieved from state by that id and machine.WatchUnits() is used to handle both cases: deploying principal units and deploying subordinates. Unit agent no longer needs to create its own Deployer task for subordinates, as this is now also handled by the machine agent's Deployer task. In follow-ups these changes will happen: * Replace log package with loggo (as suggested); * Remove Deployer shutdown code from the Uniter; * Implement client and server API interface for Deployer; * Replace state calls with API calls in Deployer. https://code.launchpad.net/~dimitern/juju-core/059-deployer-remove-unitswatcher/+merge/171587 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 7

Patch Set 2 : deployer: Refactor, remove watchers #

Total comments: 6

Patch Set 3 : deployer: Refactor, remove watchers #

Unified diffs Side-by-side diffs Delta from patch set Stats (+64 lines, -66 lines) Patch
A [revision details] View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M cmd/jujud/agent.go View 1 1 chunk +5 lines, -5 lines 0 comments Download
M cmd/jujud/deploy_test.go View 2 chunks +4 lines, -2 lines 0 comments Download
M cmd/jujud/machine.go View 1 1 chunk +1 line, -1 line 0 comments Download
M cmd/jujud/unit.go View 1 1 chunk +0 lines, -5 lines 0 comments Download
M cmd/jujud/unit_test.go View 1 3 chunks +1 line, -26 lines 0 comments Download
M worker/deployer/deployer.go View 1 2 5 chunks +33 lines, -18 lines 0 comments Download
M worker/deployer/deployer_test.go View 1 5 chunks +18 lines, -9 lines 0 comments Download

Messages

Total messages: 5
dimitern
Please take a look.
10 years, 10 months ago (2013-06-26 15:30:50 UTC) #1
fwereade
Looks great apart from the error return from newDeployer. LGTM with that fixed, plus verification ...
10 years, 10 months ago (2013-06-26 16:47:28 UTC) #2
dimitern
Please take a look. https://codereview.appspot.com/10617043/diff/1/cmd/jujud/machine.go File cmd/jujud/machine.go (right): https://codereview.appspot.com/10617043/diff/1/cmd/jujud/machine.go#newcode120 cmd/jujud/machine.go:120: if err != nil { ...
10 years, 10 months ago (2013-06-27 09:33:45 UTC) #3
jtv.canonical
LGTM, provided the points I raised are addressed. I see that you took care to ...
10 years, 10 months ago (2013-06-27 10:12:33 UTC) #4
dimitern
10 years, 10 months ago (2013-06-27 10:57:04 UTC) #5
Please take a look.

https://codereview.appspot.com/10617043/diff/7001/worker/deployer/deployer.go
File worker/deployer/deployer.go (right):

https://codereview.appspot.com/10617043/diff/7001/worker/deployer/deployer.go...
worker/deployer/deployer.go:94: log.Warningf("worker/deployer: ignoring unit %q
(not assigned)", unitName)
On 2013/06/27 10:12:34, jtv.canonical wrote:
> 
> Don't know if it's relevant but I was just told to use loggo, not log.

We should start using it, I agree, but I'll do it in a follow-up not to clutter
this CL.

https://codereview.appspot.com/10617043/diff/7001/worker/deployer/deployer.go...
worker/deployer/deployer.go:96: } else if err != nil {
On 2013/06/27 10:12:34, jtv.canonical wrote:
> 
> You've got a triple if/else nested in an else here.  Can you come up with a
> phrasing that's easier for an engineer (think engineer under pressure to fix a
> bug, and not sure if this is the right place) to follow?  A little bit of
extra
> convenience can save a surprising amount of time in the long run.
> 
> The convention in Go is to "escape early" when you hit an error, so that the
> structure of the rest of the code isn't affected by that code path.  Maybe
> there's a way to un-else one or two of these error clauses?

This will be simplified once we introduce the API to the deployer, so that
calling st.Unit(name) will return ErrPerm when you're not responsible for its
deployment, so we'll get rid of most of these cases.

https://codereview.appspot.com/10617043/diff/7001/worker/deployer/deployer.go...
worker/deployer/deployer.go:99: responsible = machineId == d.machineId
On 2013/06/27 10:12:34, jtv.canonical wrote:
> 
> To my untrained eye (and many eyes on this code will be similarly untrained)
> this looks like a nontrivial decision being made here.  It'd be good to have a
> very brief comment explaining the higher meaning of this equation.
> 
> Some disambiguating parentheses might also be nice, for those of us who are
used
> to working in multiple languages with different precedence tables.

Added some comments to describe what happens.
Sign in to reply to this message.

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