self.db.set_one(self.db_collection, {"_id": item_id}, db_item)
def update_operation_history(
- self, content, workflow_status=None, resource_status=None
+ self, content, op_id, workflow_status=None, resource_status=None
):
self.logger.info(
f"Update Operation History in DB. Workflow status: {workflow_status}. Resource status: {resource_status}"
)
self.logger.debug(f"Content: {content}")
- op_id = content["current_operation"]
- self.logger.debug("OP_id: {}".format(op_id))
op_num = 0
for operation in content["operationHistory"]:
self.logger.debug("Operations: {}".format(operation))
return content
- async def common_check_list(self, checkings_list, db_collection, db_item):
+ async def common_check_list(self, op_id, checkings_list, db_collection, db_item):
try:
for checking in checkings_list:
if checking["enable"]:
else:
db_item["resourceState"] = checking["resourceState"]
db_item = self.update_operation_history(
- db_item, "COMPLETED", checking["resourceState"]
+ db_item, op_id, "COMPLETED", checking["resourceState"]
)
self.db.set_one(db_collection, {"_id": db_item["_id"]}, db_item)
except Exception as e:
db_cluster["state"] = "FAILED_CREATION"
db_cluster["resourceState"] = "ERROR"
# has to call update_operation_history return content
- db_cluster = self.update_operation_history(db_cluster, workflow_status, None)
+ db_cluster = self.update_operation_history(
+ db_cluster, op_id, workflow_status, None
+ )
self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
# Clean items used in the workflow, no matter if the workflow succeeded
db_cluster["operatingState"] = "IDLE"
db_cluster = self.update_operation_history(
- db_cluster, workflow_status, resource_status
+ db_cluster, op_id, workflow_status, resource_status
)
db_cluster["current_operation"] = None
self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
"name": cluster_kustomization_name,
"namespace": "managed-resources",
"flag": "Ready",
- "timeout": self._checkloop_kustomization_timeout,
+ "timeout": 1500,
"enable": True,
"resourceState": "IN_PROGRESS.KUSTOMIZATION_READY",
},
"name": f"{cluster_kustomization_name}-bstrp-fluxctrl",
"namespace": "managed-resources",
"flag": "Ready",
- "timeout": self._checkloop_kustomization_timeout,
+ "timeout": self._checkloop_resource_timeout,
"enable": bootstrap,
"resourceState": "IN_PROGRESS.BOOTSTRAP_OK",
},
"resourceState": "IN_PROGRESS.RESOURCE_READY.NODEPOOL",
}
checkings_list.insert(3, nodepool_check)
- return await self.common_check_list(checkings_list, "clusters", db_cluster)
+ return await self.common_check_list(
+ op_id, checkings_list, "clusters", db_cluster
+ )
async def check_register_cluster(self, op_id, op_params, content):
self.logger.info(
"resourceState": "IN_PROGRESS.BOOTSTRAP_OK",
},
]
- return await self.common_check_list(checkings_list, "clusters", db_cluster)
+ return await self.common_check_list(
+ op_id, checkings_list, "clusters", db_cluster
+ )
async def check_update_cluster(self, op_id, op_params, content):
self.logger.info(
"resourceState": "IN_PROGRESS.RESOURCE_READY.NODEPOOL",
}
checkings_list.append(nodepool_check)
- return await self.common_check_list(checkings_list, "clusters", db_cluster)
+ return await self.common_check_list(
+ op_id, checkings_list, "clusters", db_cluster
+ )
def update_profile_state(self, db_cluster, workflow_status, resource_status):
profiles = [
self.logger.info("the db_collection is :{}".format(db_collection))
db_profile = self.db.get_one(db_collection, {"_id": profile_id})
self.logger.info("the db_profile is :{}".format(db_profile))
+ op_id = db_profile["operationHistory"][-1].get("op_id")
db_profile["state"] = db_cluster["state"]
db_profile["resourceState"] = db_cluster["resourceState"]
db_profile["operatingState"] = db_cluster["operatingState"]
db_profile["age_pubkey"] = db_cluster["age_pubkey"]
db_profile["age_privkey"] = db_profile["age_privkey"]
db_profile = self.update_operation_history(
- db_profile, workflow_status, resource_status
+ db_profile, op_id, workflow_status, resource_status
)
self.logger.info("the db_profile is :{}".format(db_profile))
self.db.set_one(db_collection, {"_id": db_profile["_id"]}, db_profile)
db_cluster["state"] = "FAILED_DELETION"
db_cluster["resourceState"] = "ERROR"
# has to call update_operation_history return content
- db_cluster = self.update_operation_history(db_cluster, workflow_status, None)
+ db_cluster = self.update_operation_history(
+ db_cluster, op_id, workflow_status, None
+ )
self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
if workflow_status:
db_cluster["operatingState"] = "IDLE"
db_cluster = self.update_operation_history(
- db_cluster, workflow_status, resource_status
+ db_cluster, op_id, workflow_status, resource_status
)
db_cluster["current_operation"] = None
self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
else:
db_cluster["resourceState"] = "ERROR"
# has to call update_operation_history return content
- db_cluster = self.update_operation_history(db_cluster, workflow_status, None)
+ db_cluster = self.update_operation_history(
+ db_cluster, op_id, workflow_status, None
+ )
self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
if workflow_status:
db_cluster["operatingState"] = "IDLE"
db_cluster = self.update_operation_history(
- db_cluster, workflow_status, resource_status
+ db_cluster, op_id, workflow_status, resource_status
)
profile_list = db_cluster[profile_type]
self.logger.info("profile list is : {}".format(profile_list))
else:
db_cluster["resourceState"] = "ERROR"
# has to call update_operation_history return content
- db_cluster = self.update_operation_history(db_cluster, workflow_status, None)
+ db_cluster = self.update_operation_history(
+ db_cluster, op_id, workflow_status, None
+ )
self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
if workflow_status:
db_cluster["operatingState"] = "IDLE"
db_cluster = self.update_operation_history(
- db_cluster, workflow_status, resource_status
+ db_cluster, op_id, workflow_status, resource_status
)
profile_list = db_cluster[profile_type]
self.logger.info("profile list is : {}".format(profile_list))
db_cluster["state"] = "FAILED_CREATION"
db_cluster["resourceState"] = "ERROR"
# has to call update_operation_history return content
- db_cluster = self.update_operation_history(db_cluster, workflow_status, None)
+ db_cluster = self.update_operation_history(
+ db_cluster, op_id, workflow_status, None
+ )
self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
# Clean items used in the workflow, no matter if the workflow succeeded
db_cluster["operatingState"] = "IDLE"
db_cluster = self.update_operation_history(
- db_cluster, workflow_status, resource_status
+ db_cluster, op_id, workflow_status, resource_status
)
db_cluster["current_operation"] = None
self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
db_cluster["state"] = "FAILED_DELETION"
db_cluster["resourceState"] = "ERROR"
# has to call update_operation_history return content
- db_cluster = self.update_operation_history(db_cluster, workflow_status, None)
+ db_cluster = self.update_operation_history(
+ db_cluster, op_id, workflow_status, None
+ )
self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
# Clean items used in the workflow or in the cluster, no matter if the workflow succeeded
db_cluster["operatingState"] = "IDLE"
db_cluster = self.update_operation_history(
- db_cluster, workflow_status, resource_status
+ db_cluster, op_id, workflow_status, resource_status
)
db_cluster["current_operation"] = None
self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
else:
db_cluster["resourceState"] = "ERROR"
- db_cluster = self.update_operation_history(db_cluster, workflow_status, None)
+ db_cluster = self.update_operation_history(
+ db_cluster, op_id, workflow_status, None
+ )
# self.logger.info("Db content: {}".format(db_content))
# self.db.set_one(self.db_collection, {"_id": _id}, db_cluster)
self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
db_cluster["resourceState"] = "ERROR"
db_cluster = self.update_operation_history(
- db_cluster, workflow_status, resource_status
+ db_cluster, op_id, workflow_status, resource_status
)
db_cluster["operatingState"] = "IDLE"
content["state"] = "FAILED_CREATION"
content["resourceState"] = "ERROR"
# has to call update_operation_history return content
- content = self.update_operation_history(content, workflow_status, None)
+ content = self.update_operation_history(content, op_id, workflow_status, None)
self.db.set_one("k8sapp", {"_id": content["_id"]}, content)
if workflow_status:
content["operatingState"] = "IDLE"
content = self.update_operation_history(
- content, workflow_status, resource_status
+ content, op_id, workflow_status, resource_status
)
content["current_operation"] = None
self.db.set_one("k8sapp", {"_id": content["_id"]}, content)
content["state"] = "FAILED_DELETION"
content["resourceState"] = "ERROR"
# has to call update_operation_history return content
- content = self.update_operation_history(content, workflow_status, None)
+ content = self.update_operation_history(content, op_id, workflow_status, None)
self.db.set_one("k8sapp", {"_id": content["_id"]}, content)
if workflow_status:
content["operatingState"] = "IDLE"
content = self.update_operation_history(
- content, workflow_status, resource_status
+ content, op_id, workflow_status, resource_status
)
content["current_operation"] = None
self.db.set_one("k8sapp", {"_id": content["_id"]}, content)
content["state"] = "FAILED_CREATION"
content["resourceState"] = "ERROR"
# has to call update_operation_history return content
- content = self.update_operation_history(content, workflow_status, None)
+ content = self.update_operation_history(content, op_id, workflow_status, None)
self.db.set_one("k8sresource", {"_id": content["_id"]}, content)
if workflow_status:
content["operatingState"] = "IDLE"
content = self.update_operation_history(
- content, workflow_status, resource_status
+ content, op_id, workflow_status, resource_status
)
content["current_operation"] = None
self.db.set_one("k8sresource", {"_id": content["_id"]}, content)
content["state"] = "FAILED_DELETION"
content["resourceState"] = "ERROR"
# has to call update_operation_history return content
- content = self.update_operation_history(content, workflow_status, None)
+ content = self.update_operation_history(content, op_id, workflow_status, None)
self.db.set_one("k8sresource", {"_id": content["_id"]}, content)
if workflow_status:
content["operatingState"] = "IDLE"
content = self.update_operation_history(
- content, workflow_status, resource_status
+ content, op_id, workflow_status, resource_status
)
content["current_operation"] = None
self.db.set_one("k8sresource", {"_id": content["_id"]}, content)
content["state"] = "FAILED_CREATION"
content["resourceState"] = "ERROR"
# has to call update_operation_history return content
- content = self.update_operation_history(content, workflow_status, None)
+ content = self.update_operation_history(content, op_id, workflow_status, None)
self.db.set_one("k8sinfra_controller", {"_id": content["_id"]}, content)
if workflow_status:
content["operatingState"] = "IDLE"
content = self.update_operation_history(
- content, workflow_status, resource_status
+ content, op_id, workflow_status, resource_status
)
content["current_operation"] = None
self.db.set_one("k8sinfra_controller", {"_id": content["_id"]}, content)
content["state"] = "FAILED_DELETION"
content["resourceState"] = "ERROR"
# has to call update_operation_history return content
- content = self.update_operation_history(content, workflow_status, None)
+ content = self.update_operation_history(content, op_id, workflow_status, None)
self.db.set_one("k8sinfra_controller", {"_id": content["_id"]}, content)
if workflow_status:
content["operatingState"] = "IDLE"
content = self.update_operation_history(
- content, workflow_status, resource_status
+ content, op_id, workflow_status, resource_status
)
content["current_operation"] = None
self.db.set_one("k8sinfra_controller", {"_id": content["_id"]}, content)
content["state"] = "FAILED_CREATION"
content["resourceState"] = "ERROR"
# has to call update_operation_history return content
- content = self.update_operation_history(content, workflow_status, None)
+ content = self.update_operation_history(content, op_id, workflow_status, None)
self.db.set_one("k8sinfra_config", {"_id": content["_id"]}, content)
if workflow_status:
content["operatingState"] = "IDLE"
content = self.update_operation_history(
- content, workflow_status, resource_status
+ content, op_id, workflow_status, resource_status
)
content["current_operation"] = None
self.db.set_one("k8sinfra_config", {"_id": content["_id"]}, content)
content["state"] = "FAILED_DELETION"
content["resourceState"] = "ERROR"
# has to call update_operation_history return content
- content = self.update_operation_history(content, workflow_status, None)
+ content = self.update_operation_history(content, op_id, workflow_status, None)
self.db.set_one("k8sinfra_config", {"_id": content["_id"]}, content)
resource_status, resource_msg = await self.check_resource_status(
content["operatingState"] = "IDLE"
content = self.update_operation_history(
- content, workflow_status, resource_status
+ content, op_id, workflow_status, resource_status
)
content["current_operation"] = None
self.db.set_one("k8sinfra_config", {"_id": content["_id"]}, content)
db_content["state"] = "FAILED_CREATION"
db_content["resourceState"] = "ERROR"
- db_content = self.update_operation_history(db_content, workflow_status, None)
+ db_content = self.update_operation_history(
+ db_content, op_id, workflow_status, None
+ )
self.db.set_one(self.db_collection, {"_id": db_content["_id"]}, db_content)
if workflow_status:
# self.logger.info("Db content: {}".format(db_content))
db_content = self.update_operation_history(
- db_content, workflow_status, resource_status
+ db_content, op_id, workflow_status, resource_status
)
db_content["operatingState"] = "IDLE"
else:
db_content["resourceState"] = "ERROR"
- db_content = self.update_operation_history(db_content, workflow_status, None)
+ db_content = self.update_operation_history(
+ db_content, op_id, workflow_status, None
+ )
# self.logger.info("Db content: {}".format(db_content))
self.db.set_one(self.db_collection, {"_id": db_content["_id"]}, db_content)
db_content["resourceState"] = "ERROR"
db_content = self.update_operation_history(
- db_content, workflow_status, resource_status
+ db_content, op_id, workflow_status, resource_status
)
db_content["operatingState"] = "IDLE"
db_content["state"] = "FAILED_DELETION"
db_content["resourceState"] = "ERROR"
- db_content = self.update_operation_history(db_content, workflow_status, None)
+ db_content = self.update_operation_history(
+ db_content, op_id, workflow_status, None
+ )
self.db.set_one(self.db_collection, {"_id": db_content["_id"]}, db_content)
if workflow_status:
db_content["resourceState"] = "ERROR"
db_content = self.update_operation_history(
- db_content, workflow_status, resource_status
+ db_content, op_id, workflow_status, resource_status
)
db_content["operatingState"] = "IDLE"
db_ksu["state"] = "FAILED_CREATION"
db_ksu["resourceState"] = "ERROR"
- db_ksu = self.update_operation_history(db_ksu, workflow_status, None)
+ db_ksu = self.update_operation_history(db_ksu, op_id, workflow_status, None)
self.db.set_one(self.db_collection, {"_id": db_ksu["_id"]}, db_ksu)
# Clean items used in the workflow, no matter if the workflow succeeded
db_ksu["resourceState"] = "ERROR"
db_ksu = self.update_operation_history(
- db_ksu, workflow_status, resource_status
+ db_ksu, op_id, workflow_status, resource_status
)
for db_ksu in content:
else:
db_ksu["resourceState"] = "ERROR"
- db_ksu = self.update_operation_history(db_ksu, workflow_status, None)
+ db_ksu = self.update_operation_history(db_ksu, op_id, workflow_status, None)
self.db.set_one(self.db_collection, {"_id": db_ksu["_id"]}, db_ksu)
# Clean items used in the workflow, no matter if the workflow succeeded
db_ksu["resourceState"] = "ERROR"
db_ksu = self.update_operation_history(
- db_ksu, workflow_status, resource_status
+ db_ksu, op_id, workflow_status, resource_status
)
for db_ksu, ksu_params in zip(content, op_params):
db_ksu["state"] = "FAILED_DELETION"
db_ksu["resourceState"] = "ERROR"
- db_ksu = self.update_operation_history(db_ksu, workflow_status, None)
+ db_ksu = self.update_operation_history(db_ksu, op_id, workflow_status, None)
self.db.set_one(self.db_collection, {"_id": db_ksu["_id"]}, db_ksu)
if workflow_status:
db_ksu["resourceState"] = "ERROR"
db_ksu = self.update_operation_history(
- db_ksu, workflow_status, resource_status
+ db_ksu, op_id, workflow_status, resource_status
)
for db_ksu in content:
else:
db_content["resourceState"] = "ERROR"
- db_content = self.update_operation_history(db_content, workflow_status, None)
+ db_content = self.update_operation_history(
+ db_content, op_id, workflow_status, None
+ )
self.db.set_one(self.db_collection, {"_id": db_content["_id"]}, db_content)
if workflow_status:
db_content["resourceState"] = "ERROR"
db_content = self.update_operation_history(
- db_content, workflow_status, resource_status
+ db_content, op_id, workflow_status, resource_status
)
db_content["operatingState"] = "IDLE"
else:
db_content["resourceState"] = "ERROR"
- db_content = self.update_operation_history(db_content, workflow_status, None)
+ db_content = self.update_operation_history(
+ db_content, op_id, workflow_status, None
+ )
self.db.set_one(self.db_collection, {"_id": db_content["_id"]}, db_content)
if workflow_status:
db_content["resourceState"] = "ERROR"
db_content = self.update_operation_history(
- db_content, workflow_status, resource_status
+ db_content, op_id, workflow_status, resource_status
)
db_content["operatingState"] = "IDLE"