Skip to content

Commit 62b40aa

Browse files
MOS CIGerrit Code Review
authored andcommitted
Merge "Store only specific node fields in nwl"
2 parents 399caea + 8525559 commit 62b40aa

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

rockoon/maintenance.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,19 @@ class NodeWorkloadLock(LockBase):
213213
kind = "NodeWorkloadLock"
214214
kopf_on_args = *version.split("/"), endpoint
215215

216+
@classmethod
217+
def get_normalized_node(cls, node_obj):
218+
node = {
219+
"apiVersion": node_obj["apiVersion"],
220+
"kind": node_obj["kind"],
221+
"spec": node_obj["spec"],
222+
"metadata": {
223+
"name": node_obj["metadata"]["name"],
224+
"labels": node_obj["metadata"].get("labels", []),
225+
},
226+
}
227+
return node
228+
216229
@classmethod
217230
def dummy(cls, name):
218231
node_name = "-".join(name.split("-")[1:])
@@ -221,10 +234,13 @@ def dummy(cls, name):
221234
dummy["spec"]["nodeDeletionRequestSupported"] = True
222235
node = kube.safe_get_node(node_name)
223236
if node.exists():
224-
node = node.obj
225-
node.pop("status", None)
237+
normalized_node = cls.get_normalized_node(node.obj)
226238
dummy["metadata"]["annotations"].update(
227-
{"openstack.lcm.mirantis.com/original-node": json.dumps(node)}
239+
{
240+
"openstack.lcm.mirantis.com/original-node": json.dumps(
241+
normalized_node
242+
)
243+
}
228244
)
229245
return dummy
230246

0 commit comments

Comments
 (0)