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

Issue 81110043: uniter/charm: manifestDeployer type

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 1 month ago by fwereade
Modified:
10 years ago
Reviewers:
mp+212962, jameinel
Visibility:
Public.

Description

uniter/charm: manifestDeployer type unit tested, but not integrated yet https://code.launchpad.net/~fwereade/juju-core/actual-manifest-deployer/+merge/212962 Requires: https://code.launchpad.net/~fwereade/juju-core/filetesting-package/+merge/212811 (do not edit description out of merge proposal)

Patch Set 1 #

Patch Set 2 : uniter/charm: manifestDeployer type #

Patch Set 3 : uniter/charm: manifestDeployer type #

Patch Set 4 : uniter/charm: manifestDeployer type #

Total comments: 18
Unified diffs Side-by-side diffs Delta from patch set Stats (+517 lines, -1 line) Patch
A [revision details] View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
M worker/uniter/charm/charm_test.go View 1 2 chunks +21 lines, -1 line 3 comments Download
A worker/uniter/charm/manifest_deployer.go View 1 chunk +236 lines, -0 lines 12 comments Download
A worker/uniter/charm/manifest_deployer_test.go View 1 2 3 1 chunk +258 lines, -0 lines 3 comments Download

Messages

Total messages: 6
fwereade
Please take a look.
10 years, 1 month ago (2014-03-27 13:38:03 UTC) #1
fwereade
Please take a look.
10 years, 1 month ago (2014-04-02 09:19:51 UTC) #2
jameinel
I had a few comments, but it looks pretty good to me overall. LGTM, though ...
10 years, 1 month ago (2014-04-03 11:14:42 UTC) #3
jameinel
a suggested spelling for the wait and abort code. https://codereview.appspot.com/81110043/diff/60001/worker/uniter/charm/charm_test.go File worker/uniter/charm/charm_test.go (right): https://codereview.appspot.com/81110043/diff/60001/worker/uniter/charm/charm_test.go#newcode40 worker/uniter/charm/charm_test.go:40: ...
10 years, 1 month ago (2014-04-03 11:26:02 UTC) #4
fwereade
On 2014/04/03 11:26:02, jameinel wrote: > a suggested spelling for the wait and abort code. ...
10 years ago (2014-04-11 06:33:08 UTC) #5
fwereade
10 years ago (2014-04-11 06:39:56 UTC) #6
https://codereview.appspot.com/81110043/diff/60001/worker/uniter/charm/charm_...
File worker/uniter/charm/charm_test.go (right):

