Skip to content

Successful final retry incorrectly raises RetriesExhaustedError when max_retry=1 #550

Description

@sagittariuslee

Description

The Redfish Python library can raise RetriesExhaustedError even when the final permitted retry succeeds.

In our environment, the client is configured with:

max_retry = 1

The request sequence is:

Attempt 1 of /redfish/v1/
... connection failure: [Errno 113] No route to host ...

Attempt 2 of /redfish/v1/
Response Time for GET to /redfish/v1/: 0.108... seconds

Attempt 2 successfully receives a valid HTTP response.

However, immediately afterward the library raises:

redfish.rest.v1.RetriesExhaustedError

The relevant code is:

attempts = 0
restresp = None

while attempts <= max_retry:
    attempts = attempts + 1

    try:
        resp = self._session.request(...)
        restresp = RestResponse(restreq, resp)
    except Exception as excp:
        ...
        continue
    else:
        break

if attempts <= self._max_retry:
    return restresp
else:
    raise RetriesExhaustedError() from cause_exception

With max_retry=1, two total attempts are allowed:

Attempt 1 -> fails
Attempt 2 -> succeeds

After the successful second attempt:

attempts = 2
self._max_retry = 1
restresp = valid RestResponse

The following check therefore evaluates false:

if attempts <= self._max_retry:

and RetriesExhaustedError is raised despite the valid response.

Charm revision

latest/stable

Juju version

3.6.13

Cloud

No response

Expected behaviour

If any permitted retry succeeds, the returned RestResponse should be returned to the caller.

For example:

if restresp is not None:
    return restresp
else:
    raise RetriesExhaustedError() from cause_exception

Reproduce / Test

  • Configure the Redfish client with max_retry=1.
  • Make the first request fail with a transient connection error.
  • Allow the second attempt to succeed.
  • Observe that the library still raises RetriesExhaustedError instead of returning the successful response.

Notes & References

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions