Skip to content

Commit f9ae22f

Browse files
authored
Merge pull request #102 from myakove/nncp-fail-when-NoMatchingNode
NNCP: Fail when reason is NoMatchingNode
2 parents f004503 + 5ed1995 commit f9ae22f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

ocp_resources/node_network_configuration_policy.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class Reason:
3232
CONFIGURING = "ConfigurationProgressing"
3333
SUCCESS = "SuccessfullyConfigured"
3434
FAILED = "FailedToConfigure"
35+
NO_MATCHING_NODE = "NoMatchingNode"
3536

3637
def __init__(
3738
self,
@@ -301,6 +302,8 @@ def status(self):
301302
return condition["reason"]
302303

303304
def wait_for_status_success(self):
305+
failed_condition_reason = self.Conditions.Reason.FAILED
306+
no_match_node_condition_reason = self.Conditions.Reason.NO_MATCHING_NODE
304307
# if we get here too fast there are no conditions, we need to wait.
305308
self.wait_for_conditions()
306309

@@ -311,7 +314,12 @@ def wait_for_status_success(self):
311314
LOGGER.info("NNCP configured Successfully")
312315
return sample
313316

314-
if sample == self.Conditions.Reason.FAILED:
317+
if sample == no_match_node_condition_reason:
318+
raise NNCPConfigurationFailed(
319+
f"Reason: {no_match_node_condition_reason}"
320+
)
321+
322+
if sample == failed_condition_reason:
315323
for failed_nnce in self._get_failed_nnce():
316324
nnce_dict = failed_nnce.instance.to_dict()
317325
for cond in nnce_dict["status"]["conditions"]:
@@ -323,9 +331,7 @@ def wait_for_status_success(self):
323331
f"NNCE {nnce_dict['metadata']['name']}: {error[0]}"
324332
)
325333

326-
raise NNCPConfigurationFailed(
327-
f"Reason: {self.Conditions.Reason.FAILED}"
328-
)
334+
raise NNCPConfigurationFailed(f"Reason: {failed_condition_reason}")
329335

330336
except (TimeoutExpiredError, NNCPConfigurationFailed):
331337
LOGGER.error("Unable to configure NNCP for node")

0 commit comments

Comments
 (0)