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

Issue 14527043: Fix tools metadata generation for null provider

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

Description

Fix tools metadata generation for null provider There's two functional changes here: - If there's existing tools metadata, use it if it has sha256/size in it, and the tools haven't been replaced. - Don't use net/http or the tools URL when fetching tools to compute sha256/size. That doesn't work with sshstorage. - Don't fetch existing tools to resolve metadata during normal tools syncing operations. Only the "juju metadata generate-tools" command will do this now. Additionally, I have refactored environs/tools/simplestreams.go, to make the intent of WriteMetadata (now MergeAndWriteMetadata) more obvious. That function is now composed of several other more specific functions. Fixes #1235717 https://code.launchpad.net/~axwalk/juju-core/lp1235717-refactor-simplestreams-writemetadata/+merge/189767 (do not edit description out of merge proposal)

Patch Set 1 #

Patch Set 2 : Fix tools metadata generation for null provider #

Total comments: 20

Patch Set 3 : Fix tools metadata generation for null provider #

Total comments: 1

Patch Set 4 : Fix tools metadata generation for null provider #

Patch Set 5 : Fix tools metadata generation for null provider #

Patch Set 6 : Fix tools metadata generation for null provider #

Unified diffs Side-by-side diffs Delta from patch set Stats (+429 lines, -142 lines) Patch
A [revision details] View 1 2 3 4 5 1 chunk +2 lines, -0 lines 0 comments Download
M cmd/jujud/agent_test.go View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M cmd/plugins/juju-metadata/toolsmetadata.go View 1 2 3 4 5 3 chunks +21 lines, -2 lines 0 comments Download
M cmd/plugins/juju-metadata/toolsmetadata_test.go View 5 chunks +16 lines, -14 lines 0 comments Download
M environs/sync/sync.go View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M environs/testing/tools.go View 1 2 3 4 3 chunks +17 lines, -7 lines 0 comments Download
M environs/tools/simplestreams.go View 1 2 3 4 6 chunks +132 lines, -82 lines 0 comments Download
M environs/tools/simplestreams_test.go View 1 2 3 4 8 chunks +226 lines, -15 lines 0 comments Download
M environs/tools/tools.go View 1 chunk +1 line, -6 lines 0 comments Download
M testing/targz.go View 1 2 3 4 2 chunks +8 lines, -10 lines 0 comments Download
M worker/upgrader/upgrader_test.go View 1 2 3 4 4 chunks +4 lines, -4 lines 0 comments Download

Messages

Total messages: 12
axw
Please take a look.
10 years, 7 months ago (2013-10-08 06:23:00 UTC) #1
axw
On 2013/10/08 06:23:00, axw wrote: > Please take a look. More tests on the way, ...
10 years, 7 months ago (2013-10-08 07:08:00 UTC) #2
axw
Please take a look.
10 years, 7 months ago (2013-10-08 07:40:23 UTC) #3
rog
This looks great in general, with a few remarks and suggestions below. https://codereview.appspot.com/14527043/diff/5001/cmd/plugins/juju-metadata/toolsmetadata.go File cmd/plugins/juju-metadata/toolsmetadata.go ...
10 years, 7 months ago (2013-10-09 12:08:57 UTC) #4
axw
https://codereview.appspot.com/14527043/diff/5001/cmd/plugins/juju-metadata/toolsmetadata.go File cmd/plugins/juju-metadata/toolsmetadata.go (right): https://codereview.appspot.com/14527043/diff/5001/cmd/plugins/juju-metadata/toolsmetadata.go#newcode76 cmd/plugins/juju-metadata/toolsmetadata.go:76: return tools.MergeAndWriteMetadata(targetStorage, toolsList, tools.ResolveFlag(c.fetch)) On 2013/10/09 12:08:57, rog wrote: ...
10 years, 7 months ago (2013-10-09 14:28:25 UTC) #5
axw
Please take a look.
10 years, 7 months ago (2013-10-09 14:33:32 UTC) #6
rog
LGTM with some thoughts below. For the future, I think that the "resolve" mode is ...
10 years, 7 months ago (2013-10-09 16:29:42 UTC) #7
axw
On 2013/10/09 16:29:42, rog wrote: > LGTM with some thoughts below. Thanks. I'll change the ...
10 years, 7 months ago (2013-10-10 02:26:45 UTC) #8
axw
Please take a look.
10 years, 7 months ago (2013-10-10 03:07:46 UTC) #9
axw
Please take a look.
10 years, 6 months ago (2013-10-16 04:47:32 UTC) #10
axw
Please take a look.
10 years, 6 months ago (2013-10-16 05:15:16 UTC) #11
axw
10 years, 6 months ago (2013-10-16 05:28:31 UTC) #12
On 2013/10/10 02:26:45, axw wrote:
> On 2013/10/09 16:29:42, rog wrote:
> > LGTM with some thoughts below.
> 
> Thanks. I'll change the newMetadata/oldMetadata thing as suggested, but I
think
> I'll leave the others to a followup.
> 
> > For the future, I think that the "resolve" mode is unnecessary and should go
-
> > if we have items in the target bucket that we don't have hashes for, we
should
> > just ignore them. This will actually work fine in practice, I think, even if
> we
> > abort a SyncTools half way through, because when we retry the SyncTools, any
> > items in the target bucket that we didn't get around to adding to the target
> > bucket simplestreams data should have metadata in the source bucket's
> > simplestreams data. 
> > 
> > In general, I think retro-discovering hash data by trying to find out what
the
> > data currently is is a flawed idea - the hash of some tools should be
> generated
> > on first upload and preserved forever after.
> 
> I'd like to say I agree, however I know the requirements here are a bit
subtle.
> I think it'd be good to talk with wallyworld at SFO to nut it out.

