Merge lp:~cjohnston/ubuntu-ci-services-itself/push-img-swift into lp:ubuntu-ci-services-itself

Proposed by Chris Johnston
Status: Merged
Approved by: Chris Johnston
Approved revision: 389
Merged at revision: 399
Proposed branch: lp:~cjohnston/ubuntu-ci-services-itself/push-img-swift
Merge into: lp:ubuntu-ci-services-itself
Diff against target: 95 lines (+27/-13)
3 files modified
ci-utils/ci_utils/amqp_worker.py (+8/-5)
image-builder/imagebuilder/cloud_image.py (+12/-6)
image-builder/imagebuilder/run_worker.py (+7/-2)
To merge this branch: bzr merge lp:~cjohnston/ubuntu-ci-services-itself/push-img-swift
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Andy Doan (community) Approve
Chris Johnston (community) Needs Resubmitting
Francis Ginther Needs Fixing
Review via email: mp+211142@code.launchpad.net

Commit message

Push build images to swift storage for later retrieval

Description of the change

This is the first part of a multi-part MP to enable a user to download the built image files via the CLI.

To post a comment you must log in.
Revision history for this message
Andy Doan (doanac) wrote :

is there a reason to not use the create_datatore implemention:

 http://bazaar.launchpad.net/~canonical-ci-engineering/ubuntu-ci-services-itself/trunk/view/head:/ci-utils/ci_utils/amqp_worker.py#L110

instead of creating one in cloud_image.py?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:386
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/430/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/430/rebuild

review: Approve (continuous-integration)
387. By Chris Johnston

Update per review

Revision history for this message
Chris Johnston (cjohnston) :
review: Needs Resubmitting
Revision history for this message
Francis Ginther (fginther) wrote :

76 + ds = _create_data_store(ticket_id)
77 + ds.change_visibility()
53 + with open(converted_image_path, 'r') as fp:
54 + location = ds.put_file(upload_filename, fp)

I believe public/private is a setting for the container. So doesn't this just set the container to private until the next component comes along and changes visibility back to public? Perhaps I missing something.

review: Needs Fixing
Revision history for this message
Chris Johnston (cjohnston) wrote :

On Fri, Mar 14, 2014 at 6:13 PM, Francis Ginther <
<email address hidden>> wrote:

> Review: Needs Fixing
>
> 76 + ds = _create_data_store(ticket_id)
> 77 + ds.change_visibility()
> 53 + with open(converted_image_path, 'r') as fp:
> 54 + location = ds.put_file(upload_filename, fp)
>
> I believe public/private is a setting for the container. So doesn't this
> just set the container to private until the next component comes along and
> changes visibility back to public? Perhaps I missing something.
>

 67+ ds_name = params['ticket_id'] + '-image' 68+ ds =
self._create_data_store(ds_name)
Here you will see that we are creating a separate data store called
ticket-<id>-image... So, nothing else should be setting this container to
public.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:387
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/433/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/433/rebuild

review: Approve (continuous-integration)
Revision history for this message
Evan (ev) wrote :

17 + def _create_artifact(self, name, url, retval, type='LOGS'):

This could use a docstring.

54 + location = ds.put_file(upload_filename, fp)

Shouldn't we catch and handle DataStoreException here?

Revision history for this message
Andy Doan (doanac) wrote :

On 03/14/2014 06:55 PM, Evan Dandrea wrote:
> 54 + location = ds.put_file(upload_filename, fp)
>
> Shouldn't we catch and handle DataStoreException here?

Good idea. If this fails, the ticket should be able to continue. eg, all
is not lost.

Revision history for this message
Francis Ginther (fginther) wrote :

> On Fri, Mar 14, 2014 at 6:13 PM, Francis Ginther <
> <email address hidden>> wrote:
>
> > Review: Needs Fixing
> >
> > 76 + ds = _create_data_store(ticket_id)
> > 77 + ds.change_visibility()
> > 53 + with open(converted_image_path, 'r') as fp:
> > 54 + location = ds.put_file(upload_filename, fp)
> >
> > I believe public/private is a setting for the container. So doesn't this
> > just set the container to private until the next component comes along and
> > changes visibility back to public? Perhaps I missing something.
> >
>
> 67+ ds_name = params['ticket_id'] + '-image' 68+ ds =
> self._create_data_store(ds_name)
> Here you will see that we are creating a separate data store called
> ticket-<id>-image... So, nothing else should be setting this container to
> public.

I swear I was looking for something like this, just in the wrong place. Thanks for clearing up.

388. By Chris Johnston

Catch exception per review

Revision history for this message
Chris Johnston (cjohnston) :
review: Needs Resubmitting
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:388
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/435/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/435/rebuild

review: Approve (continuous-integration)
Revision history for this message
Andy Doan (doanac) :
review: Approve
389. By Chris Johnston

