Skip to content

Commit dc92a90

Browse files
author
Simon Rowe
committed
CA-263587: extract error content from precheck script
When the precheck script is called directly the output will contain an XML document on failure. Process it in the same manner as when it fails during installation of the control package. Signed-off-by: Simon Rowe <[email protected]>
1 parent 8f9a596 commit dc92a90

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

scripts/extensions/pool_update.precheck

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,18 @@ def execute_precheck(session, control_package, yum_conf_file, update_precheck_fi
184184
raise PrecheckFailure(output)
185185

186186
if os.path.isfile(update_precheck_file):
187-
pp = subprocess.Popen(update_precheck_file, shell=False, stdout=subprocess.PIPE, close_fds=True)
187+
pp = subprocess.Popen(update_precheck_file, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
188188
precheck_output, _ = pp.communicate()
189189
xcp.logger.info('pool_update.precheck %r precheck_output=%r', update_precheck_file, precheck_output)
190190
if pp.returncode != 0:
191+
regex = ERROR_XML_START + '.+' + ERROR_XML_END
192+
m = re.search(regex, precheck_output, flags=re.DOTALL)
193+
if m:
194+
try:
195+
xmldoc = xml.dom.minidom.parseString(m.group(0))
196+
except:
197+
raise PrecheckFailure(precheck_output)
198+
parse_precheck_failure(xmldoc)
191199
raise PrecheckFailure(precheck_output)
192200
else:
193201
if '\n' in precheck_output:

0 commit comments

Comments
 (0)