Skip to content

Commit 51323c9

Browse files
committed
Add update method to handle consecutive updates safely
Added an update method in NodeNetworkConfigurationPolicy to wait for NNCP status updates before applying changes. This prevents API failures caused by the admission webhook rejecting updates while NNCP is still in progress. Signed-off-by: Shahaf Bahar <[email protected]>
1 parent 2dc73c0 commit 51323c9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ocp_resources/node_network_configuration_policy.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from ocp_resources.node_network_state import NodeNetworkState
1313
from ocp_resources.resource import Resource, ResourceEditor
1414
from timeout_sampler import TimeoutExpiredError, TimeoutSampler, TimeoutWatch, retry
15+
from typing import Any
1516

1617
IPV4_STR = "ipv4"
1718
IPV6_STR = "ipv6"
@@ -360,6 +361,12 @@ def _wait_for_nncp_status_update(self, initial_transition_time: str) -> bool:
360361
return True
361362
return False
362363

364+
def update(self, resource_dict: dict[str, Any]) -> None:
365+
initial_success_status_time = self._get_last_successful_transition_time()
366+
super().update(resource_dict=resource_dict)
367+
if resource_dict["spec"] and initial_success_status_time:
368+
self._wait_for_nncp_status_update(initial_transition_time=initial_success_status_time)
369+
363370
@property
364371
def status(self):
365372
for condition in self.instance.status.conditions:

0 commit comments

Comments
 (0)