I discussed this with wallyworld on IRC, and he agreed that it should go in
1.18.
After 1.16, all tools in storage should have corresponding metadata with size
and hash.

> >
>
https://codereview.appspot.com/14527043/diff/5001/environs/tools/simplestream...
> > File environs/tools/simplestreams.go (right):
> > 
> >
>
https://codereview.appspot.com/14527043/diff/5001/environs/tools/simplestream...
> > environs/tools/simplestreams.go:240: func MergeMetadata(newMetadata,
> oldMetadata
> > []*ToolsMetadata) []*ToolsMetadata {
> > On 2013/10/09 14:28:25, axw wrote:
> > > On 2013/10/09 12:08:57, rog wrote:
> > > > I'm not sure that "new" and "old" are appropriate prefixes here - they
> seem
> > to
> > > > imply that the arguments are treated differently, but isn't
MergeMetadata
> > > > commutative?
> > > > 
> > > > Personally I'd use something like m0 and m1, but go with your own
thoughts
> > for
> > > > naming.
> > > 
> > > It's not commutative, per the last sentence of the doc comment:
> > > "If both entries have information, prefer the entry from newMetadata".
> > > 
> > > The idea behind that is that if both have size&hash, then the one from
> > > "newMetadata" is considered newer. That's to cater for copying over the
top
> of
> > > existing tools (say, a dev build).
> > 
> > Hmm, that *should* never happen - a version should always correspond only to
> one
> > particular tarball. I think if we do get a clash like this, then we have a
> > problem that I suspect our current logic won't cope with.
> > 
> > Perhaps this function should check for inconsistencies and return an error
if
> it
> > finds one.
> 
> Yeah, that sounds sensible. The tools won't be copied over if they are already
> in the target, so the "newMetadata" entry won't have a size/hash. So this code
> is only handling a theoretical case, anyway. I'll make this change and
> repropose.
> 
> >
>
https://codereview.appspot.com/14527043/diff/5001/environs/tools/simplestream...
> > environs/tools/simplestreams.go:292: type ResolveFlag bool
> > On 2013/10/09 14:28:25, axw wrote:
> > > On 2013/10/09 12:08:57, rog wrote:
> > > > I know we do this elsewhere, but I've come to dislike
> > > > this idiom - it's an unsatisfactory halfway house between
> > > > named constants and bools. There's still code that
> > > > uses the bool semantics, which means that these names aren't
> > > > really helping much because you have to know their values
> > > > anyway.
> > > >
> > > > I'd prefer either to use int and iota or to stick with the bool
> > > > and lose the named constants.
> > > 
> > > Consider a bool as (conceptually) a 1-bit unsigned int; then what's the
> > > difference between that and int with constant named values? The only
> > difference
> > > I see is that the bool is range limited to [0, 1], which is a very good
> thing.
> > 
> > The main difference I see is that various pieces of code will use a boolean
> > directly, or a boolean test and the sense of the code isn't clear in that
> case.
> > For example, in another piece of code in this CL, there's a boolean field
> called
> > "fetch" which is passed directly as the resolve argument; and in
> > MergeAndWriteMetadata itself, we just use it as a bool.
> > 
> > I'd leave ResolveFlag, but explicitly use the named constants everywhere,
> > rather than just type converting to ResolveFlag.
> > 
> > But given that this function isn't long for this world (I'm hoping), I'm ok
as
> > it is.
> > 
> >
>
https://codereview.appspot.com/14527043/diff/13001/environs/tools/simplestrea...
> > File environs/tools/simplestreams_test.go (right):
> > 
> >
>
https://codereview.appspot.com/14527043/diff/13001/environs/tools/simplestrea...
> > environs/tools/simplestreams_test.go:641: c.Assert(merged, gc.DeepEquals,
> > test.merged)
> > Thanks - I find this much easier to follow (and it's easier to change if we
> > decide to change the semantics of MergeMetadata)
Sign in to reply to this message.

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