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

Issue 99660047: Introduce InstanceDistributor policy

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 years, 11 months ago by axw
Modified:
9 years, 11 months ago
Reviewers:
mp+221481, fwereade
Visibility:
Public.

Description

Introduce InstanceDistributor policy This change introduces an InstanceDistributor policy, which will be used to implement automatic Availability Zone management for AWS and OpenStack. When an attempt is made to assign a unit to a clean machine, we gather the instances that have already been provisioned, and provide those and the unit's distribution group to the provider. The provider may select as many or as few of the candidates as it wishes to allow; the assignment policy will then choose one of them for assigning to. If no candidates are returned, the unit will be assigned to a new machine. There are currently no implementations of this policy; they will be forthcoming when manual AZ support lands in the amazon/openstack providers. https://code.launchpad.net/~axwalk/juju-core/provider-unit-assignment-policy/+merge/221481 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 6

Patch Set 2 : Introduce InstanceDistributor policy #

Unified diffs Side-by-side diffs Delta from patch set Stats (+385 lines, -50 lines) Patch
A [revision details] View 1 1 chunk +2 lines, -0 lines 0 comments Download
M environs/statepolicy.go View 2 chunks +13 lines, -0 lines 0 comments Download
M state/apiserver/provisioner/provisioner.go View 1 1 chunk +6 lines, -27 lines 0 comments Download
M state/conn_test.go View 2 chunks +8 lines, -0 lines 0 comments Download
A state/distribution.go View 1 1 chunk +77 lines, -0 lines 0 comments Download
A state/distribution_test.go View 1 chunk +185 lines, -0 lines 0 comments Download
M state/policy.go View 1 3 chunks +30 lines, -8 lines 0 comments Download
M state/service.go View 1 1 chunk +7 lines, -3 lines 0 comments Download
M state/unit.go View 1 2 chunks +57 lines, -12 lines 0 comments Download

Messages

Total messages: 3
axw
Please take a look.
9 years, 11 months ago (2014-05-30 05:43:52 UTC) #1
fwereade
LGTM with a bit of mindful rearrangement. https://codereview.appspot.com/99660047/diff/1/state/distribution.go File state/distribution.go (right): https://codereview.appspot.com/99660047/diff/1/state/distribution.go#newcode42 state/distribution.go:42: distributionGroup, err ...
9 years, 11 months ago (2014-05-30 08:51:12 UTC) #2
axw
9 years, 11 months ago (2014-05-30 12:42:06 UTC) #3
Please take a look.

https://codereview.appspot.com/99660047/diff/1/state/distribution.go
File state/distribution.go (right):

https://codereview.appspot.com/99660047/diff/1/state/distribution.go#newcode42
state/distribution.go:42: distributionGroup, err := service.ServiceInstances()
On 2014/05/30 08:51:12, fwereade wrote:
> fwiw, this doesn't feel *quite* right because we don't actually ever need/use
> the *Service directly -- the AllUnits could be figured out from the unit name
> alone, so grabbing the service doc is just an unnecessary db hit (I think?).

Indeed it is unnecessary. I've changed ServiceInstances to take a service name,
and extracted the logic of Service.AllUnits out to a free function which takes a
service name.

> But it's a balance: using the methods we already have for familarity/clarity's
> sake, vs writing more primitives that operate more on ids and less on
> instantiated objects and *might* eventually lead us in a leaner/cleaner
> direction. I have a slight preference for the latter but I'll leave it to your
> judgment.

https://codereview.appspot.com/99660047/diff/1/state/distribution.go#newcode54
state/distribution.go:54: func (service *Service) ServiceInstances()
([]instance.Id, error) {
On 2014/05/30 08:51:12, fwereade wrote:
> Suggestion: ServiceInstances(*state.Service). I retain a mild discomfort over
> spreading the methods on a particular type across files, but just making the
> receiver a regular param pretty much eliminates that feeling of ick. I'm not
> sure it's *entirely* rational, but...
> 
> Anyway, same applies to Unit.distribute above. Doesn't feel like it's quite in
> the right place.

Changed both to free functions.

https://codereview.appspot.com/99660047/diff/1/state/policy.go
File state/policy.go (right):

https://codereview.appspot.com/99660047/diff/1/state/policy.go#newcode204
state/policy.go:204: // TODO(axw) move this comment
On 2014/05/30 08:51:12, fwereade wrote:
> where to? ;p

Yeah, it's probably best just left here.
Sign in to reply to this message.

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