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

Issue 68000045: Use stats=0 for charm store interaction by CI

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 2 months ago by abel.deuring
Modified:
10 years, 1 month ago
Reviewers:
mue, mp+208834, fwereade
Visibility:
Public.

Description

Use stats=0 for charm store interaction by CI Bug #1276462: CI deployments have a noticable effect on the charm download statistics. Unfortunately, just adding an environment variable JUJU_TESTING is not sufficient: Running something like "JUJU_TESTING=1 juju deploy mysql" or "JUJU_TESTING juju bootstrap" does not automatically set the environment variable in the deployed machines, where the charm downloads happen. After discussing the problem with TheMue I added instead a new config parameter "testing". This parameter can then be used on the deployed machines to add the HTTP query parameter "stats=0" to the URL. The type Repository has three methods that issue HTTP GET requests to the store: Get(), Info() and Event(). The latter method is only used during charm uploads, so I did not change it. So, Get() and Info() need access to the environment configuration. ISTM that direct access is not possible in the package charm due to circular import, so I added a call parameter "testing" to Get() nad Info(); this parameter is set from the configuration data in the call sites. https://code.launchpad.net/~adeuring/juju-core/1276462/+merge/208834 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 1

Patch Set 2 : Use stats=0 for charm store interaction by CI #

Patch Set 3 : Use stats=0 for charm store interaction by CI #

Total comments: 16
Unified diffs Side-by-side diffs Delta from patch set Stats (+131 lines, -23 lines) Patch
A [revision details] View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M charm/repo.go View 1 2 4 chunks +18 lines, -2 lines 8 comments Download
M charm/repo_test.go View 1 2 5 chunks +43 lines, -2 lines 2 comments Download
M charm/testing/mockstore.go View 3 chunks +23 lines, -8 lines 0 comments Download
M cmd/juju/deploy.go View 1 2 2 chunks +2 lines, -2 lines 0 comments Download
M cmd/juju/upgradecharm.go View 1 2 2 chunks +2 lines, -2 lines 0 comments Download
M environs/config/config.go View 1 2 4 chunks +18 lines, -5 lines 4 comments Download
M environs/config/config_test.go View 1 3 chunks +12 lines, -0 lines 0 comments Download
M state/apiserver/client/client.go View 1 2 1 chunk +1 line, -1 line 0 comments Download
M state/apiserver/client/client_test.go View 1 2 2 chunks +4 lines, -1 line 2 comments Download
M testing/charm.go View 1 2 2 chunks +6 lines, -0 lines 0 comments Download

Messages

Total messages: 7
abel.deuring
Please take a look.
10 years, 2 months ago (2014-02-28 15:10:45 UTC) #1
mue
So far mostly OK, but I dislike the identifier "testing" inside the configuration and the ...
10 years, 2 months ago (2014-02-28 15:36:33 UTC) #2
abel.deuring
Please take a look.
10 years, 2 months ago (2014-03-03 14:11:48 UTC) #3
abel.deuring
On 2014/03/03 14:11:48, abel.deuring wrote: > Please take a look. After a discussion with fwereade ...
10 years, 1 month ago (2014-03-07 11:31:58 UTC) #4
abel.deuring
Please take a look.
10 years, 1 month ago (2014-03-07 11:32:46 UTC) #5
fwereade
LGTM if the following is clear, ping me if there's any issue https://codereview.appspot.com/68000045/diff/40001/charm/repo.go File charm/repo.go ...
10 years, 1 month ago (2014-03-07 12:15:55 UTC) #6
abel.deuring
10 years, 1 month ago (2014-03-07 13:59:11 UTC) #7
https://codereview.appspot.com/68000045/diff/40001/charm/repo.go
File charm/repo.go (right):

https://codereview.appspot.com/68000045/diff/40001/charm/repo.go#newcode105
charm/repo.go:105: // SetTestMode returns a Repository where testMode is set to
value passed to
On 2014/03/07 12:15:56, fwereade wrote:
> please call this WithTestMode, we're not setting anything on the original

