Merge lp:~lamont/maas/bug-1504863-1.8 into lp:maas/1.8

Proposed by LaMont Jones
Status: Merged
Approved by: LaMont Jones
Approved revision: no longer in the source branch.
Merged at revision: 4054
Proposed branch: lp:~lamont/maas/bug-1504863-1.8
Merge into: lp:maas/1.8
Diff against target: 48 lines (+17/-2)
1 file modified
src/provisioningserver/dhcp/leases.py (+17/-2)
To merge this branch: bzr merge lp:~lamont/maas/bug-1504863-1.8
Reviewer Review Type Date Requested Status
LaMont Jones (community) Approve
Review via email: mp+274458@code.launchpad.net

Commit message

In lease parsing, give preference to raising the child process error over the parent's error. This should help debug bug#1504863.

Description of the change

In lease parsing, give preference to raising the child process error over the parent's error. This should help debug bug#1504863.

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

Voting does not meet specified criteria. Required: Approve >= 1, Disapprove == 0. Got: 1 Pending.

Revision history for this message
LaMont Jones (lamont) wrote :

trivial backport

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/provisioningserver/dhcp/leases.py'
2--- src/provisioningserver/dhcp/leases.py 2015-05-07 18:14:38 +0000
3+++ src/provisioningserver/dhcp/leases.py 2015-10-14 19:56:25 +0000
4@@ -33,13 +33,13 @@
5 'record_lease_state',
6 ]
7
8-
9 from collections import defaultdict
10 import errno
11 from os import (
12 fstat,
13 stat,
14 )
15+import sys
16
17 from provisioningserver.dhcp.leases_parser_fast import parse_leases
18 from provisioningserver.logger import get_maas_logger
19@@ -115,13 +115,28 @@
20 if get_leases_timestamp() == previous_leases_time:
21 return None
22
23+ exc_info = None # Keep track of exceptions in the *parent*.
24+
25 with objectfork() as (pid, recv, send):
26 if pid == 0:
27 # Child, where we'll do the parsing.
28 send(parse_leases_file())
29 else:
30 # Parent, where we'll receive the results.
31- parse_result = recv()
32+ try:
33+ parse_result = recv()
34+ except:
35+ # This probably means that the child has crashed, but keep
36+ # hold of this exception for later in case it is a problem
37+ # only in the parent.
38+ exc_info = sys.exc_info()
39+
40+ # On exit from the objectfork() context above the child process will be
41+ # terminated and any errors it encountered will be propagated into the
42+ # parent process; this block will not be reached. However it's possible
43+ # that the parent alone has crashed, and we propagate its error now.
44+ if exc_info is not None:
45+ raise exc_info
46
47 if parse_result is not None:
48 timestamp, leases = parse_result

Subscribers

People subscribed via source and target branches

to all changes: