Merge lp:~terceiro/lava-dispatcher/master-device-version into lp:lava-dispatcher

Proposed by Antonio Terceiro
Status: Merged
Merged at revision: 490
Proposed branch: lp:~terceiro/lava-dispatcher/master-device-version
Merge into: lp:lava-dispatcher
Diff against target: 80 lines (+30/-1)
2 files modified
lava_dispatcher/device/master.py (+26/-0)
lava_dispatcher/job.py (+4/-1)
To merge this branch: bzr merge lp:~terceiro/lava-dispatcher/master-device-version
Reviewer Review Type Date Requested Status
Linaro Validation Team Pending
Review via email: mp+138463@code.launchpad.net

Description of the change

this branch adds support for obtaining the version (hwpack/rootfs) for master images.

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

On 12/06/2012 08:21 AM, Antonio Terceiro wrote:
> === modified file 'lava_dispatcher/job.py'
> --- lava_dispatcher/job.py 2012-11-24 20:58:07 +0000
> +++ lava_dispatcher/job.py 2012-12-06 14:20:27 +0000
> @@ -148,7 +148,6 @@
>
> metadata = {
> 'target.hostname': self.target,
> - 'target.device_version': self.context.get_device_version(),
> }
>
> if 'device_type' in self.job_data:
> @@ -232,6 +231,7 @@
> self.context.test_data.job_status = 'fail'
> raise
> finally:
> + self.context.test_data.add_metadata({ 'target.device_version': self.context.get_device_version() or 'error'})

Is the get_device_version sufficiently exception-safe? ie - the 3 lines
of code after this are important or the lava-results won't get submitted
properly. I'm not the best at proper error handling, maybe Michael can
speculate. Also - this wraps way past column 80 and is going to make
pylint/pflakes/etc complain.

