Check before deleting old deployments
When the Software Agent starts, it lists all ostree deployments, and deletes all with an index greater than 2 in the list. But it does not check the list size before trying to delete, leading in some cases to an out-of-range exception. This commit adds a check before iterating through the list to delete. Test-Plan: PASS: Deploy an ISO and check no out-of-range error after unlock PASS: Deploy an RR patch and see only two deployments after unlock Story: 2010676 Task: 51069 Change-Id: I2555597fac30677bcb36629a2ea66feb52a40de1 Signed-off-by: Lindley Vieira <lindley.vieira@windriver.com>
This commit is contained in:
parent
2db18a6212
commit
000050b151
@ -445,8 +445,12 @@ def delete_older_deployments():
|
|||||||
# We want to delete all deployments except the two mentioned above.
|
# We want to delete all deployments except the two mentioned above.
|
||||||
# This means we will undeploy all deployments starting from the
|
# This means we will undeploy all deployments starting from the
|
||||||
# 2nd index of deployment_id_list
|
# 2nd index of deployment_id_list
|
||||||
|
deploys_amount = len(deployment_id_list)
|
||||||
|
if deploys_amount <= 2:
|
||||||
|
LOG.info("No older deployments to delete")
|
||||||
|
return
|
||||||
|
|
||||||
for index in reversed(range(2, len(deployment_id_list))):
|
for index in reversed(range(2, deploys_amount)):
|
||||||
try:
|
try:
|
||||||
cmd = "ostree admin undeploy %s" % index
|
cmd = "ostree admin undeploy %s" % index
|
||||||
output = subprocess.run(cmd, shell=True, check=True, capture_output=True)
|
output = subprocess.run(cmd, shell=True, check=True, capture_output=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user