Merge lp:~vila/uci-engine/1295324-testbed-unreachable into lp:uci-engine

Proposed by Vincent Ladeuil
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: 420
Merged at revision: 420
Proposed branch: lp:~vila/uci-engine/1295324-testbed-unreachable
Merge into: lp:uci-engine
Diff against target: 72 lines (+20/-6)
1 file modified
test_runner/tstrun/testbed.py (+20/-6)
To merge this branch: bzr merge lp:~vila/uci-engine/1295324-testbed-unreachable
Reviewer Review Type Date Requested Status
Andy Doan (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+213634@code.launchpad.net

Commit message

Handle testbed disappearing when getting files out of it.

Description of the change

Fix the rare case where the testbed can't be reached even when it's up.

To test, I simulated the case by killing the nova instance after it has been
setup and the tests run there.

As a drive-by, I also fixed the case where an HTTP 413 Rate limiting
exception was breaking the testbed monitoring.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

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

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

review: Approve (continuous-integration)
Revision history for this message
Andy Doan (doanac) wrote :

40 + time.sleep(30)
41 + log.exception('Rate limit while acquiring nova console'
42 + ' for {}'.format(self.instance.id))

nothing huge, but putting the log message before the time.sleep might make tailing the logfile more friendly.

Revision history for this message
Vincent Ladeuil (vila) wrote :

/me facepalms

Thanks for the catch, fixed ;)

420. By Vincent Ladeuil

Sleep after logging the exception makes tailing the log more friendly (Andy).

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

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

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

review: Approve (continuous-integration)
Revision history for this message
Andy Doan (doanac) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'test_runner/tstrun/testbed.py'
--- test_runner/tstrun/testbed.py 2014-03-17 20:49:20 +0000
+++ test_runner/tstrun/testbed.py 2014-04-01 17:30:56 +0000
@@ -31,7 +31,7 @@
31log = logging.getLogger(__name__)31log = logging.getLogger(__name__)
3232
3333
34class NovaClientException(Exception):34class TestBedException(Exception):
35 pass35 pass
3636
3737
@@ -179,7 +179,7 @@
179 pass179 pass
180 # MISSINGTEST: some cloud doesn't provide one of our expected flavors180 # MISSINGTEST: some cloud doesn't provide one of our expected flavors
181 # -- vila 2014-01-06181 # -- vila 2014-01-06
182 raise NovaClientException(182 raise TestBedException(
183 'None of {} can be found'.format(self.flavors))183 'None of {} can be found'.format(self.flavors))
184184
185 def setup(self):185 def setup(self):
@@ -235,9 +235,9 @@
235 time.sleep(5)235 time.sleep(5)
236 # MISSINGTEST: What if the instance doesn't come up after max_tries ?236 # MISSINGTEST: What if the instance doesn't come up after max_tries ?
237 if status == 'BUILD':237 if status == 'BUILD':
238 raise NovaClientException('Instance never came up')238 raise TestBedException('Instance never came up')
239 else:239 else:
240 raise NovaClientException('Instance never provided an IP')240 raise TestBedException('Instance never provided an IP')
241241
242 def get_cloud_init_console(self, length=None):242 def get_cloud_init_console(self, length=None):
243 return self.instance.get_console_output(length)243 return self.instance.get_console_output(length)
@@ -252,6 +252,15 @@
252 # the console for the specific message we specified in user-data).252 # the console for the specific message we specified in user-data).
253 try:253 try:
254 console = self.get_cloud_init_console(10)254 console = self.get_cloud_init_console(10)
255 except exceptions.OverLimit:
256 # This happens rarely but breaks badly if not caught. elmo
257 # recommended a 30 seconds nap in that case.
258 nap_time = 30
259 msg = ('Rate limit while acquiring nova console for {},'
260 ' will sleep for {} seconds')
261 log.exception(msg.format(self.instance.id, nap_time))
262 time.sleep(nap_time)
263 continue
255 except requests.ConnectionError:264 except requests.ConnectionError:
256 # The reported status is the one known before the last attempt.265 # The reported status is the one known before the last attempt.
257 log.warn('Received connection error for {},'266 log.warn('Received connection error for {},'
@@ -264,7 +273,7 @@
264 'cloud-init completed for {}'.format(self.instance.id))273 'cloud-init completed for {}'.format(self.instance.id))
265 return274 return
266 time.sleep(5)275 time.sleep(5)
267 raise NovaClientException('Instance never completed cloud-init')276 raise TestBedException('Instance never completed cloud-init')
268277
269 def teardown(self):278 def teardown(self):
270 self.nova.servers.delete(self.instance.id)279 self.nova.servers.delete(self.instance.id)
@@ -294,7 +303,12 @@
294 return proc, out, err303 return proc, out, err
295304
296 def get_remote_content(self, path):305 def get_remote_content(self, path):
297 _, content, _ = self.ssh('cat', path, out=subprocess.PIPE)306 proc, content, err = self.ssh('cat', path, out=subprocess.PIPE,
307 err=subprocess.PIPE)
308 if proc.returncode:
309 # We didn't get a proper content, report it instead
310 content = ("{} couldn't be copied from testbed {}:\n"
311 "error: {}\n".format(path, self.ip, err))
298 return content312 return content
299313
300 def run_test(self, package):314 def run_test(self, package):

Subscribers

People subscribed via source and target branches