-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update wait_for_status_success() call to look at both type and status for status.conditions #2289
Conversation
WalkthroughThe pull request modifies the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Report bugs in Issues The following are automatically added:
Available user actions:
Supported /retest check runs
Supported labels
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
ocp_resources/node_network_configuration_policy.py
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: python-module-install
- GitHub Check: tox
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
ocp_resources/node_network_configuration_policy.py (1)
373-373
: Document retry parameters and behavior.Add a docstring explaining the retry behavior, including why the specific wait_timeout and sleep values were chosen.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
ocp_resources/node_network_configuration_policy.py
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: python-module-install
- GitHub Check: tox
🔇 Additional comments (2)
ocp_resources/node_network_configuration_policy.py (2)
13-13
: LGTM!The
retry
import is correctly added alongside other timeout_sampler imports.
378-392
: 🛠️ Refactor suggestionImprove error handling and code reusability.
The method has several issues:
- Duplicates condition retrieval logic instead of using
get_available_condition
- Missing error handling for empty available_condition list
- Inconsistent error handling between branches
Apply this diff to fix the issues:
@retry(wait_timeout=120, sleep=5) def wait_for_status_success(self): """ Wait for the policy to reach success status. Returns: list: Available conditions if successful. Raises: NNCPConfigurationFailed: If configuration fails or no matching node found. """ failed_condition_reason = self.Conditions.Reason.FAILED_TO_CONFIGURE no_match_node_condition_reason = self.Conditions.Reason.NO_MATCHING_NODE - available_condition = [ - condition - for condition in self.instance.get("status", {}).get("conditions", []) - if condition and condition["type"] == self.Conditions.Type.AVAILABLE - ] - if available_condition: - if available_condition[0]["status"] == self.Condition.Status.TRUE: - self.logger.info(f"NNCP {self.name} configured Successfully") - return available_condition - - elif available_condition[0]["reason"] == no_match_node_condition_reason: - raise NNCPConfigurationFailed(f"{self.name}. Reason: {no_match_node_condition_reason}") - - elif available_condition[0]["reason"] == failed_condition_reason: - self._process_failed_status(failed_condition_reason=failed_condition_reason) + available_condition = self.get_available_condition() + if not available_condition: + raise NNCPConfigurationFailed(f"{self.name}. Reason: No available condition found") + + if available_condition["status"] == self.Condition.Status.TRUE: + self.logger.info(f"NNCP {self.name} configured Successfully") + return [available_condition] + + if available_condition["reason"] == no_match_node_condition_reason: + raise NNCPConfigurationFailed(f"{self.name}. Reason: {no_match_node_condition_reason}") + + if available_condition["reason"] == failed_condition_reason: + self._process_failed_status(failed_condition_reason=failed_condition_reason) + + raise NNCPConfigurationFailed( + f"{self.name}. Unexpected reason: {available_condition['reason']}" + )Likely invalid or redundant comment.
/verified |
/verified |
/verified |
/cherry-pick v4.17 |
… for status.conditions (#2289) * status should return reason, when condition status is True * based on review comments and offline conversation with dev team * remove unnecessary code * undo retry * addressed review comment * address review comment * update based on reviews
Cherry-picked PR Update wait_for_status_success() call to look at both type and status for status.conditions into v4.17 |
… for status.conditions (#2289) (#2297) * status should return reason, when condition status is True * based on review comments and offline conversation with dev team * remove unnecessary code * undo retry * addressed review comment * address review comment * update based on reviews Co-authored-by: Debarati Basu-Nag <[email protected]>
/cherry-pick v4.16 |
… for status.conditions (#2289) * status should return reason, when condition status is True * based on review comments and offline conversation with dev team * remove unnecessary code * undo retry * addressed review comment * address review comment * update based on reviews
Cherry-picked PR Update wait_for_status_success() call to look at both type and status for status.conditions into v4.16 |
… for status.conditions (#2289) (#2300) * status should return reason, when condition status is True * based on review comments and offline conversation with dev team * remove unnecessary code * undo retry * addressed review comment * address review comment * update based on reviews Co-authored-by: Debarati Basu-Nag <[email protected]>
Short description:
More details:
What this PR does / why we need it:
Which issue(s) this PR fixes:
Special notes for reviewer:
Bug:
Summary by CodeRabbit