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

Issue 6453061: implement RelationState persistence

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

Description

implement RelationState persistence RelationState gets a new field, Path, and two new methods: (*RelationState) Validate(HookInfo) error ...which allows a client to verify the sanity of a hook before it is run, and: (*RelationState) Commit(HookInfo) error ...which persists the state change to disk, and should be called on successful execution of a hook, or resolution of an error state. RelationState is aggressive about error detection and should always write consistent states; errors while committing a hook should not cause any change to the RelationState or its persistence directory. A new AllRelationStates function, which scans a complete relations directory and returns a map of relation id to *RelationState stored therein, will be convenient when reconciling persisted relation state against the unit's service's latest relation membership. https://code.launchpad.net/~fwereade/juju-core/persist-relation-state/+merge/117181 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 23

Patch Set 2 : implement RelationState persistence #

Total comments: 31

Patch Set 3 : implement RelationState persistence #

Total comments: 6

Patch Set 4 : implement RelationState persistence #

Unified diffs Side-by-side diffs Delta from patch set Stats (+586 lines, -96 lines) Patch
A [revision details] View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
M worker/uniter/hookqueue.go View 1 chunk +0 lines, -14 lines 0 comments Download
M worker/uniter/hookqueue_test.go View 2 chunks +82 lines, -82 lines 0 comments Download
A worker/uniter/relationstate.go View 1 2 1 chunk +210 lines, -0 lines 0 comments Download
A worker/uniter/relationstate_test.go View 1 2 3 1 chunk +292 lines, -0 lines 0 comments Download

Messages

Total messages: 10
fwereade
Please take a look.
11 years, 9 months ago (2012-07-29 13:24:43 UTC) #1
rog
Looking nice. I'm not sure about Validate though - shouldn't we be confident enough that ...
11 years, 9 months ago (2012-07-30 08:28:09 UTC) #2
fwereade
On 2012/07/30 08:28:09, rog wrote: > Looking nice. I'm not sure about Validate though - ...
11 years, 9 months ago (2012-07-30 08:41:23 UTC) #3
fwereade
Thanks. A couple of responses follow; I'll get on the easy fixes in a mo. ...
11 years, 9 months ago (2012-07-30 08:42:11 UTC) #4
fwereade
Please take a look. https://codereview.appspot.com/6453061/diff/1/worker/uniter/relationstate.go File worker/uniter/relationstate.go (right): https://codereview.appspot.com/6453061/diff/1/worker/uniter/relationstate.go#newcode74 worker/uniter/relationstate.go:74: walker := func(path string, fi ...
11 years, 9 months ago (2012-07-30 13:42:28 UTC) #5
rog
LGTM, particularly the walk->readdir change. https://codereview.appspot.com/6453061/diff/6001/worker/uniter/relationstate.go File worker/uniter/relationstate.go (right): https://codereview.appspot.com/6453061/diff/6001/worker/uniter/relationstate.go#newcode19 worker/uniter/relationstate.go:19: defer errorContextf(&err, "cannot load ...
11 years, 9 months ago (2012-07-30 13:52:30 UTC) #6
niemeyer
Great stuff! A first round: https://codereview.appspot.com/6453061/diff/6001/worker/uniter/relationstate.go File worker/uniter/relationstate.go (right): https://codereview.appspot.com/6453061/diff/6001/worker/uniter/relationstate.go#newcode19 worker/uniter/relationstate.go:19: defer errorContextf(&err, "cannot load ...
11 years, 9 months ago (2012-07-31 01:40:08 UTC) #7
fwereade
Please take a look. https://codereview.appspot.com/6453061/diff/6001/worker/uniter/relationstate.go File worker/uniter/relationstate.go (right): https://codereview.appspot.com/6453061/diff/6001/worker/uniter/relationstate.go#newcode19 worker/uniter/relationstate.go:19: defer errorContextf(&err, "cannot load relations ...
11 years, 9 months ago (2012-07-31 08:51:03 UTC) #8
niemeyer
LGTM, with a few suggestions for test readability: https://codereview.appspot.com/6453061/diff/8001/worker/uniter/relationstate_test.go File worker/uniter/relationstate_test.go (right): https://codereview.appspot.com/6453061/diff/8001/worker/uniter/relationstate_test.go#newcode56 worker/uniter/relationstate_test.go:56: {nil, ...
11 years, 9 months ago (2012-07-31 12:52:48 UTC) #9
fwereade
11 years, 9 months ago (2012-07-31 14:25:31 UTC) #10
*** Submitted:

implement RelationState persistence

RelationState gets a new field, Path, and two new methods:

  (*RelationState) Validate(HookInfo) error

...which allows a client to verify the sanity of a hook before
it is run, and:

  (*RelationState) Commit(HookInfo) error

...which persists the state change to disk, and should be called on
successful execution of a hook, or resolution of an error state.
RelationState is aggressive about error detection and should always
write consistent states; errors while committing a hook should not
cause any change to the RelationState or its persistence directory.

A new AllRelationStates function, which scans a complete relations
directory and returns a map of relation id to *RelationState stored
therein, will be convenient when reconciling persisted relation state
against the unit's service's latest relation membership.

R=rog, niemeyer
CC=
https://codereview.appspot.com/6453061

https://codereview.appspot.com/6453061/diff/8001/worker/uniter/relationstate_...
File worker/uniter/relationstate_test.go (right):

https://codereview.appspot.com/6453061/diff/8001/worker/uniter/relationstate_...
worker/uniter/relationstate_test.go:56: {nil, []string{"foo-bar-1"}, `.* is a
directory`},
On 2012/07/31 12:52:48, niemeyer wrote:
> The previous format here was significantly more readable. Can we have it back?

Done.

https://codereview.appspot.com/6453061/diff/8001/worker/uniter/relationstate_...
worker/uniter/relationstate_test.go:89: return uniter.HookInfo{
On 2012/07/31 12:52:48, niemeyer wrote:
> Why do we need all of the helpers here? This:
> 
> uniter.HookInfo{
>     RelationId:    1,
>     HookInfo:      "changed",
>     RemoteUnit:    "foo/1",
>     ChangeVersion: 123,
> },
> 
> Is so much better than this:
> 
> hookInfos([]hookInfo{
>     {"foo/1", "changed", 1, 123},
> })

You're right, it did turn out nicer.

https://codereview.appspot.com/6453061/diff/8001/worker/uniter/relationstate_...
worker/uniter/relationstate_test.go:118: }), msi{"foo/1": 1, "foo/2": 0}, "",
"",
On 2012/07/31 12:52:48, niemeyer wrote:
> These tests would also benefit from breaking down fields into their own lines.
> If there are many empty fields, or potentially confusing meaning, using field
> names would also work well.

Done.
Sign in to reply to this message.

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