getsentry / sentry

Developer-first error tracking and performance monitoring
https://sentry.io
Other
38.96k stars 4.18k forks source link

More configurable Redis Cluster #40762

Open Agalin opened 1 year ago

Agalin commented 1 year ago

Problem Statement

When configuring Redis Cluster in settings only a few selected options are supported (startup_nodes and readonly_mode + a few more hardcoded values).

Not only it differs from Redis Blaster clusters (where whole config is passed after a minor transformation to hosts) but also blocks some important options:

Solution Brainstorm

Currently I'm using a small reimplementation of _RedisCluster's factory method that passes a copy of the whole config excluding is_redis_cluster (custom Sentry parameter) and hosts as it's overwritten explicitly):

def custom_factory(self, **config):
    hosts = config.get("hosts")
    hosts = list(hosts.values()) if isinstance(hosts, dict) else hosts

    def cluster_factory():
        if config.get("is_redis_cluster", False):
            # Copy config and remove Sentry-specific keys.
            safe_config = deepcopy(config)
            del safe_config["is_redis_cluster"]
            hosts = safe_config.pop("hosts")
            return RetryingRedisCluster(
                startup_nodes=hosts,
                decode_responses=True,
                skip_full_coverage_check=True,
                max_connections=16,
                max_connections_per_node=True,
                **safe_config  # Pass all options to the Redis Cluster client.
            )
        else:
            host = hosts[0].copy()
            host["decode_responses"] = True
            return (
                import_string(config["client_class"])
                if "client_class" in config
                else StrictRedis
            )(**host)

    return SimpleLazyObject(cluster_factory)

It works fine but I assume there are reasons only selected list of options is supported.

getsentry-release commented 1 year ago

Routing to @getsentry/team-web-sdk-backend for triage. ⏲️

getsentry-release commented 1 year ago

Routing to @getsentry/app-backend for triage. ⏲️

untitaker commented 1 year ago

@Agalin feel free to submit any improvements to consistency across blaster/cluster or additional supported options for either kind of clients, for as long as they are compatible with existing prod configuration. We are not going to spend time ourselves trying to refine the redis blaster experience I think, rather we're looking into dropping redis blaster completely.

Agalin commented 1 year ago

It’s strictly about Redis Cluster configuration. Currently it’s simply not possible to some clusters because only a few options can be configured.

untitaker commented 1 year ago

Yeah makes sense. Either way we're happy to merge PRs that go in the direction of making this experience better, but we're not going to actively work on it right now.

On Wed, Nov 16, 2022 at 4:24 PM Agalin @.***> wrote:

It’s strictly about Redis Cluster configuration. Currently it’s simply not possible to some clusters because only a few options can be configured.

— Reply to this email directly, view it on GitHub https://github.com/getsentry/sentry/issues/40762#issuecomment-1317193824, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGMPRKDLBX5O2IQBL23MXLWIT4BJANCNFSM6AAAAAARTEKFIU . You are receiving this because you commented.Message ID: @.***>