Merge lp:~axwalk/juju-core/filestorage-write-tmpdir into lp:~go-bot/juju-core/trunk
Status: | Merged |
---|---|
Approved by: | Andrew Wilkins |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1836 |
Proposed branch: | lp:~axwalk/juju-core/filestorage-write-tmpdir |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
247 lines (+84/-19) 9 files modified
cmd/juju/synctools.go (+1/-1) cmd/plugins/juju-metadata/toolsmetadata.go (+1/-1) environs/filestorage/filestorage.go (+41/-8) environs/filestorage/filestorage_test.go (+33/-1) environs/httpstorage/backend_test.go (+1/-1) environs/testing/storage.go (+1/-1) environs/tools/simplestreams_test.go (+3/-3) provider/local/environ.go (+1/-1) provider/local/storage/worker.go (+2/-2) |
To merge this branch: | bzr merge lp:~axwalk/juju-core/filestorage-write-tmpdir |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tim Penhey (community) | Approve | ||
Review via email: mp+185715@code.launchpad.net |
Commit message
environs/
As requested in review of manual-bootstrap:
https:/
A new parameter is added to NewFileStorageW
to specify a temporary directory. Put will now
write to a temporary file in this location, and
then move it to the final destination; as long
as the temporary directory exists on the same
filesystem as the storage directory, this should
be atomic.
If the temporary directory is unspecified/blank,
then storagedir+".tmp" will be used to ensure
a "default" of colocation on the storage directory's
filesystem.
While it is not strictly necessary, the temporary
directory location will match that of sshstorage
(merge proposal pending).
Description of the change
environs/
As requested in review of manual-bootstrap:
https:/
A new parameter is added to NewFileStorageW
to specify a temporary directory. Put will now
write to a temporary file in this location, and
then move it to the final destination; as long
as the temporary directory exists on the same
filesystem as the storage directory, this should
be atomic.
If the temporary directory is unspecified/blank,
then storagedir+".tmp" will be used to ensure
a "default" of colocation on the storage directory's
filesystem.
While it is not strictly necessary, the temporary
directory location will match that of sshstorage
(merge proposal pending).
Reviewers: mp+185715_ code.launchpad. net,
Message:
Please take a look.
Description: filestorage: optional atomic Put
environs/
As requested in review of manual-bootstrap: /code.launchpad .net/~axwalk/ juju-core/ manual- bootstrap/ +merge/ 184714
https:/
A new parameter is added to NewFileStorageW riter
to specify a temporary directory. Put will now
write to a temporary file in this location, and
then move it to the final destination; as long
as the temporary directory exists on the same
filesystem as the storage directory, this should
be atomic.
As with io/ioutil TemporaryFile, if the temporary
directory is blank, os.TempDir will be used to
get the default temporary directory.
https:/ /code.launchpad .net/~axwalk/ juju-core/ filestorage- write-tmpdir/ +merge/ 185715
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/13727043/ 20130916061421- 7r11uoyztquho14 o
Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: cmd/juju/ synctools. go synctools. go' synctools. go 2013-09-13 04:16:42 +0000 synctools. go 2013-09-16 06:41:18 +0000
=== modified file 'cmd/juju/
--- cmd/juju/
+++ cmd/juju/
@@ -83,7 +83,7 @@
target := environ.Storage() NewFileStorageW riter(c. destination) NewFileStorageW riter(c. destination, "")
if c.destination != "" {
- target, err = filestorage.
+ target, err = filestorage.
if err != nil {
return err
}
Index: environs/ filestorage/ filestorage. go filestorage/ filestorage. go' filestorage/ filestorage. go 2013-09-12 05:04:40 +0000 filestorage/ filestorage. go 2013-09-16 06:41:18 +0000
=== modified file 'environs/
--- environs/
+++ environs/
@@ -21,7 +21,7 @@
path string
}
-// newFileStorageR eader returns a new storage reader for eader returns a new storage reader for eader(path string) (environs. StorageReader, error) { Clean(path)
+// NewFileStorageR
// a directory inside the local file system.
func NewFileStorageR
p := filepath.
@@ -85,14 +85,22 @@
type fileStorageWriter struct { eader
fileStorageR
+ tmpdir string
}
-func NewFileStorageW riter(path string) (environs.Storage, error) { riter returns a new read/write storag for riter(path, tmpdir string) (environs.Storage, error) { eader(path) ter{*reader. (*fileStorageRe ader)}, nil ter{*reader. (*fileStorageRe ader), tmpdir}, nil
+// NewFileStorageW
+// a directory inside the local file system.
+//
+// A temporary directory may be specified, in which files will be written
+// to before moving to the final destination. If specified, the temporary
+// directory should be on the same filesystem as the storage directory
+// to ensure atomicity. If left unspecified (blank), $TMPDIR will be used.
+func NewFileStorageW
reader, err := NewFileStorageR
if err != nil {
return nil, err
}
- return &fileStorageWri
+ return &fileStorageWri
}
func (f *fileStorageWriter) Put(name string, r io.Reader, length int64)
error {
@@ -101,11 +109,18 @@
if err := os.MkdirAll(dir, 0755); err != nil && !os.IsExist...