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

Issue 53210044: state;apiserver: Fix a race - lp bug #1067979 (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 2 months ago by dimitern
Modified:
10 years, 2 months ago
Reviewers:
mp+203291, fwereade
Visibility:
Public.

Description

state;apiserver: Fix a race - lp bug #1067979 This introduces some changes to how charm store charms are added through the API (in state and to provider storage). Now PrepareStoreCharmUpload is called before trying to download the charm, repackage it and upload it to storage, in order to reserve a charm URL in state with pending state. Added a test that demonstrates multiple concurrent deployments of the same charm does not cause the race issues, like mentioned in the bug. A few drive-by fixes brought up during review: * Added ReadSHA256 and ReadFileSHA256 helpers in utils, and changed most places where hashes are calculated to use them. * Charms are now uploaded to storage with a randomly generated archive names with the format "<charm-name>-<revision>-<uuid>". This allows multiple concurrent uploads to happen safely, and at the end AddCharm in the API checks to see if the charm info is already updated in state and if so, deletes the duplicated upload. * Added GetEnvironStorage helper to environs/testing. * Fixed potential compatibility issues with older versions and the recently added PendingUpload and Placeholder fields of the charm document. Also tested multiple concurrent deployments with the local provider manually and updated the bug accordingly. https://code.launchpad.net/~dimitern/juju-core/260-lp-1067979-duplicate-charm/+merge/203291 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 4

Patch Set 2 : state;apiserver: Fix a race - lp bug #1067979 #

Patch Set 3 : state;apiserver: Fix a race - lp bug #1067979 #

Total comments: 15

Patch Set 4 : state;apiserver: Fix a race - lp bug #1067979 #

Total comments: 16

Patch Set 5 : state;apiserver: Fix a race - lp bug #1067979 #

Patch Set 6 : state;apiserver: Fix a race - lp bug #1067979 #

Total comments: 10

Patch Set 7 : state;apiserver: Fix a race - lp bug #1067979 #

Patch Set 8 : state;apiserver: Fix a race - lp bug #1067979 #

Patch Set 9 : state;apiserver: Fix a race - lp bug #1067979 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+562 lines, -190 lines) Patch
A [revision details] View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -0 lines 0 comments Download
M charm/repo.go View 1 2 3 4 2 chunks +2 lines, -9 lines 0 comments Download
M charm/testing/mockstore.go View 1 2 3 4 5 6 7 8 3 chunks +12 lines, -9 lines 0 comments Download
M environs/sync/sync.go View 1 2 3 4 5 6 7 8 2 chunks +6 lines, -12 lines 0 comments Download
M environs/testing/storage.go View 1 2 3 4 2 chunks +17 lines, -0 lines 0 comments Download
M environs/tools/testing/testing.go View 1 2 3 4 5 6 7 8 3 chunks +4 lines, -9 lines 0 comments Download
M juju/conn.go View 1 2 3 4 2 chunks +1 line, -6 lines 0 comments Download
M juju/conn_test.go View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M juju/testing/conn.go View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M juju/testing/repo.go View 1 2 3 4 3 chunks +2 lines, -7 lines 0 comments Download
M state/apiserver/charms.go View 1 2 3 4 3 chunks +2 lines, -17 lines 0 comments Download
M state/apiserver/charms_test.go View 1 2 3 4 5 chunks +11 lines, -16 lines 0 comments Download
M state/apiserver/client/client.go View 1 2 3 4 5 6 7 8 6 chunks +37 lines, -13 lines 0 comments Download
M state/apiserver/client/client_test.go View 1 2 3 4 5 6 7 8 5 chunks +128 lines, -14 lines 0 comments Download
M state/apiserver/export_test.go View 1 1 chunk +3 lines, -4 lines 0 comments Download
M state/state.go View 1 2 3 4 5 6 7 8 8 chunks +144 lines, -21 lines 0 comments Download
M state/state_test.go View 1 2 3 4 5 6 7 chunks +95 lines, -28 lines 0 comments Download
M testing/charm.go View 1 2 3 4 5 6 7 3 chunks +19 lines, -9 lines 0 comments Download
M utils/trivial.go View 1 2 3 4 2 chunks +26 lines, -0 lines 0 comments Download
M utils/trivial_test.go View 1 2 3 4 5 6 4 chunks +46 lines, -2 lines 0 comments Download
M worker/uniter/charm/charm.go View 1 2 3 4 2 chunks +2 lines, -6 lines 0 comments Download
M worker/uniter/uniter_test.go View 1 2 3 4 5 6 7 8 2 chunks +1 line, -6 lines 0 comments Download

