修复超过5个部署之后部署丢失的问题
This commit is contained in:
parent
451e47ee1c
commit
161e2a07a9
|
@ -281,32 +281,30 @@ class DeployBackend(BackendBaseOstree):
|
|||
self._progress_to_plymouth(60)
|
||||
|
||||
logging.info("start deploy available_refs:%s new_revision:%s...",refs,new_revision)
|
||||
ret,new_deployment = sysroot.deploy_tree(self.osname,new_revision,self.origin,self.merge_deployment,None,None)
|
||||
ret,upgrade_deployment = sysroot.deploy_tree(self.osname,new_revision,self.origin,self.merge_deployment,None,None)
|
||||
|
||||
# 进行部署时 保留历史部署
|
||||
flags = OSTree.SysrootSimpleWriteDeploymentFlags.RETAIN
|
||||
sysroot.simple_write_deployment(self.osname,new_deployment,self.merge_deployment,flags,None)
|
||||
sysroot.simple_write_deployment(self.osname,upgrade_deployment,self.merge_deployment,flags,None)
|
||||
|
||||
self._progress_to_plymouth(90)
|
||||
|
||||
# 获取当前部署 数量
|
||||
cur_deployment = []
|
||||
cur_deployment.append(new_deployment)
|
||||
special_deployment = []
|
||||
has_deployment = []
|
||||
old_deployments = sysroot.get_deployments()
|
||||
|
||||
# 部署的列表
|
||||
for deploys in old_deployments:
|
||||
# 对为hotfix和pin的部署进行过滤
|
||||
# 放hotfix和pin 部署
|
||||
if deploys.get_unlocked() == OSTree.DeploymentUnlockedState.HOTFIX and deploys.is_pinned():
|
||||
continue
|
||||
special_deployment.append(special_deployment)
|
||||
# 其他升级保存的部署
|
||||
elif not upgrade_deployment.equal(deploys):
|
||||
has_deployment.append(deploys)
|
||||
|
||||
if not new_deployment.equal(deploys):
|
||||
cur_deployment.append(deploys)
|
||||
|
||||
logging.info("Number of current deployments:%d and all:%d",len(cur_deployment),len(old_deployments))
|
||||
if len(cur_deployment) > 5:
|
||||
logging.info("Number of current deployments:%d and all:%d",len(has_deployment),len(old_deployments))
|
||||
if len(has_deployment) > 5:
|
||||
logging.info("The number of deployments exceed 5 and delete the 5 after the depoyment...")
|
||||
ret = sysroot.write_deployments(cur_deployment[:5],None)
|
||||
new_deployment = [upgrade_deployment] + special_deployment + has_deployment[:5]
|
||||
ret = sysroot.write_deployments(new_deployment,None)
|
||||
self._progress_to_plymouth(95)
|
||||
|
||||
# 健全性检查
|
||||
|
|
Loading…
Reference in New Issue