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

Issue 11087043: Add RemoveAll() to environs.StorageWriter. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 9 months ago by jtv.canonical
Modified:
10 years, 8 months ago
Reviewers:
dimitern, mp+173857, jameinel, fwereade
Visibility:
Public.

Description

Add RemoveAll() to environs.StorageWriter. There was one method that just about all providers need from their storage implementations, but which wasn't on the interface: "delete all files." To work around this, several providers took their Storage() and downcast it to their own specific Storage implementation, just to call an internal deleteAll() method. The EC2 provider solved it by referring to the implementation type, rather than the interface type, from the environment object. And the Azure one solved it by going straight into the internals from its Environ.Destroy() implementation. Adding a "delete all" method to the interface solves all that. (I provided a shared basic implementation for the dummy and local storage implementations. It can't easily be tested on its own, but it's covered indirectly by these uses.) The new method is called RemoveAll, for consistency with the existing Remove() method. It should now be possible to jack a local storage object into an EC2 provider instance, and indeed into any other provider, to simplify testing. And some ugly HTTP-level mocking and testing disappears from the Azure provider. https://code.launchpad.net/~jtv/juju-core/providers-deleteall/+merge/173857 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 1

Patch Set 2 : Add RemoveAll() to environs.StorageWriter. #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+153 lines, -99 lines) Patch
A [revision details] View 1 1 chunk +2 lines, -0 lines 0 comments Download
M environs/azure/environ.go View 1 chunk +1 line, -7 lines 0 comments Download
M environs/azure/environ_test.go View 4 chunks +10 lines, -50 lines 0 comments Download
M environs/azure/storage.go View 1 chunk +11 lines, -0 lines 0 comments Download
M environs/azure/storage_test.go View 1 chunk +25 lines, -0 lines 0 comments Download
M environs/dummy/storage.go View 1 chunk +7 lines, -0 lines 0 comments Download
M environs/ec2/ec2.go View 2 chunks +4 lines, -6 lines 1 comment Download
M environs/ec2/export_test.go View 1 chunk +0 lines, -4 lines 0 comments Download
M environs/ec2/live_test.go View 1 chunk +1 line, -1 line 0 comments Download
M environs/ec2/storage.go View 1 chunk +2 lines, -2 lines 0 comments Download
M environs/emptystorage.go View 0 chunks +-1 lines, --1 lines 0 comments Download
M environs/emptystorage_test.go View 0 chunks +-1 lines, --1 lines 0 comments Download
M environs/interface.go View 1 1 chunk +8 lines, -0 lines 1 comment Download
M environs/localstorage/storage.go View 1 chunk +4 lines, -0 lines 0 comments Download
M environs/localstorage/storage_test.go View 3 chunks +27 lines, -1 line 0 comments Download
M environs/maas/environ.go View 1 chunk +2 lines, -4 lines 0 comments Download
M environs/maas/storage.go View 6 chunks +7 lines, -6 lines 0 comments Download
M environs/maas/storage_test.go View 1 chunk +2 lines, -2 lines 0 comments Download
M environs/openstack/export_test.go View 1 chunk +0 lines, -4 lines 0 comments Download
M environs/openstack/local_test.go View 3 chunks +3 lines, -3 lines 0 comments Download
M environs/openstack/provider.go View 1 chunk +2 lines, -4 lines 0 comments Download
M environs/openstack/storage.go View 3 chunks +9 lines, -7 lines 0 comments Download
A environs/storage.go View 1 chunk +28 lines, -0 lines 1 comment Download

Messages

Total messages: 7
jtv.canonical
Please take a look.
10 years, 9 months ago (2013-07-10 05:47:55 UTC) #1
fwereade
This is awesome, LGTM apart from the rogue paste marked below. https://codereview.appspot.com/11087043/diff/1/environs/interface.go File environs/interface.go (right): ...
10 years, 9 months ago (2013-07-10 09:38:48 UTC) #2
jtv.canonical
On 2013/07/10 09:38:48, fwereade wrote: > This is awesome, LGTM apart from the rogue paste ...
10 years, 9 months ago (2013-07-10 10:11:46 UTC) #3
jtv.canonical
Please take a look.
10 years, 9 months ago (2013-07-10 10:15:55 UTC) #4
dimitern
Very nice cleanup! LGTM.
10 years, 9 months ago (2013-07-10 10:27:49 UTC) #5
jameinel
LGTM Given this is a new interface attribute, I'd like to see an associated interface ...
10 years, 9 months ago (2013-07-10 10:30:23 UTC) #6
jtv.canonical
10 years, 9 months ago (2013-07-10 11:14:07 UTC) #7
On 2013/07/10 10:30:23, jameinel wrote:

> Given this is a new interface attribute, I'd like to see an associated
interface
> test. Something in environs/jujutest/livetests.go should work well.

Thanks for the review!  Some good, critical points here.

Since I'll be reviewing one of yours as well, and to manage scope, I'll add the
test in a separate branch.


>
https://codereview.appspot.com/11087043/diff/6001/environs/ec2/ec2.go#newcode545
> environs/ec2/ec2.go:545: // holding e.ecfgMutex. e.Storage() does this for us.
> I think you can remove the comment completely as we aren't pretending to touch
> e.storageUnlocked directly.

You're right.  It did feel a bit superfluous, but I figured I might be seeing it
less clearly than someone more familiar with the design.  Removed.


>
https://codereview.appspot.com/11087043/diff/6001/environs/interface.go#newco...
> environs/interface.go:91: RemoveAll() error
> If we are adding an API to the official interface, can you add an associated
> test to
> 
> environs/jujutest/livetests.go ?

Will do, after I've reviewed your branch!


>
https://codereview.appspot.com/11087043/diff/6001/environs/storage.go#newcode14
> environs/storage.go:14: func RemoveAll(stor Storage) error {
> Is this used? it looks more like all the implementations already did their own
> thing.

The localstorage implementation uses it.  It didn't have an equivalent of
RemoveAll.
Sign in to reply to this message.

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