> if submit_results:
> params = submit_results.get('parameters', {})
> action = lava_commands[submit_results['command']](

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Andy Doan <email address hidden> writes:

> On 12/06/2012 08:21 AM, Antonio Terceiro wrote:
>> === modified file 'lava_dispatcher/job.py'
>> --- lava_dispatcher/job.py 2012-11-24 20:58:07 +0000
>> +++ lava_dispatcher/job.py 2012-12-06 14:20:27 +0000
>> @@ -148,7 +148,6 @@
>>
>> metadata = {
>> 'target.hostname': self.target,
>> - 'target.device_version': self.context.get_device_version(),
>> }
>>
>> if 'device_type' in self.job_data:
>> @@ -232,6 +231,7 @@
>> self.context.test_data.job_status = 'fail'
>> raise
>> finally:
>> + self.context.test_data.add_metadata({ 'target.device_version': self.context.get_device_version() or 'error'})
>
> Is the get_device_version sufficiently exception-safe? ie - the 3 lines
> of code after this are important or the lava-results won't get submitted
> properly. I'm not the best at proper error handling, maybe Michael can
> speculate.

It looks ok to me, but the part that concerns me is the point at which
it is called -- get_device_version will only work usefully if the board
is in the master image, but I don't think its guaranteed to be at this
point. I would rather have the target squirrel the device version away
the first time the device boots into the master image, if that's
possible.

CHeers,
mwh

> Also - this wraps way past column 80 and is going to make
> pylint/pflakes/etc complain.
>
>> if submit_results:
>> params = submit_results.get('parameters', {})
>> action = lava_commands[submit_results['command']](
>
>
> --
> https://code.launchpad.net/~terceiro/lava-dispatcher/master-device-version/+merge/138463
> You are subscribed to branch lp:lava-dispatcher.

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

On 12/06/2012 04:58 PM, Michael Hudson-Doyle wrote:
> It looks ok to me, but the part that concerns me is the point at which
> it is called -- get_device_version will only work usefully if the board
> is in the master image, but I don't think its guaranteed to be at this
> point. I would rather have the target squirrel the device version away
> the first time the device boots into the master image, if that's
> possible.

Read again - I thought the same thing the first time I read the code. It
actually sets this the first time it boots to master and is safe to call
from any context afterwards.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Andy Doan <email address hidden> writes:

> On 12/06/2012 04:58 PM, Michael Hudson-Doyle wrote:
>> It looks ok to me, but the part that concerns me is the point at which
>> it is called -- get_device_version will only work usefully if the board
>> is in the master image, but I don't think its guaranteed to be at this
>> point. I would rather have the target squirrel the device version away
>> the first time the device boots into the master image, if that's
>> possible.
>
> Read again - I thought the same thing the first time I read the code. It
> actually sets this the first time it boots to master and is safe to call
> from any context afterwards.

Ah quite right. +1 to merge.

Cheers,
mwh

481. By Antonio Terceiro

reformat long line

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lava_dispatcher/device/master.py'
--- lava_dispatcher/device/master.py 2012-12-05 19:10:40 +0000
+++ lava_dispatcher/device/master.py 2012-12-07 20:01:22 +0000
@@ -81,6 +81,7 @@
81 }81 }
8282
83 self.master_ip = None83 self.master_ip = None
84 self.device_version = None
8485
85 if config.pre_connect_command:86 if config.pre_connect_command:
86 logging_system(config.pre_connect_command)87 logging_system(config.pre_connect_command)
@@ -88,6 +89,9 @@
88 self.proc = self._connect_carefully(config.connection_command)89 self.proc = self._connect_carefully(config.connection_command)
89 atexit.register(self._close_logging_spawn)90 atexit.register(self._close_logging_spawn)
9091
92 def get_device_version(self):
93 return self.device_version
94
91 def power_on(self):95 def power_on(self):
92 self._boot_linaro_image()96 self._boot_linaro_image()
93 return self.proc97 return self.proc
@@ -400,6 +404,7 @@
400 runner = MasterCommandRunner(self)404 runner = MasterCommandRunner(self)
401 try:405 try:
402 self.master_ip = runner.get_master_ip()406 self.master_ip = runner.get_master_ip()
407 self.device_version = runner.get_device_version()
403 except NetworkError as e:408 except NetworkError as e:
404 msg = "Failed to get network up: " % e409 msg = "Failed to get network up: " % e
405 logging.warning(msg)410 logging.warning(msg)
@@ -518,6 +523,27 @@
518 logging.debug("Master image IP is %s" % ip)523 logging.debug("Master image IP is %s" % ip)
519 return ip524 return ip
520525
526 def get_device_version(self):
527 pattern = 'device_version=(\d+-\d+/\d+-\d+)'
528 self.run("echo \"device_version="
529 "$(lava-master-image-info --master-image-hwpack "
530 "| sed 's/[^0-9-]//g; s/^-\+//')"
531 "/"
532 "$(lava-master-image-info --master-image-rootfs "
533 "| sed 's/[^0-9-]//g; s/^-\+//')"
534 "\"",
535 [pattern, pexpect.EOF, pexpect.TIMEOUT],
536 timeout = 5)
537
538 device_version = None
539 if self.match_id == 0:
540 device_version = self.match.group(1)
541 logging.debug('Master image version (hwpack/rootfs) is %s' % device_version)
542 else:
543 logging.warning('Could not determine image version!')
544
545 return device_version
546
521 def has_partition_with_label(self, label):547 def has_partition_with_label(self, label):
522 if not label:548 if not label:
523 return False549 return False
524550
=== modified file 'lava_dispatcher/job.py'
--- lava_dispatcher/job.py 2012-11-24 20:58:07 +0000
+++ lava_dispatcher/job.py 2012-12-07 20:01:22 +0000
@@ -148,7 +148,6 @@
148148
149 metadata = {149 metadata = {
150 'target.hostname': self.target,150 'target.hostname': self.target,
151 'target.device_version': self.context.get_device_version(),
152 }151 }
153152
154 if 'device_type' in self.job_data:153 if 'device_type' in self.job_data:
@@ -232,6 +231,10 @@
232 self.context.test_data.job_status = 'fail'231 self.context.test_data.job_status = 'fail'
233 raise232 raise
234 finally:233 finally:
234 device_version = self.context.get_device_version() or 'error'
235 self.context.test_data.add_metadata({
236 'target.device_version': device_version
237 })
235 if submit_results:238 if submit_results:
236 params = submit_results.get('parameters', {})239 params = submit_results.get('parameters', {})
237 action = lava_commands[submit_results['command']](240 action = lava_commands[submit_results['command']](

Subscribers

People subscribed via source and target branches