Skip to content

Commit e0f64bf

Browse files
committed
CA-228756: Provide more error details for precheck and apply.
Catch the unexpected failure and return detailed error message. Signed-off-by: Hui Zhang <[email protected]>
1 parent 13a2dc0 commit e0f64bf

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

scripts/extensions/pool_update.apply

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ def execute_apply(session, update_package, yum_conf_file):
5858
if m:
5959
errmsg = m.group()
6060
errmsg = re.sub(ERROR_MESSAGE_END + '.+', '', errmsg, flags=re.DOTALL)
61-
errmsg = re.sub('\n +', ' ', errmsg, flags=re.DOTALL)
6261
raise ApplyFailure(errmsg)
6362
else:
64-
raise ApplyFailure()
63+
raise ApplyFailure(output)
6564

6665

6766
if __name__ == '__main__':

scripts/extensions/pool_update.precheck

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ def execute_precheck(session, control_package, yum_conf_file, update_precheck_fi
9696
if m:
9797
errmsg = m.group()
9898
errmsg = re.sub(ERROR_MESSAGE_END + '.+', '', errmsg, flags=re.DOTALL)
99-
precheckfailure_msg = re.sub('\n +', ' ', errmsg, flags=re.DOTALL)
10099
if ERROR_MESSAGE_CONFLICTS_WITH in errmsg and ERROR_MESSAGE_PROCESSING_CONFLICT in output:
101100
regex = ERROR_MESSAGE_PROCESSING_CONFLICT + '(.*)' + ERROR_MESSAGE_CONFLICTS + UPDATE_PREFIX + '(.+?)\n'
102101
conflict_tuples = re.findall(regex, output)
@@ -106,7 +105,7 @@ def execute_precheck(session, control_package, yum_conf_file, update_precheck_fi
106105
conflict_updates += tuple[1] + ' '
107106
raise ConflictPresent(conflict_updates.rstrip())
108107
else:
109-
raise PrecheckFailure(precheckfailure_msg)
108+
raise PrecheckFailure(errmsg)
110109
elif ERROR_MESSAGE_VERSION_REQUIRED in errmsg and ERROR_MESSAGE_VERSION_INSTALLED in errmsg:
111110
regex = ERROR_MESSAGE_VERSION_REQUIRED + '(.+?)\n.+ {2,2}(.+)$'
112111
match = re.search(regex, errmsg, flags=re.DOTALL)
@@ -115,7 +114,7 @@ def execute_precheck(session, control_package, yum_conf_file, update_precheck_fi
115114
installed_version = match.group(2).rstrip()
116115
raise WrongServerVersion(required_version, installed_version)
117116
else:
118-
raise PrecheckFailure(precheckfailure_msg)
117+
raise PrecheckFailure(errmsg)
119118
elif ERROR_MESSAGE_PREREQUISITE in errmsg:
120119
regex = ERROR_MESSAGE_PREREQUISITE + UPDATE_PREFIX + '(.+?)\n'
121120
prerequisite_list = re.findall(regex, errmsg)
@@ -125,22 +124,24 @@ def execute_precheck(session, control_package, yum_conf_file, update_precheck_fi
125124
prerequisite_updates += prerequisite + ' '
126125
raise PrerequisiteMissing(prerequisite_updates.rstrip())
127126
else:
128-
raise PrecheckFailure(precheckfailure_msg)
127+
raise PrecheckFailure(errmsg)
129128
else:
130-
raise PrecheckFailure(precheckfailure_msg)
129+
raise PrecheckFailure(errmsg)
131130
else:
132-
raise PrecheckFailure()
133-
else:
134-
if not os.path.isfile(update_precheck_file):
135-
return 'ok'
131+
raise PrecheckFailure(output)
132+
133+
if os.path.isfile(update_precheck_file):
134+
pp = subprocess.Popen(update_precheck_file, shell=False, stdout=subprocess.PIPE, close_fds=True)
135+
precheck_output, _ = pp.communicate()
136+
xcp.logger.info('pool_update.precheck %r precheck_output=%r', update_precheck_file, precheck_output)
137+
if pp.returncode != 0:
138+
raise PrecheckFailure(precheck_output)
136139
else:
137-
pp = subprocess.Popen(update_precheck_file, shell=False, stdout=subprocess.PIPE, close_fds=True)
138-
precheck_output, _ = pp.communicate()
139-
xcp.logger.info('pool_update.precheck %r precheck_output=%r', update_precheck_file, precheck_output)
140-
for msg in livepatch_messages.keys():
141-
if msg in precheck_output:
140+
if '\n' in precheck_output:
141+
msg = precheck_output.split()[0]
142+
if msg in livepatch_messages.keys():
142143
return livepatch_messages[msg]
143-
raise PrecheckFailure()
144+
return 'ok'
144145

145146

146147
if __name__ == '__main__':

0 commit comments

Comments
 (0)