Merge lp:~caio1982/ubuntu-system-image/sis-nondestructive into lp:ubuntu-system-image/server

Proposed by Caio Begotti
Status: Work in progress
Proposed branch: lp:~caio1982/ubuntu-system-image/sis-nondestructive
Merge into: lp:ubuntu-system-image/server
Diff against target: 63 lines (+13/-4)
3 files modified
bin/copy-image (+5/-2)
bin/import-images (+5/-2)
lib/systemimage/tree.py (+3/-0)
To merge this branch: bzr merge lp:~caio1982/ubuntu-system-image/sis-nondestructive
Reviewer Review Type Date Requested Status
Stéphane Graber (community) Needs Fixing
Review via email: mp+252581@code.launchpad.net

Description of the change

Folks, these changes are small but quite important for us on PES as we got our built images deleted without much alert inside our storage, which was pointing to the same publish path when we hooked it to image server. So we think this should be optional in the scripts, and also we should avoid deleting the publish path itself, otherwise all next runs of import-images and copy-images will probably fail with this:

Traceback (most recent call last):
  File "bin/import-images", line 66, in <module>
    pub = tree.Tree(conf)
  File "/tmp/system-image/bin/../lib/systemimage/tree.py", line 153, in __init__
    raise Exception("Invalid path: %s" % path)

To keep the original behaviour you just need to pass option -c to copy and import images calls in your cron jobs.

To post a comment you must log in.
Revision history for this message
Stéphane Graber (stgraber) wrote :

I'm still against changing the default behavior. There are a few people using this code in production and requiring them to notice this change and update their cron entries is unacceptable.

Turn that into a --no-cleanup option and I may reconsider.

review: Disapprove
262. By Caio Begotti

turn the new behavior really new, respecting current "production deployments" of the code that might not be easily updated so anyone looking for the new behavior must explicetely pass the --no-cleanup option to copy or import scripts

Revision history for this message
Caio Begotti (caio1982) wrote :

Ok, I thought about making it --keep-orphaned/-k but I stuck with your suggestion instead, code updated.

Revision history for this message
Caio Begotti (caio1982) wrote :

Also, I left the short option out because there might be better uses of '-n' in the future I guess.

Revision history for this message
Stéphane Graber (stgraber) wrote :

This branch is regressing code coverage, please fix.

Name Stmts Miss Cover Missing
----------------------------------------------------------
lib/systemimage/__init__ 0 0 100%
lib/systemimage/config 109 0 100%
lib/systemimage/diff 110 0 100%
lib/systemimage/generators 771 0 100%
lib/systemimage/gpg 124 0 100%
lib/systemimage/tools 177 0 100%
lib/systemimage/tree 513 1 99% 251
----------------------------------------------------------
TOTAL 1804 1 99%

review: Needs Fixing
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Caio, could you re-visit this branch? If you're too busy I could pick it up in your stead as I would love to get this in as well. Without this flag sometimes I need to re-download a lot of images in my local staging instance when something goes wrong.

Revision history for this message
Caio Begotti (caio1982) wrote :

Lukasz, feel free to pick it up if it's very urgent for you but I plan
to get back to my semi-abandoned branches sometime next week!

On Fri, May 8, 2015 at 10:29 AM, Łukasz Zemczak
<email address hidden> wrote:
> Caio, could you re-visit this branch? If you're too busy I could pick it up in your stead as I would love to get this in as well. Without this flag sometimes I need to re-download a lot of images in my local staging instance when something goes wrong.
> --
> https://code.launchpad.net/~caio1982/ubuntu-system-image/sis-nondestructive/+merge/252581
> You are the owner of lp:~caio1982/ubuntu-system-image/sis-nondestructive.

Unmerged revisions

262. By Caio Begotti

turn the new behavior really new, respecting current "production deployments" of the code that might not be easily updated so anyone looking for the new behavior must explicetely pass the --no-cleanup option to copy or import scripts

261. By Caio Begotti

avoid being so destructive when running the script, as it might wipe out any artifacts in the same path of the publish path

the different from before is that to keep the old behaviour you need to pass option -c to the copy and import images commands, that is all

for the rest of us it means the default behaviour now is to never wipe out images after they are processed, this way image server can coexist with an archiver storage for instance, like capomastro needs in the PES team to build phone images

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/copy-image'
--- bin/copy-image 2015-03-11 20:55:00 +0000
+++ bin/copy-image 2015-03-11 21:27:59 +0000
@@ -36,6 +36,7 @@
36 parser.add_argument("-k", "--keep-version", action="store_true",36 parser.add_argument("-k", "--keep-version", action="store_true",
37 help="Keep the original verison number")37 help="Keep the original verison number")
38 parser.add_argument("--verbose", "-v", action="count", default=0)38 parser.add_argument("--verbose", "-v", action="count", default=0)
39 parser.add_argument("--no-cleanup", action='store_true', default=False)
3940
40 args = parser.parse_args()41 args = parser.parse_args()
4142
@@ -302,8 +303,10 @@
302 pub.sync_aliases(args.destination_channel)303 pub.sync_aliases(args.destination_channel)
303304
304 # Remove any orphaned file305 # Remove any orphaned file
305 logging.info("Removing orphaned files from the pool")306 if not args.no_cleanup:
306 pub.cleanup_tree()307 orphans = ', '.join(pub.list_orphaned_files())
308 logging.info("Removing orphaned files from the pool: %s", orphans)
309 pub.cleanup_tree()
307310
308 # Sync the mirrors311 # Sync the mirrors
309 logging.info("Triggering a mirror sync")312 logging.info("Triggering a mirror sync")
310313
=== modified file 'bin/import-images'
--- bin/import-images 2015-03-11 20:55:00 +0000
+++ bin/import-images 2015-03-11 21:27:59 +0000
@@ -29,6 +29,7 @@
29if __name__ == '__main__':29if __name__ == '__main__':
30 parser = argparse.ArgumentParser(description="image importer")30 parser = argparse.ArgumentParser(description="image importer")
31 parser.add_argument("--verbose", "-v", action="count", default=0)31 parser.add_argument("--verbose", "-v", action="count", default=0)
32 parser.add_argument("--no-cleanup", action='store_true', default=False)
32 args = parser.parse_args()33 args = parser.parse_args()
3334
34 # Setup logging35 # Setup logging
@@ -301,8 +302,10 @@
301 pub.sync_aliases(channel_name)302 pub.sync_aliases(channel_name)
302303
303 # Remove any orphaned file304 # Remove any orphaned file
304 logging.info("Removing orphaned files from the pool")305 if not args.no_cleanup:
305 pub.cleanup_tree()306 orphans = ', '.join(pub.list_orphaned_files())
307 logging.info("Removing orphaned files from the pool: %s", orphans)
308 pub.cleanup_tree()
306309
307 # Sync the mirrors310 # Sync the mirrors
308 logging.info("Triggering a mirror sync")311 logging.info("Triggering a mirror sync")
309312
=== modified file 'lib/systemimage/tree.py'
--- lib/systemimage/tree.py 2015-03-11 20:55:00 +0000
+++ lib/systemimage/tree.py 2015-03-11 21:27:59 +0000
@@ -243,6 +243,9 @@
243 """243 """
244244
245 for entry in self.list_orphaned_files():245 for entry in self.list_orphaned_files():
246 if entry in self.path:
247 continue
248
246 if os.path.isdir(entry):249 if os.path.isdir(entry):
247 os.rmdir(entry)250 os.rmdir(entry)
248 else:251 else:

Subscribers

People subscribed via source and target branches

to all changes: