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

Issue 6455065: state: lifecycle implementation started (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 9 months ago by TheMue
Modified:
11 years, 8 months ago
Reviewers:
aram, mp+117382, niemeyer, fwereade, rog
Visibility:
Public.

Description

state: lifecycle implementation started The branch contains the type definition and some utility functions for lifecycles in general. A first integration into relation is done and the tests changed (very naive by just setting the lifecycle state before removing). So the tests of state are working while any outer relying code may fail. This has to be done in a follow-up CL. https://code.launchpad.net/~themue/juju-core/go-state-lifecycle-relation/+merge/117382 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 46

Patch Set 2 : state: lifecycle implementation started #

Total comments: 13

Patch Set 3 : state: lifecycle implementation started #

Total comments: 13

Patch Set 4 : state: lifecycle implementation started #

Patch Set 5 : state: lifecycle implementation started #

Unified diffs Side-by-side diffs Delta from patch set Stats (+303 lines, -14 lines) Patch
A [revision details] View 1 2 3 4 1 chunk +2 lines, -0 lines 0 comments Download
A state/lifecycle.go View 1 2 3 1 chunk +121 lines, -0 lines 0 comments Download
A state/lifecycle_test.go View 1 2 3 1 chunk +72 lines, -0 lines 0 comments Download
M state/relation.go View 1 2 3 4 2 chunks +32 lines, -0 lines 0 comments Download
M state/relation_internal_test.go View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M state/relation_test.go View 1 2 3 4 5 chunks +56 lines, -3 lines 0 comments Download
M state/service.go View 1 2 3 4 2 chunks +3 lines, -5 lines 0 comments Download
M state/service_test.go View 1 2 3 1 chunk +4 lines, -0 lines 0 comments Download
M state/state.go View 1 2 3 4 3 chunks +12 lines, -5 lines 0 comments Download

Messages

Total messages: 23
TheMue
Please take a look.
11 years, 9 months ago (2012-07-31 07:17:24 UTC) #1
rog
looks plausible. a few minor comments below. https://codereview.appspot.com/6455065/diff/1/state/lifecycle.go File state/lifecycle.go (right): https://codereview.appspot.com/6455065/diff/1/state/lifecycle.go#newcode18 state/lifecycle.go:18: func (l ...
11 years, 9 months ago (2012-07-31 07:48:58 UTC) #2
aram
No changes to watchers in this CL? https://codereview.appspot.com/6455065/diff/1/state/lifecycle.go File state/lifecycle.go (right): https://codereview.appspot.com/6455065/diff/1/state/lifecycle.go#newcode18 state/lifecycle.go:18: func (l ...
11 years, 9 months ago (2012-07-31 08:19:11 UTC) #3
fwereade
Good start, couple of issues https://codereview.appspot.com/6455065/diff/1/state/lifecycle.go File state/lifecycle.go (right): https://codereview.appspot.com/6455065/diff/1/state/lifecycle.go#newcode18 state/lifecycle.go:18: func (l Life) checkNext(next ...
11 years, 9 months ago (2012-07-31 09:12:33 UTC) #4
aram
https://codereview.appspot.com/6455065/diff/1/state/relation.go File state/relation.go (right): https://codereview.appspot.com/6455065/diff/1/state/relation.go#newcode79 state/relation.go:79: life Life On 2012/07/31 09:12:33, fwereade wrote: > I'm ...
11 years, 9 months ago (2012-07-31 09:29:17 UTC) #5
aram
https://codereview.appspot.com/6455065/diff/1/state/lifecycle.go File state/lifecycle.go (right): https://codereview.appspot.com/6455065/diff/1/state/lifecycle.go#newcode9 state/lifecycle.go:9: type Life string Hmm, this simplifies returning errors, but ...
11 years, 9 months ago (2012-07-31 09:36:47 UTC) #6
fwereade
On 2012/07/31 09:36:47, aram wrote: > https://codereview.appspot.com/6455065/diff/1/state/lifecycle.go > File state/lifecycle.go (right): > > https://codereview.appspot.com/6455065/diff/1/state/lifecycle.go#newcode9 > ...
11 years, 9 months ago (2012-07-31 09:58:55 UTC) #7
fwereade
On 2012/07/31 09:29:17, aram wrote: > https://codereview.appspot.com/6455065/diff/1/state/relation.go > File state/relation.go (right): > > https://codereview.appspot.com/6455065/diff/1/state/relation.go#newcode79 > ...
11 years, 9 months ago (2012-07-31 10:08:28 UTC) #8
aram
> Does a string cost us so much as to not be worth the clarity? ...
11 years, 9 months ago (2012-07-31 10:42:41 UTC) #9
niemeyer
First round: https://codereview.appspot.com/6455065/diff/1/state/lifecycle.go File state/lifecycle.go (right): https://codereview.appspot.com/6455065/diff/1/state/lifecycle.go#newcode18 state/lifecycle.go:18: func (l Life) checkNext(next Life) error { ...
11 years, 9 months ago (2012-07-31 19:35:55 UTC) #10
TheMue
Please take a look. https://codereview.appspot.com/6455065/diff/1/state/lifecycle.go File state/lifecycle.go (right): https://codereview.appspot.com/6455065/diff/1/state/lifecycle.go#newcode9 state/lifecycle.go:9: type Life string On 2012/07/31 ...
11 years, 9 months ago (2012-08-06 19:46:35 UTC) #11
aram
https://codereview.appspot.com/6455065/diff/11001/state/lifecycle.go File state/lifecycle.go (right): https://codereview.appspot.com/6455065/diff/11001/state/lifecycle.go#newcode96 state/lifecycle.go:96: value, found := config.Get(lifeKey) Isn't there a race between ...
11 years, 9 months ago (2012-08-07 10:20:26 UTC) #12
aram
https://codereview.appspot.com/6455065/diff/11001/state/lifecycle.go File state/lifecycle.go (right): https://codereview.appspot.com/6455065/diff/11001/state/lifecycle.go#newcode26 state/lifecycle.go:26: var transitions = [nLife][nLife]bool{ I love shorter names in ...
11 years, 9 months ago (2012-08-07 10:29:07 UTC) #13
TheMue
Thx Aram, missed to check the real changes in the config. Will add it. https://codereview.appspot.com/6455065/diff/11001/state/lifecycle.go ...
11 years, 9 months ago (2012-08-07 11:39:53 UTC) #14
niemeyer
https://codereview.appspot.com/6455065/diff/11001/state/lifecycle.go File state/lifecycle.go (right): https://codereview.appspot.com/6455065/diff/11001/state/lifecycle.go#newcode91 state/lifecycle.go:91: func (lc *lifecycle) SetLife(next Life) error { The issues ...
11 years, 9 months ago (2012-08-07 15:09:36 UTC) #15
TheMue
Please take a look. https://codereview.appspot.com/6455065/diff/11001/state/lifecycle.go File state/lifecycle.go (right): https://codereview.appspot.com/6455065/diff/11001/state/lifecycle.go#newcode26 state/lifecycle.go:26: var transitions = [nLife][nLife]bool{ On ...
11 years, 9 months ago (2012-08-08 13:24:19 UTC) #16
niemeyer
https://codereview.appspot.com/6455065/diff/17001/state/lifecycle.go File state/lifecycle.go (right): https://codereview.appspot.com/6455065/diff/17001/state/lifecycle.go#newcode45 state/lifecycle.go:45: // init initializes the lifecycle with the state Alive ...
11 years, 8 months ago (2012-08-13 15:48:49 UTC) #17
TheMue
Added some clearing comments for the next step. https://codereview.appspot.com/6455065/diff/17001/state/lifecycle.go File state/lifecycle.go (right): https://codereview.appspot.com/6455065/diff/17001/state/lifecycle.go#newcode45 state/lifecycle.go:45: // ...
11 years, 8 months ago (2012-08-14 12:36:06 UTC) #18
TheMue
Please take a look.
11 years, 8 months ago (2012-08-16 12:46:04 UTC) #19
TheMue
Please take a look.
11 years, 8 months ago (2012-08-21 08:49:09 UTC) #20
niemeyer
https://codereview.appspot.com/6455065/diff/17001/state/lifecycle.go File state/lifecycle.go (right): https://codereview.appspot.com/6455065/diff/17001/state/lifecycle.go#newcode45 state/lifecycle.go:45: // init initializes the lifecycle with the state Alive ...
11 years, 8 months ago (2012-08-28 17:15:06 UTC) #21
TheMue
On 2012/08/28 17:15:06, niemeyer wrote: > https://codereview.appspot.com/6455065/diff/17001/state/lifecycle.go > File state/lifecycle.go (right): > > https://codereview.appspot.com/6455065/diff/17001/state/lifecycle.go#newcode45 > ...
11 years, 8 months ago (2012-08-28 17:24:11 UTC) #22
niemeyer
11 years, 8 months ago (2012-08-29 20:33:41 UTC) #23
On 2012/08/28 17:24:11, TheMue wrote:
> On 2012/08/28 17:15:06, niemeyer wrote:
> > https://codereview.appspot.com/6455065/diff/17001/state/lifecycle.go
> > File state/lifecycle.go (right):
> > 
> >
https://codereview.appspot.com/6455065/diff/17001/state/lifecycle.go#newcode45
> > state/lifecycle.go:45: // init initializes the lifecycle with the state
Alive
> .
> > On 2012/08/14 12:36:06, TheMue wrote:
> > > On 2012/08/13 15:48:49, niemeyer wrote:
> > > > Why do we need this? We should be creating the actual nodes with life
set
> to
> > > > Alive in the first place, rather than changing them to Alive after the
> fact
> > > via
> > > > this method.
> > > 
> > > Maybe this comment is misleading. init() is to write the initial Alive
into
> > the
> > > config node. init() is called immediately after the creation of the
> instance,
> > so
> > > the config node should be empty so far. But I preferred to take care that
> it's
> > > really so.
> > 
> > The comment isn't misleading. The logic itself is wrong. You can't create a
> node
> > that has no lifecycle state and then initialize it after the fact.
Meanwhile,
> > someone else will pick it up, and will see wrong state.
> > 
> > This, specifically, is a relevant race condition:
> > 
> > 98         r := newRelation(st, key)
> > 99         if err := r.lifecycle.init(); err != nil {
> > 
> > We've been going back and forth on this, and I'm feeling unproductive
> reviewing
> > this over and over about the same problems.
> > 
> > I suggest we stop work on state, put that aside, and focus entirely on
mstate.
> > Let's implement watches and presence, and move forward.
> 
> Take a look at newRelation(), it doesn't create a node, only the struct with
> lifecycle initialized:

What is this logic doing Frank:

  46 func (lc *lifecycle) init() error {
  47         config, err := readConfigNode(lc.zk, lc.path)
  48         if err != nil {
  49                 return err
  50         }
  51         config.Set(lifeKey, Alive)
  52         changes, err := config.Write()
  53         if err != nil {
  54                 return err
  55         }

Either:

1) The node was created before without a lifecycle

or

2) An empty node is being read, and is being written down
   just with lifecycle information and nothing else

Both are wrong.

This is feeling very unproductive to me, Frank. This is in review for several
weeks, and the issues that are brought up are repeatedly  receiving replies that
indicate lack of care instead of being fixed.

I'm marking the branch as rejected.
Sign in to reply to this message.

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