Messages

Total messages: 14
dimitern
Please take a look.
10 years, 2 months ago (2014-01-27 09:41:12 UTC) #1
fwereade
A few comments, reprising what we discussed at lunch https://codereview.appspot.com/53210044/diff/1/state/apiserver/client/client.go File state/apiserver/client/client.go (right): https://codereview.appspot.com/53210044/diff/1/state/apiserver/client/client.go#newcode885 state/apiserver/client/client.go:885: ...
10 years, 2 months ago (2014-01-27 12:46:16 UTC) #2
dimitern
Please take a look. https://codereview.appspot.com/53210044/diff/1/state/apiserver/client/client.go File state/apiserver/client/client.go (right): https://codereview.appspot.com/53210044/diff/1/state/apiserver/client/client.go#newcode885 state/apiserver/client/client.go:885: storageURL, err := storage.URL(name) On ...
10 years, 2 months ago (2014-01-27 19:15:05 UTC) #3
dimitern
Please take a look.
10 years, 2 months ago (2014-01-27 19:24:06 UTC) #4
fwereade
few more comments, but the heart of it looks solid https://codereview.appspot.com/53210044/diff/40001/charm/url.go File charm/url.go (right): https://codereview.appspot.com/53210044/diff/40001/charm/url.go#newcode261 ...
10 years, 2 months ago (2014-01-28 08:19:41 UTC) #5
dimitern
Please take a look. https://codereview.appspot.com/53210044/diff/40001/charm/url.go File charm/url.go (right): https://codereview.appspot.com/53210044/diff/40001/charm/url.go#newcode261 charm/url.go:261: func (u *URL) ArchiveName() (string, ...
10 years, 2 months ago (2014-01-28 10:55:04 UTC) #6
fwereade
Very nice, last round I think https://codereview.appspot.com/53210044/diff/40001/state/apiserver/client/client_test.go File state/apiserver/client/client_test.go (right): https://codereview.appspot.com/53210044/diff/40001/state/apiserver/client/client_test.go#newcode1821 state/apiserver/client/client_test.go:1821: close(ops) On 2014/01/28 ...
10 years, 2 months ago (2014-01-28 12:00:31 UTC) #7
dimitern
Please take a look. https://codereview.appspot.com/53210044/diff/60001/state/apiserver/charms.go File state/apiserver/charms.go (right): https://codereview.appspot.com/53210044/diff/60001/state/apiserver/charms.go#newcode229 state/apiserver/charms.go:229: func GetEnvironStorage(st *state.State) (storage.Storage, error) ...
10 years, 2 months ago (2014-01-28 17:15:01 UTC) #8
fwereade
I still think there's something up with PrepareStoreCharmUpload, but it's getting late and I may ...
10 years, 2 months ago (2014-01-28 23:09:30 UTC) #9
dimitern
Please take a look. https://codereview.appspot.com/53210044/diff/60001/state/state.go File state/state.go (right): https://codereview.appspot.com/53210044/diff/60001/state/state.go#newcode625 state/state.go:625: Insert: uploadedCharm, On 2014/01/28 23:09:31, ...
10 years, 2 months ago (2014-01-29 13:49:05 UTC) #10
fwereade
Most of these are genuinely trivial now -- if we're in agreement on them all, ...
10 years, 2 months ago (2014-01-29 16:01:21 UTC) #11
dimitern
Please take a look. https://codereview.appspot.com/53210044/diff/100001/state/charm.go File state/charm.go (right): https://codereview.appspot.com/53210044/diff/100001/state/charm.go#newcode87 state/charm.go:87: func CharmArchiveName(name string, revision int) ...
10 years, 2 months ago (2014-01-29 20:59:12 UTC) #12
dimitern
Please take a look.
10 years, 2 months ago (2014-01-30 13:53:10 UTC) #13
dimitern
10 years, 2 months ago (2014-01-30 14:24:40 UTC) #14
Please take a look.
Sign in to reply to this message.

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