Skip to content

Fixing sentinel command response #3191

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
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Conversation

mahigupta
Copy link

@mahigupta mahigupta commented Mar 23, 2024

Pull Request check-list

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?
  • Was the change added to CHANGES file?

Description of change

For #3139

  • Made change to execute_command function to parse sentinel command response correctly and don't return by default True

@mahigupta
Copy link
Author

@dvora-h Can you please take a look.

@mahigupta
Copy link
Author

@vladvildanov Can you please take a look ?

@vladvildanov
Copy link
Collaborator

@mahigupta Thanks for your input! I'll also include @gerzse into this

@mahigupta
Copy link
Author

Hello,
@vladvildanov @gerzse , Can anyone look in to this PR ?

@vladvildanov
Copy link
Collaborator

@mahigupta Looks fine 👌 Working on fixing CI, docker-compose was removed from default commands in Ubuntu 22.04 LTS runner

@mahigupta
Copy link
Author

@vladvildanov @gerzse Ci fixed now to go ahead with this PR ?

@petyaslavova
Copy link
Collaborator

This change will still need a few new unit tests to be added.

@petyaslavova petyaslavova requested a review from Copilot May 15, 2025 16:10
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the behavior of the sentinel command response in Redis by updating the execute_command function to correctly parse responses and returning either a boolean or the original response based on the provided options.

  • Updates in both synchronous and asynchronous sentinel modules to pop "once" and "return_responses" from kwargs and return the processed response.
  • Updates to the Redis commands for sentinel to pass the new execution options.
  • An update to the CHANGES file documenting the fix.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
redis/sentinel.py Updated execute_command to handle return_responses and once logic.
redis/commands/sentinel.py Modified sentinel command method calls to include new options.
redis/asyncio/sentinel.py Asynchronous execute_command updated similar to its sync counterpart.
CHANGES Documented the fix for the sentinel command response behavior.

@petyaslavova petyaslavova requested a review from vladvildanov May 16, 2025 07:52
@petyaslavova petyaslavova added the bug Bug label May 27, 2025
@petyaslavova petyaslavova requested a review from Copilot June 3, 2025 11:38
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes how sentinel commands parse and return responses by introducing a return_responses flag and removing the default True return behavior. It also updates several sentinel command wrappers to leverage this new flag and expands test coverage with real-sentinel integration tests.

  • Enhance execute_command (sync/async) to pop once/return_responses flags and return a list or boolean accordingly
  • Update sentinel command methods to use once=True and/or return_responses=True where appropriate
  • Add deployed_sentinel fixtures and real-instance tests in both sync and asyncio suites

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_sentinel.py Added deployed_sentinel fixture and real-sentinel integration tests
tests/test_asyncio/test_sentinel.py Mirror sync changes for asyncio tests and real-instance coverage
redis/sentinel.py Refactored execute_command to support return_responses flag
redis/asyncio/sentinel.py Refactored async execute_command similarly
redis/commands/sentinel.py Updated sentinel_* wrappers to pass once/return_responses options
Comments suppressed due to low confidence (2)

redis/commands/sentinel.py:15

  • The method now returns a list of tuples (due to return_responses=True) rather than a single tuple; please update this docstring to reflect the new return type.
        """Returns a (host, port) pair for the given ``service_name``"""

redis/commands/sentinel.py:23

  • This change makes sentinel_master return a list of dicts instead of a single dict, which is a breaking API change; consider documenting this behavior clearly or offering a non-breaking alternative.
def sentinel_master(self, service_name):

if return_responses:
return responses

return bool(reduce(lambda x, y: x and y, responses))
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider replacing reduce(lambda x, y: x and y, responses) with the built-in all(responses) for improved readability and to avoid the extra import.

Suggested change
return bool(reduce(lambda x, y: x and y, responses))
return all(responses)

Copilot uses AI. Check for mistakes.

if return_responses:
return responses

return bool(reduce(lambda x, y: x and y, responses))
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Similar to the sync version, you can use all(responses) instead of reduce to simplify the boolean aggregation.

Suggested change
return bool(reduce(lambda x, y: x and y, responses))
return all(responses)

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants