Merge lp:~javier.collado/utah/bug1035227 into lp:utah

Proposed by Javier Collado
Status: Merged
Merged at revision: 633
Proposed branch: lp:~javier.collado/utah/bug1035227
Merge into: lp:utah
Diff against target: 47 lines (+19/-0) (has conflicts)
2 files modified
utah/provisioning/provisioning.py (+4/-0)
utah/run.py (+15/-0)
Text conflict in utah/run.py
To merge this branch: bzr merge lp:~javier.collado/utah/bug1035227
Reviewer Review Type Date Requested Status
Max Brustkern (community) Approve
Javier Collado (community) Needs Resubmitting
Review via email: mp+119327@code.launchpad.net

Description of the change

When an ssh command returns a failure code, it's logged as a warning (we might want to ignore it). However, when the client fails, then an error message is printed to sys.stderr and run_utah_tests.py exits. If we decide to ignore some client return codes and continue for some other return codes, this can be easily updated though.

Example output:
INFO: Running command through SSH: doesnotexist -r /tmp/master.run -o /var/log/utah/utah-36-quantal-amd64_master.run_tmp
WARNING: Return code: 127
utah failed with return code: 127
INFO: Running command through SSH: rm -f /var/log/utah/utah-36-quantal-amd64_master.run_tmp
utah@xps8300:/home/javi/code/bzr/utah/bug1035227$ PYTHONPATH=. examples/run_utah_tests.py utah/client/examples/master.run --image

Note that the error message isn't the last one printed to the console because the 'rm' command is executed later in a finally clause.

To post a comment you must log in.
Revision history for this message
Max Brustkern (nuclearbob) wrote :

I think I'd like to get that error into a log rather than just using sys.stderr.print. How about using machine.logger.error for that? I think this is definitely a good change either way, since it'll provide more useful error info. If you agree with changing the logging method, you can either change the branch, or just let me know and I'll make the change when I do the merge.

review: Needs Information
lp:~javier.collado/utah/bug1035227 updated
625. By Javier Collado

Replaced sys.stderr.write with machine.logger.error

Revision history for this message
Javier Collado (javier.collado) wrote :

Applied changes as suggested by the review comment.

review: Needs Resubmitting
Revision history for this message
Javier Collado (javier.collado) wrote :

I'm completely fine with using machine.logger, so that those error messages are also available in the log file. However, I think the code isn't consistent and it uses "print" statements when it could use "machine.logger" for example in utah/run.

What do you think about updating them in a separate merge?

Revision history for this message
Javier Collado (javier.collado) wrote :

I've created a merge proposal with a few changes to use "machine.logger" where I think it makes sense:
https://code.launchpad.net/~javier.collado/utah/use_machine_logger/+merge/119479

Revision history for this message
Max Brustkern (nuclearbob) wrote :

All right, I'll take a look at that. Some of the print statements are used to let something monitoring the output know which files it needs to downloads, but it probably makes sense to change other ones.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utah/provisioning/provisioning.py'
2--- utah/provisioning/provisioning.py 2012-08-13 21:14:04 +0000
3+++ utah/provisioning/provisioning.py 2012-08-14 07:15:22 +0000
4@@ -471,6 +471,10 @@
5 retval = channel.recv_exit_status()
6 self.logger.debug('Closing SSH connection')
7 self.ssh_client.close()
8+ if retval == 0:
9+ self.logger.debug('Return code: {}'.format(retval))
10+ else:
11+ self.logger.warning('Return code: {}'.format(retval))
12 self.logger.debug('Standard output follows:')
13 for line in stdout:
14 self.logger.debug(line.strip())
15
16=== modified file 'utah/run.py'
17--- utah/run.py 2012-08-13 20:37:09 +0000
18+++ utah/run.py 2012-08-14 07:15:22 +0000
19@@ -42,6 +42,7 @@
20 machine.uploadfiles([locallist], os.path.normpath('/tmp'))
21 options = (' -r /tmp/' + os.path.basename(locallist)
22 + ' -o ' + remotelog)
23+<<<<<<< TREE
24 try:
25 machine.run('utah' + extraopts + options, root=True)
26 except UTAHException as error:
27@@ -56,6 +57,20 @@
28 else:
29 print('Test log copied to ' + locallog)
30 locallogs.append(locallog)
31+=======
32+ returncode = machine.run('utah' + extraopts + options, root=True)
33+ if returncode != 0:
34+ machine.logger.error('utah failed with return code: {}\n'
35+ .format(returncode))
36+ exitstatus = 1
37+ break
38+ machine.downloadfiles([remotelog], locallog)
39+ print('Test log copied to ' + locallog)
40+ locallogs.append(locallog)
41+ except UTAHException as error:
42+ print('Failed to run test: ' + str(error))
43+ exitstatus = 1
44+>>>>>>> MERGE-SOURCE
45 finally:
46 try:
47 machine.run('rm -f ' + remotelog)

Subscribers

People subscribed via source and target branches