Done.

https://codereview.appspot.com/68000045/diff/40001/charm/repo.go#newcode143
charm/repo.go:143: charmSnippets := make([]string, len(curls)+1)
On 2014/03/07 12:15:56, fwereade wrote:
> revert this line, I don't think we need/want the empty value at the end in
> non-test-mode. The following append will still work fine. You *could* do
> `make([]string, len(curls), len(curls)+1)` to set capacity, to ensure that the
> following append doesn't reallocate -- that'd be quite nice, I guess.

Done.

https://codereview.appspot.com/68000045/diff/40001/charm/repo.go#newcode148
charm/repo.go:148: charmSnippets = append(charmSnippets, "stats=0")
On 2014/03/07 12:15:56, fwereade wrote:
> "charmSnippets" isn't a great name any more

Changed to queryParams

https://codereview.appspot.com/68000045/diff/40001/charm/repo.go#newcode352
charm/repo.go:352: store_url = store_url + "?stats=0"
On 2014/03/07 12:15:56, fwereade wrote:
> I feel like there ought to be library methods for building query strings, and
> our complete failure to use them STM to suck a bit. Would you take 5 minutes
to
> see if you can do something a bit nicer that manual query-building with
explicit
> url.QueryEscape() calls here and there?
> 
> If not, it's not a blocker: I expect there's a reason it's already like this.
> But it'd be nice.

If I understand the documentation of net/url correctly, QueryEscape() only
replaces characters that are invalid in URL or that have a special "meaning"
into %xx sequences. But I agree that constructing URLs this way sucks. (As well
as calling srings.Join(...) for example in Info(). ISTM that the standard Go
libraries do not have convenient helpers to build HTTP URLs... (But I wouldn't
claim to be very familiar with these libraries...)

https://codereview.appspot.com/68000045/diff/40001/charm/repo_test.go
File charm/repo_test.go (right):

https://codereview.appspot.com/68000045/diff/40001/charm/repo_test.go#newcode223
charm/repo_test.go:223: storeInTestMode, ok :=
s.store.SetTestMode(true).(*charm.CharmStore)
On 2014/03/07 12:15:56, fwereade wrote:
> shouldn't need to type assert here, should you?

No, it's necessary: SetTestMode()/WithTestMode() returns a Repository, not a
CharmStore, like WithAuthAttrs(). But Repository does not define the method
Info(), which is called below.

https://codereview.appspot.com/68000045/diff/40001/environs/config/config.go
File environs/config/config.go (right):

https://codereview.appspot.com/68000045/diff/40001/environs/config/config.go#...
environs/config/config.go:745: "testmode":     false,
On 2014/03/07 12:15:56, fwereade wrote:
> "test-mode" please... possible "testing-mode"? Bikeshed, bikeshed, not
*really*
> bothered, but please be consistent about separating words with "-"

Done.

https://codereview.appspot.com/68000045/diff/40001/environs/config/config.go#...
environs/config/config.go:864: repo = CS.SetTestMode(cfg.TestMode())
On 2014/03/07 12:15:56, fwereade wrote:
> you could do the auth, authSet check inside here too and only check
> .(Specializer) once

well, it's a dance with two types, Repository and CharmStore: Both
WithTestMode() and WithAuthAttrs do not return CharmStore, but we need this
type, not Repository in order to call the methods...

https://codereview.appspot.com/68000045/diff/40001/state/apiserver/client/cli...
File state/apiserver/client/client_test.go (right):

https://codereview.appspot.com/68000045/diff/40001/state/apiserver/client/cli...
state/apiserver/client/client_test.go:1733: func (s *clientSuite)
TestClientAuthorizeStoreOnDeployServiceSetCharmAndAddCharm(c *gc.C) {
On 2014/03/07 12:15:56, fwereade wrote:
> s/Authorize/Specialize/

Done.
Sign in to reply to this message.

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