https://codereview.appspot.com/81110043/diff/60001/worker/uniter/charm/charm_...
worker/uniter/charm/charm_test.go:40: if br.waitAbort == nil {
On 2014/04/03 11:26:02, jameinel wrote:
> Perhaps this:
> 
> waitingForAbortChan = br.waitAbort
> if waitingForAbortChan == nil {
>   // We aren't waiting for an abort, so we just need an always-closed channel
>   waitingForAbortChan = make(chan struct{})
>   close(waitingForAbortChan)
> } else {
>   // EnableWaitForAbort is a one-time wait, so make sure it is gone when we
are
> done
>   defer func() { br.WaitAbort = nil }()
> }
> 
> select {
> case <-abort:
>   return nil, fmt.Errorf("charm read aborted")
> case <-waitForAbortChan:
>   // someone asked us to stop waiting, so return the bundle now
> }
> return bundle, nil
> 
> // EnableWaitForAbort makes it so that the next call to bundleReader.Read()
can
> be aborted (in testing). Otherwise the reader can finish faster than the abort
> could be triggered. The returned channel can be closed when the caller doesn't
> want to wait anymore. [closing the abort channel will cause Read() to fail
with
> an abort, closing the waiting channel will cause the Read() to succeed.]
> func (br *bundleReader) EnableWaitForAbort() chan struct {
> }

Done, but a bit differently.

https://codereview.appspot.com/81110043/diff/60001/worker/uniter/charm/manife...
File worker/uniter/charm/manifest_deployer.go (right):

https://codereview.appspot.com/81110043/diff/60001/worker/uniter/charm/manife...
worker/uniter/charm/manifest_deployer.go:17: // deployingURLPath holds the path
in the charm dir to which the manifest
On 2014/04/03 11:14:42, jameinel wrote:
> holds the path in the charm dir *where* the manifest ...

Really? Seems wrong to me. Done regardless.

https://codereview.appspot.com/81110043/diff/60001/worker/uniter/charm/manife...
worker/uniter/charm/manifest_deployer.go:95: if err :=
d.removeDiff(baseManifest, d.staged.manifest); err != nil {
On 2014/04/03 11:14:42, jameinel wrote:
> Is it worth optimizing for when baseURL is nil then baseManifest is an empty
set
> and we could just skip this step? (either here or in the removeDiff)?

I originally did that but it seemed to obscure the flow for no actual
improvement in behaviour. OTOH, I do now have `upgrading` in a var, so let's go
with it.

https://codereview.appspot.com/81110043/diff/60001/worker/uniter/charm/manife...
worker/uniter/charm/manifest_deployer.go:135: for _, path := range
diff.SortedValues() {
On 2014/04/03 11:14:42, jameinel wrote:
> When deleting you need to go in reverse sorted order. So that you delete
> "foo/bar" before you delete "foo/".
> 
> Arguably if RemoveAll doesn't fail when the target doesn't exist, then it
isn't
> terrible to just rm -rf the dir first, and then ignore the fact that you can't
> ignore the contents later.
> But if we wanted a more careful "only remove what we put there" and used
> os.Remove and os.Rmdir() then we'd want to reverse the list.
> 
> It would probably be good, regardless, to have a test that has a charm that
> removes a directory and a file within that directory.
> 
> http://golang.org/pkg/os/#RemoveAll does say it returns no-error when the path
> doesn't exist.

We want to be brutal about overwrites -- using this will actually resolve
lp:1191028 as well. Charms which want to keep user files in old dirs can just
leave the dir in the charm, and user files will be preserved; if there's only
junk like .pycs, they will be trashed without mercy.

https://codereview.appspot.com/81110043/diff/60001/worker/uniter/charm/manife...
worker/uniter/charm/manifest_deployer.go:152: // one, removes all entries in the
manifest for the interrupted operation. This
On 2014/04/03 11:14:42, jameinel wrote:
> It doesn't seem to remove all entries, just the different ones. probably
change
> it to:
> removes all entries unique to the manifest for the interrupted operation.

Done.

https://codereview.appspot.com/81110043/diff/60001/worker/uniter/charm/manife...
worker/uniter/charm/manifest_deployer.go:163: logger.Debugf("detected
interrupted deploy of charm %q", deployingURL)
On 2014/04/03 11:14:42, jameinel wrote:
> maybe higher than Debugf, as this is likely a bad place to be in. Infof seems
> appropriate.

Done.

https://codereview.appspot.com/81110043/diff/60001/worker/uniter/charm/manife...
worker/uniter/charm/manifest_deployer.go:178: func (d *manifestDeployer)
storeManifest(url *charm.URL, manifest set.Strings) error {
On 2014/04/03 11:14:42, jameinel wrote:
> It seems like it would be nice if the Manifest had the concept of its own URL
in
> the content of the file, rather than only as the Quoted URL name.
> That would imply writing a nested YAML file (since you need some way to have
> content that is the actual files and some content that is metadata).
> Is that worth doing?
> I really like things on disk to be self describing, but maybe I'm going
> overboard.

I dunno -- I feel that the unit of self-description is the directory itself
really. Once you have a charm url in the file, you have an opportunity for
inconsistency between the real key -- the filename -- and the contents; and then
you need to think about how to handle that inconsistency... it's just more
things that could go wrong.

https://codereview.appspot.com/81110043/diff/60001/worker/uniter/charm/manife...
File worker/uniter/charm/manifest_deployer_test.go (right):

https://codereview.appspot.com/81110043/diff/60001/worker/uniter/charm/manife...
worker/uniter/charm/manifest_deployer_test.go:89: wait :=
s.bundles.SetAbortWait()
On 2014/04/03 11:14:42, jameinel wrote:
> I can see that you are testing that SetAbortWait does something, but it isn't
> clear to me what the use case for it is. (It seems to just create another
> channel like abort but that doesn't cause an error to be returned.)

Yeah, I have evidently not made its purpose sufficiently clear.
Sign in to reply to this message.

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