Merge trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:389
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/436/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/436/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ci-utils/ci_utils/amqp_worker.py'
--- ci-utils/ci_utils/amqp_worker.py 2014-03-12 21:45:22 +0000
+++ ci-utils/ci_utils/amqp_worker.py 2014-03-15 11:29:58 +0000
@@ -128,14 +128,17 @@
128 try:128 try:
129 name = '{}.output.log'.format(logger.name)129 name = '{}.output.log'.format(logger.name)
130 url = store.put_file(name, content, 'text/plain')130 url = store.put_file(name, content, 'text/plain')
131 retval.setdefault('artifacts', []).append({131 self._create_artifact(name, url, retval)
132 'name': name,
133 'reference': url,
134 'type': 'LOGS',
135 })
136 except:132 except:
137 log.exception('unable to store worker log')133 log.exception('unable to store worker log')
138134
135 def _create_artifact(self, name, url, retval, type='LOGS'):
136 retval.setdefault('artifacts', []).append({
137 'name': name,
138 'reference': url,
139 'type': type,
140 })
141
139 def _handle_cancel(self, params):142 def _handle_cancel(self, params):
140 '''provide an advisory mechansim to inform the worker to stop143 '''provide an advisory mechansim to inform the worker to stop
141144
142145
=== modified file 'image-builder/imagebuilder/cloud_image.py'
--- image-builder/imagebuilder/cloud_image.py 2014-03-15 03:27:45 +0000
+++ image-builder/imagebuilder/cloud_image.py 2014-03-15 11:29:58 +0000
@@ -31,7 +31,7 @@
3131
32from imagebuilder import ImageException32from imagebuilder import ImageException
33from ci_utils.image_store import ImageStore33from ci_utils.image_store import ImageStore
34from ci_utils import dump_stack, launchpad34from ci_utils import dump_stack, data_store, launchpad
3535
3636
37log = logging.getLogger('Imagebuilder')37log = logging.getLogger('Imagebuilder')
@@ -228,7 +228,7 @@
228 runcmd('qemu-nbd -d /dev/%s' % self.nbd_dev)228 runcmd('qemu-nbd -d /dev/%s' % self.nbd_dev)
229229
230230
231def modify_image(image, repos, series, packages, status_cb=None):231def modify_image(image, repos, series, packages, ds, status_cb=None):
232 '''Add packges and PPAs to a cloud image mounted in a chroot'''232 '''Add packges and PPAs to a cloud image mounted in a chroot'''
233 if not status_cb:233 if not status_cb:
234 status_cb = lambda x: 0 # just provide a no-op234 status_cb = lambda x: 0 # just provide a no-op
@@ -250,11 +250,17 @@
250 status_cb('Shrinking the converted image...')250 status_cb('Shrinking the converted image...')
251 runcmd('qemu-img convert -O qcow2 -c %s %s' % (251 runcmd('qemu-img convert -O qcow2 -c %s %s' % (
252 image_path, converted_image_path))252 image_path, converted_image_path))
253 glance_filename = str(uuid.uuid1()) + '.img'253 upload_filename = str(uuid.uuid1()) + '.img'
254 status_cb(254 status_cb(
255 'Uploading converted image to glance as %s' % glance_filename)255 'Uploading converted image to glance as %s' % upload_filename)
256 glance.image_create(glance_filename, converted_image_path)256 glance.image_create(upload_filename, converted_image_path)
257 return glance_filename257 try:
258 ds.change_visibility()
259 with open(converted_image_path, 'r') as fp:
260 location = ds.put_file(upload_filename, fp)
261 except data_store.DataStoreException:
262 status_cb('ERROR: unable to upload image to swift')
263 return upload_filename, location
258264
259265
260def main():266def main():
261267
=== modified file 'image-builder/imagebuilder/run_worker.py'
--- image-builder/imagebuilder/run_worker.py 2014-03-14 21:54:37 +0000
+++ image-builder/imagebuilder/run_worker.py 2014-03-15 11:29:58 +0000
@@ -29,13 +29,18 @@
29 series = params['series']29 series = params['series']
30 packages = params['package_list']30 packages = params['package_list']
31 trigger = params['progress_trigger']31 trigger = params['progress_trigger']
32 ds_name = params['ticket_id'] + '-image'
33 ds = self._create_data_store(ds_name)
3234
33 def status_cb(msg):35 def status_cb(msg):
34 log.info(msg)36 log.info(msg)
35 amqp_utils.progress_update(trigger, {'message': msg})37 amqp_utils.progress_update(trigger, {'message': msg})
3638
37 image_id = modify_image(image, repos, series, packages, status_cb)39 image_id, location = modify_image(image, repos, series, packages,
38 return amqp_utils.progress_completed, {'image_id': image_id}40 ds, status_cb)
41 retval = {'image_id': image_id}
42 self._create_artifact(image_id, location, retval, type='IMAGE')
43 return amqp_utils.progress_completed, retval
3944
4045
41if __name__ == '__main__':46if __name__ == '__main__':

Subscribers

People subscribed via source and target branches