Keyboard Shortcuts

File
u :up to issue
m :publish + mail comments
M :edit review message
j / k :jump to file after / before current file
J / K :jump to next file with a comment after / before current file
Side-by-side diff
i :toggle intra-line diffs
e :expand all comments
c :collapse all comments
s :toggle showing all comments
n / p :next / previous diff chunk or comment
N / P :next / previous comment
<Up> / <Down> :next / previous line
<Enter> :respond to / edit current comment
d :mark current comment as done
Issue
u :up to list of issues
m :publish + mail comments
j / k :jump to patch after / before current patch
o / <Enter> :open current patch in side-by-side view
i :open current patch in unified diff view
Issue List
j / k :jump to issue after / before current issue
o / <Enter> :open current issue
# : close issue
Comment/message editing
<Ctrl> + s or <Ctrl> + Enter :save comment
<Esc> :cancel edit
Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(91)
Issues Repositories Search
Open Issues | Closed Issues | All Issues | Sign in with your Google Account to create issues and add comments

Issue 63790045: State policy based config validation.

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 10 months ago by waigani
Modified:
11 years, 10 months ago
Reviewers:
mp+207586, axw, fwereade
Visibility:
Public.
State policy based config validation. First pass at using state policy to preform environ specific config validations. https://code.launchpad.net/~waigani/juju-core/trunk/+merge/207586 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 7

Patch Set 2 : State policy based config validation. #

Patch Set 3 : State policy based config validation. #

