Enhance way to check if host is updated
Today PatchAgent checks if the host is updated by comparing the last feed commit ID and the last sysroot commit ID, but this is not accurate, since the sysroot commit can be not applied in the node. This commit enhances this check by comparing the last feed commit ID with the last deployment commit ID (it can be pending or active). With this change, the system will be able to identify if the deployment was correctly applied. If not, it will try to reapply. Test-plan: PASS: 'deploy start' a patch and see if the nodes report the mismatch with the deployment PASS: 'deploy start' a major release and see if the nodes report the mismatch with the deployment PASS: Apply/remove a patch in a DC lab with success PASS: Apply a full major upgrade in a DX system with sucess Story: 2010676 Task: 51322 Change-Id: I4658092da8a34d63cea6413981ce9f06aa0c0c16 Signed-off-by: Lindley Vieira <lindley.vieira@windriver.com>
This commit is contained in:
@@ -194,11 +194,11 @@ def get_all_feed_commits(patch_sw_version):
|
||||
|
||||
def get_latest_deployment_commit():
|
||||
"""
|
||||
Get the active deployment commit ID
|
||||
:return: The commit ID associated with the active commit
|
||||
Get the latest deployment commit ID (pending or active)
|
||||
:return: The commit ID associated with the latest commit or None
|
||||
"""
|
||||
|
||||
# Sample command and output that is parsed to get the active commit
|
||||
# Sample command and output that is parsed to get the latest commit
|
||||
# associated with the deployment
|
||||
#
|
||||
# Command: ostree admin status
|
||||
@@ -208,7 +208,6 @@ def get_latest_deployment_commit():
|
||||
# debian 0658a62854647b89caf5c0e9ed6ff62a6c98363ada13701d0395991569248d7e.0 (pending)
|
||||
# origin refspec: starlingx
|
||||
# * debian a5d8f8ca9bbafa85161083e9ca2259ff21e5392b7595a67f3bc7e7ab8cb583d9.0
|
||||
# Unlocked: hotfix
|
||||
# origin refspec: starlingx
|
||||
|
||||
cmd = "ostree admin status"
|
||||
@@ -225,12 +224,10 @@ def get_latest_deployment_commit():
|
||||
# Store the output of the above command in a string
|
||||
output_string = output.stdout.decode('utf-8')
|
||||
|
||||
# Parse the string to get the active commit on this deployment
|
||||
# Trim everything before * as * represents the active deployment commit
|
||||
trimmed_output_string = output_string[output_string.index("*"):]
|
||||
split_output_string = trimmed_output_string.split()
|
||||
active_deployment_commit = split_output_string[2]
|
||||
return active_deployment_commit
|
||||
match = re.search(r'\b(\w+)\.\d+\b', output_string)
|
||||
if match:
|
||||
return match.group(1)
|
||||
return None
|
||||
|
||||
|
||||
def update_repo_summary_file(repo_path):
|
||||
|
@@ -554,6 +554,16 @@ class PatchAgent(PatchService):
|
||||
active_sysroot_commit, self.latest_feed_commit)
|
||||
self.changes = True
|
||||
|
||||
latest_deployment_commit = ostree_utils.get_latest_deployment_commit()
|
||||
if latest_deployment_commit:
|
||||
if latest_deployment_commit != self.latest_feed_commit:
|
||||
LOG.info("Latest deployment Commit:%s does not match "
|
||||
"active controller's Feed Repo Commit: %s",
|
||||
latest_deployment_commit, self.latest_feed_commit)
|
||||
self.changes = True
|
||||
else:
|
||||
self.changes = False
|
||||
|
||||
return True
|
||||
|
||||
def handle_install(self,
|
||||
|
Reference in New Issue
Block a user