Browse Source

Add new patch metadata to block apply in upgrade

This commit introduces a new patch metadata tag to indicate that the
patch cannot be applied in an upgrade, that it can only be applied
when the running release matches the patch.

Story: 2006590
Task: 36890
Change-Id: I1b64e254e12c54695ca3691cfb7e446866089707
Signed-off-by: Don Penney <don.penney@windriver.com>
changes/73/686473/2
Don Penney 3 years ago
parent
commit
5153ec7f92
  1. 4
      cgcs-patch/cgcs-patch/cgcs_patch/patch_client.py
  2. 13
      cgcs-patch/cgcs-patch/cgcs_patch/patch_controller.py
  3. 18
      cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py

4
cgcs-patch/cgcs-patch/cgcs_patch/patch_client.py

@ -324,6 +324,10 @@ def print_patch_show_result(req):
print(textwrap.fill(" {0:<15} ".format("RR:") + pd[patch_id]["reboot_required"],
width=TERM_WIDTH, subsequent_indent=' ' * 20))
if "apply_active_release_only" in pd[patch_id] and pd[patch_id]["apply_active_release_only"] != "":
print(textwrap.fill(" {0:<15} ".format("Apply Active Release Only:") + pd[patch_id]["apply_active_release_only"],
width=TERM_WIDTH, subsequent_indent=' ' * 20))
if "summary" in pd[patch_id] and pd[patch_id]["summary"] != "":
print(textwrap.fill(" {0:<15} ".format("Summary:") + pd[patch_id]["summary"],
width=TERM_WIDTH, subsequent_indent=' ' * 20))

13
cgcs-patch/cgcs-patch/cgcs_patch/patch_controller.py

@ -1074,6 +1074,19 @@ class PatchController(PatchService):
if not id_verification:
return dict(info=msg_info, warning=msg_warning, error=msg_error)
# Check for patches that can't be applied during an upgrade
upgrade_check = True
for patch_id in patch_list:
if self.patch_data.metadata[patch_id]["sw_version"] != SW_VERSION \
and self.patch_data.metadata[patch_id].get("apply_active_release_only") == "Y":
msg = "%s cannot be applied in an upgrade" % patch_id
LOG.error(msg)
msg_error += msg + "\n"
upgrade_check = False
if not upgrade_check:
return dict(info=msg_info, warning=msg_warning, error=msg_error)
# Next, check the patch dependencies
# required_patches will map the required patch to the patches that need it
required_patches = {}

18
cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py

@ -485,7 +485,8 @@ class PatchData(object):
"summary",
"description",
"install_instructions",
"warnings"]:
"warnings",
"apply_active_release_only"]:
value = root.findtext(key)
if value is not None:
self.metadata[patch_id][key] = value
@ -659,6 +660,7 @@ class PatchMetadata(object):
self.status = None
self.unremovable = None
self.reboot_required = None
self.apply_active_release_only = None
self.requires = []
self.groups = {}
self.contents = {}
@ -724,6 +726,8 @@ class PatchMetadata(object):
self.unremovable)
add_text_tag_to_xml(top, 'reboot_required',
self.reboot_required)
add_text_tag_to_xml(top, 'apply_active_release_only',
self.apply_active_release_only)
for groupname in sorted(self.groups.keys()):
if self.groups[groupname]:
@ -1038,7 +1042,7 @@ class PatchFile(object):
if field is None:
for f in ["status", "sw_version", "unremovable", "summary",
"description", "install_instructions",
"warnings", "reboot_required"]:
"warnings", "reboot_required", "apply_active_release_only"]:
r[f] = thispatch.query_line(patch_id, f)
else:
if field not in ['id', 'cert']:
@ -1267,7 +1271,8 @@ def patch_build():
'storage=',
'all-nodes=',
'pre-apply=',
'pre-remove='])
'pre-remove=',
'apply-active-release-only'])
except getopt.GetoptError:
print("Usage: %s [ <args> ] ... <rpm list>"
% os.path.basename(sys.argv[0]))
@ -1289,6 +1294,11 @@ def patch_build():
print("\t--controller-worker <rpm> New package for combined node")
print("\t--controller-worker-lowlatency <rpm> New package for lowlatency combined node")
print("\t--all-nodes <rpm> New package for all node types")
print("\t--pre-apply <script> Add pre-apply semantic check")
print("\t--pre-remove <script> Add pre-remove semantic check")
print("\t--apply-active-release-only Patch can only be applied if corresponding")
print("\t release is active")
exit(1)
pf = PatchFile()
@ -1339,6 +1349,8 @@ def patch_build():
pf.add_semantic(constants.SEMANTIC_PREAPPLY, arg)
elif opt == "--pre-remove":
pf.add_semantic(constants.SEMANTIC_PREREMOVE, arg)
elif opt == "--apply-active-release-only":
pf.meta.apply_active_release_only = "Y"
if pf.meta.id is None:
print("The --id argument is mandatory.")

Loading…
Cancel
Save