-
Notifications
You must be signed in to change notification settings - Fork 28
Classify 4xx (except 429) as terminal in RestSend retry policy #502
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
Open
allenrobel
wants to merge
1
commit into
develop
Choose a base branch
from
nd_restsend_4xx_terminal
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+199
−8
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Medium: Preserve retryable 4xx responses instead of terminalizing the entire class
Issue
_is_terminal_client_error()treats every 4xx except 429 as a definitive application rejection for every verb. That is too broad: HTTP 408, 421, and 425 explicitly support retry, and the bundled ND OpenAPI documents 409 on safe GET operations whose conflict is tied to the resource's current state.Evidence
plugins/module_utils/rest/response_handler_nd.pyline 190classifies the full
400..499range as terminal with only 429 excluded.plugins/module_utils/rest/response_handler_nd.pylines 225-228applies that same predicate to GET, even though GET is safe/idempotent and its existing retries also serve polling and eventual-consistency workflows.
plugins/module_utils/rest/rest_send.pylines 377-384immediately exits the retry loop when the handler returns
retryable=False.GET /anomalyRules/postProcessingRules,GET /links,GET /links/{linkId},GET /logicalLinks, andGET /remoteFabrics. Its shared response says the conflict is with the resource's current state; the spec contains no retryability metadata that supports blanket terminalization.retryable=Falsefor GET 408, 409, and 425, while only GET 429 remained retryable.Existing PR overlap
No matching existing PR comment found.
Existing open issue overlap
Related open issue: #457 is the design source for this PR and proposes the same blanket 4xx-except-429 rule. It does not track the protocol-level 408/421/425 exceptions or the OpenAPI-documented GET 409 counterexample, so this finding narrows and corrects that policy rather than duplicating tracked work.
Impact
A concrete ND scenario is topology reconciliation after a switch is added or updated. An Ansible module requests
GET /linkswhile ND is still reconciling the fabric and receives the OpenAPI-documented409 Conflictbecause the link data is temporarily unavailable in its current state. A retry a few seconds later can return200 OKwith the completed link data.The operator therefore sees a failed automation job even though nothing is permanently wrong, and running the same playbook again moments later can succeed. This is a representative scenario inferred from ND's OpenAPI contract, not a live-testbed reproduction. The same blanket classification also suppresses standards-defined retry handling for 408, 421, and 425, and because
ResponseHandleris shared, the regression affects every module using RestSend.Suggested fix
Split safe GET policy from mutation policy and replace the blanket range check with explicit, evidence-backed classifications. At minimum, keep 408 and 425 retryable; preserve retry/polling for safe GET 409; and handle 421 by reopening or changing the connection before retrying. Put the version-specific decision on the injected
ResponseValidationStrategy(or another policy object), matching this file's documented extension point, and add handler plus RestSend tests for the retained retry cases.