Total comments: 4
Created: 11 years, 10 months ago
Download [raw] [tar.bz2]
Unified diffs Side-by-side diffs Delta from patch set Stats (+152 lines, -14 lines) Patch
A [revision details] View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M environs/statepolicy.go View 1 1 chunk +13 lines, -0 lines 0 comments Download
M state/apiserver/client/client.go View 1 1 chunk +2 lines, -12 lines 1 comment Download
A state/configvalidator_test.go View 1 2 1 chunk +92 lines, -0 lines 0 comments Download
M state/conn_test.go View 2 chunks +9 lines, -1 line 0 comments Download
M state/policy.go View 1 3 chunks +28 lines, -0 lines 1 comment Download
M state/state.go View 1 2 chunks +6 lines, -1 line 2 comments Download
Total messages: 6
|
waigani
Please take a look.
11 years, 10 months ago (2014年02月21日 03:42:06 UTC) #1
Please take a look.
Sign in to reply to this message.
axw
Preliminary comments. I think it'd be a good idea to tone back the changes to ...
11 years, 10 months ago (2014年02月21日 04:07:35 UTC) #2
Preliminary comments.
I think it'd be a good idea to tone back the changes to SetEnvironConfig for
this CL, and just add the validation check after checkEnvironConfig (leaving the
TODO and everything else as it is). Up to you, though.
Please also update the API server code (stateserver/client/client.go,
EnvironSet) to remove the Validate call which will become redundant.
https://codereview.appspot.com/63790045/diff/1/environs/statepolicy.go
File environs/statepolicy.go (right):
https://codereview.appspot.com/63790045/diff/1/environs/statepolicy.go#newcode38
environs/statepolicy.go:38: env, err := New(cfg)
We don't need an environ here, we should be using the provider. You can get that
with: environs.Provider(cfg.Type())
https://codereview.appspot.com/63790045/diff/1/environs/statepolicy.go#newcode43
environs/statepolicy.go:43: if c, ok := env.(state.ConfigValidator); ok {
And here you'd just return provider: state.ConfigValidator should have a method
with the same signature as EnvironProvider.Validate.
https://codereview.appspot.com/63790045/diff/1/state/policy.go
File state/policy.go (right):
https://codereview.appspot.com/63790045/diff/1/state/policy.go#newcode27
state/policy.go:27: // ConfigValidator takes a *config.Config and returns
Space before the comment please, to separate the fields: they're logical
independent things, so grouping isn't meaningful.
https://codereview.appspot.com/63790045/diff/1/state/policy.go#newcode49
state/policy.go:49: ValidateEnvironsConfig(newConfig *config.Config, oldConfig
*config.Config) (*config.Config, error)
If you just call the method Validate, then environs.EnvironProvider already
implements this.
https://codereview.appspot.com/63790045/diff/1/state/policy.go#newcode75
state/policy.go:75: // a Validator, and calls PrecheckInstance if a non-nil
Prechecker is returned.
Surely it doesn't call PrecheckInstance? :)
https://codereview.appspot.com/63790045/diff/1/state/policy.go#newcode80
state/policy.go:80: cfg, err := st.EnvironConfig()
No need to get config from state here, we've already got one.
https://codereview.appspot.com/63790045/diff/1/state/state.go
File state/state.go (right):
https://codereview.appspot.com/63790045/diff/1/state/state.go#newcode266
state/state.go:266: newValidConfig, err := st.validateEnvironConfig(cfg, old)
Not quite right, I think.
What I think we should be doing here is computing the delta based on cfg-old. We
then validate this against the config in state and replace what's in state. This
must all be done atomically.
Otherwise, you might have two independently valid changes that are invalid when
combined.
We may also need a change to EnvironSet in the API server: it gets a config from
state and passes it into SetEnvironConfig. That should be part of the
transaction too (and all the validation bits in there can be removed, because
they'll be redundant).
Sign in to reply to this message.
waigani
Please take a look.
11 years, 10 months ago (2014年02月21日 09:37:19 UTC) #3
Please take a look.
Sign in to reply to this message.
axw
On 2014年02月21日 09:37:19, waigani wrote: > Please take a look. Implementations looks good, but please ...
11 years, 10 months ago (2014年02月21日 09:44:47 UTC) #4
On 2014年02月21日 09:37:19, waigani wrote:
> Please take a look.
Implementations looks good, but please add some tests.
Sign in to reply to this message.
waigani
Please take a look.
11 years, 10 months ago (2014年02月23日 05:04:45 UTC) #5
Please take a look.
Sign in to reply to this message.
fwereade
LGTM assuming there's a followup in which my comments are, or will be, addressed. Progress ...
11 years, 10 months ago (2014年02月27日 13:36:33 UTC) #6
LGTM assuming there's a followup in which my comments are, or will be,
addressed. Progress not perfection :).
https://codereview.appspot.com/63790045/diff/40001/state/apiserver/client/cli...
File state/apiserver/client/client.go (right):
https://codereview.appspot.com/63790045/diff/40001/state/apiserver/client/cli...
state/apiserver/client/client.go:791: }
Shouldn't all this code above here move into state? If we're using oldConfig as
a base we need to assert that the base really is oldConfig, and handle
state-changed in here, and have a retry loop in here, etc.
https://codereview.appspot.com/63790045/diff/40001/state/policy.go
File state/policy.go (right):
https://codereview.appspot.com/63790045/diff/40001/state/policy.go#newcode81
state/policy.go:81: configValidator, err := st.policy.ConfigValidator(cfg)
if this just depends on type, can we make it explicit and pass in the type? I'm
just a bit twitchy about seeing cfg passed in twice.
https://codereview.appspot.com/63790045/diff/40001/state/state.go
File state/state.go (right):
https://codereview.appspot.com/63790045/diff/40001/state/state.go#newcode261
state/state.go:261: func (st *State) SetEnvironConfig(cfg, old *config.Config)
error {
yeah, passing in old here really makes no sense. If we're applying a delta, it
should be a delta all the way; the old/new stuff is purely to validate that
delta.
If there's a followup addressing this then feel free to address this stuff
there, though, it's not like this implementation is any worse ;).
https://codereview.appspot.com/63790045/diff/40001/state/state.go#newcode283
state/state.go:283: settings.Delete(k)
I tried to resist the urge to say this again, but, gaah, this is all messed up.
This is not a comment on your branch.
Sign in to reply to this message.
|
Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b

AltStyle によって変換されたページ (->オリジナル) /