Skip to content

Commit

Permalink
Merge "Store only specific node fields in nwl"
Browse files Browse the repository at this point in the history
  • Loading branch information
MOS CI authored and Gerrit Code Review committed Mar 1, 2025
2 parents 399caea + 8525559 commit 62b40aa
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions rockoon/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,19 @@ class NodeWorkloadLock(LockBase):
kind = "NodeWorkloadLock"
kopf_on_args = *version.split("/"), endpoint

@classmethod
def get_normalized_node(cls, node_obj):
node = {
"apiVersion": node_obj["apiVersion"],
"kind": node_obj["kind"],
"spec": node_obj["spec"],
"metadata": {
"name": node_obj["metadata"]["name"],
"labels": node_obj["metadata"].get("labels", []),
},
}
return node

@classmethod
def dummy(cls, name):
node_name = "-".join(name.split("-")[1:])
Expand All @@ -221,10 +234,13 @@ def dummy(cls, name):
dummy["spec"]["nodeDeletionRequestSupported"] = True
node = kube.safe_get_node(node_name)
if node.exists():
node = node.obj
node.pop("status", None)
normalized_node = cls.get_normalized_node(node.obj)
dummy["metadata"]["annotations"].update(
{"openstack.lcm.mirantis.com/original-node": json.dumps(node)}
{
"openstack.lcm.mirantis.com/original-node": json.dumps(
normalized_node
)
}
)
return dummy

Expand Down

0 comments on commit 62b40aa

Please sign in to comment.