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

Issue 38180043: state: update SetEnvironConfig to take new and old

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 5 months ago by axw
Modified:
10 years, 5 months ago
Reviewers:
mp+197989, rog
Visibility:
Public.

Description

state: update SetEnvironConfig to take new and old SetEnvironConfig is updated to take both new and old configurations, and a delta computed from these. The only functional change for now is that attributes that exist in old but not in new are now deleted from state. To do this right, we should also check that the settings in state are the same as the "old" config, so the delta computed is what the user expects. I have not done this part yet, as it is a fairly big change and I am not confident I understand all of the repercussions. https://code.launchpad.net/~axwalk/juju-core/setenvironconfig-delta/+merge/197989 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+70 lines, -52 lines) Patch
A [revision details] View 1 chunk +2 lines, -0 lines 0 comments Download
M cmd/juju/environment.go View 1 chunk +1 line, -1 line 0 comments Download
M cmd/juju/upgradejuju_test.go View 2 chunks +6 lines, -6 lines 0 comments Download
M cmd/jujud/agent_test.go View 1 chunk +3 lines, -3 lines 0 comments Download
M environs/testing/tools.go View 1 chunk +1 line, -1 line 0 comments Download
M juju/conn.go View 1 chunk +2 lines, -2 lines 0 comments Download
M juju/testing/repo.go View 1 chunk +5 lines, -5 lines 0 comments Download
M juju/testing/utils.go View 1 chunk +1 line, -1 line 0 comments Download
M state/api/provisioner/provisioner_test.go View 1 chunk +2 lines, -2 lines 0 comments Download
M state/apiserver/client/client.go View 1 chunk +1 line, -1 line 0 comments Download
M state/initialize_test.go View 2 chunks +2 lines, -2 lines 0 comments Download
M state/state.go View 1 chunk +14 lines, -5 lines 2 comments Download
M state/state_test.go View 5 chunks +6 lines, -4 lines 0 comments Download
M state/testing/config.go View 1 chunk +2 lines, -2 lines 0 comments Download
M worker/firewaller/firewaller_test.go View 1 chunk +3 lines, -2 lines 0 comments Download
M worker/provisioner/provisioner_test.go View 5 chunks +19 lines, -15 lines 0 comments Download

Messages

Total messages: 4
axw
Please take a look.
10 years, 5 months ago (2013-12-06 04:56:07 UTC) #1
rog
LGTM with one thought below. Thanks! https://codereview.appspot.com/38180043/diff/1/state/state.go File state/state.go (right): https://codereview.appspot.com/38180043/diff/1/state/state.go#newcode272 state/state.go:272: settings.Update(newattrs) To do ...
10 years, 5 months ago (2013-12-06 08:46:22 UTC) #2
axw
Thanks for the review https://codereview.appspot.com/38180043/diff/1/state/state.go File state/state.go (right): https://codereview.appspot.com/38180043/diff/1/state/state.go#newcode272 state/state.go:272: settings.Update(newattrs) On 2013/12/06 08:46:23, rog ...
10 years, 5 months ago (2013-12-06 09:01:26 UTC) #3
axw
10 years, 5 months ago (2013-12-06 09:09:28 UTC) #4
On 2013/12/06 09:01:26, axw wrote:
> Thanks for the review
> 
> https://codereview.appspot.com/38180043/diff/1/state/state.go
> File state/state.go (right):
> 
> https://codereview.appspot.com/38180043/diff/1/state/state.go#newcode272
> state/state.go:272: settings.Update(newattrs)
> On 2013/12/06 08:46:23, rog wrote:
> > To do this right, shouldn't we only update
> > those settings that have changed between old
> > and new?
> > 
> > Otherwise if two people concurrently do:
> > 
> >  juju set-environment foo=a
> >  juju set-environment bar=b
> > 
> > then one of them may overwrite the other.
> 
> I don't think it will overwrite in that example, but I may be mistaken.
Updates
> and deletions are translated to $set/$unset transaction operations. Deletions
> are only relative to the "old" config, which is known to the caller. In both
the
> cases you give, neither one will cause a deletion.

Responding to myself here: rog meant that we could overwrite foo/bar with an old
value, on account of us updating everything (Update(AllAttrs)).

> > I suspect that the only way to do this correctly is
> > to have something like:
> > 
> > func (st *State) UpdateEnvironConfig(func (*config.Config) (*config.Config,
> > error)) error
> > 
> > which would retrieve the configuration from state, call the given
> > function to determine the new one and verify that it's valid, and apply the
> new
> > configuration to the state, checking that the settings have not changed in
the
> > meantime.
> > 
> > I guess that's a bigger change though, and the change in this CL is at least
a
> > significant improvement on what we had before, so I'm OK with it for now.
Sign in to reply to this message.

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