From e23a576f8b8ee49f447ba2baafcda165014cb495 Mon Sep 17 00:00:00 2001 From: Armen Zambrano G Date: Tue, 5 Oct 2021 15:18:19 -0400 Subject: [PATCH 1/2] feat(dev): Use newer kafka & zookeeper images to support Apple arm64 The current zookeeper image we use fails to execute on Apple's arm64 machines (see [issue][1]) for details). Only upgrading the version of both when executing on Apple arm64 machines. Fixes #28570. [1]: https://github.com/confluentinc/kafka-images/issues/80#issuecomment-855511438 --- .github/actions/setup-sentry/action.yml | 4 ++++ src/sentry/conf/server.py | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/actions/setup-sentry/action.yml b/.github/actions/setup-sentry/action.yml index 715f4c13c538d9..350edb43c6706d 100644 --- a/.github/actions/setup-sentry/action.yml +++ b/.github/actions/setup-sentry/action.yml @@ -158,12 +158,16 @@ runs: # TODO: Use devservices kafka. See https://github.com/getsentry/sentry/pull/20986#issuecomment-704510570 if [ "$NEED_KAFKA" = "true" ]; then + # This is *not* the production version. Unclear reason as to why this was chosen + # https://github.com/getsentry/ops/blob/c823e62f930ecc6c97bb08898c71e49edc7232f6/cookbooks/getsentry/attributes/default.rb#L631 docker run \ --name sentry_zookeeper \ -d --network host \ -e ZOOKEEPER_CLIENT_PORT=2181 \ confluentinc/cp-zookeeper:4.1.0 + # This is the production version; do not change w/o changing it there as well + # https://github.com/getsentry/ops/blob/c823e62f930ecc6c97bb08898c71e49edc7232f6/cookbooks/getsentry/attributes/default.rb#L643 docker run \ --name sentry_kafka \ -d --network host \ diff --git a/src/sentry/conf/server.py b/src/sentry/conf/server.py index d0319e11068007..84ea8bd6f2727f 100644 --- a/src/sentry/conf/server.py +++ b/src/sentry/conf/server.py @@ -9,6 +9,7 @@ import sys import tempfile from datetime import timedelta +from platform import platform as pf from urllib.parse import urlparse from django.conf.global_settings import * # NOQA @@ -1697,6 +1698,8 @@ def build_cdc_postgres_init_db_volume(settings): ) +APPLE_ARM64 = pf().startswith("mac") and pf().endswith("arm64-arm-64bit") + SENTRY_DEVSERVICES = { "redis": lambda settings, options: ( { @@ -1749,7 +1752,11 @@ def build_cdc_postgres_init_db_volume(settings): ), "zookeeper": lambda settings, options: ( { - "image": "confluentinc/cp-zookeeper:5.1.2", + # On Apple arm64, we upgrade to version 6.x allows zookeeper to run properly on Apple's arm64 + # See details https://github.com/confluentinc/kafka-images/issues/80#issuecomment-855511438 + "image": "confluentinc/cp-zookeeper:6.2.0" + if APPLE_ARM64 + else "confluentinc/cp-zookeeper:5.1.2", "environment": {"ZOOKEEPER_CLIENT_PORT": "2181"}, "volumes": {"zookeeper": {"bind": "/var/lib/zookeeper"}}, "only_if": "kafka" in settings.SENTRY_EVENTSTREAM or settings.SENTRY_USE_RELAY, @@ -1757,7 +1764,10 @@ def build_cdc_postgres_init_db_volume(settings): ), "kafka": lambda settings, options: ( { - "image": "confluentinc/cp-kafka:5.1.2", + # On Apple arm64, we upgrade to version 6.x to match zookeeper's version (I believe they both release together) + "image": "confluentinc/cp-kafka:6.2.0" + if APPLE_ARM64 + else "confluentinc/cp-kafka:5.1.2", "ports": {"9092/tcp": 9092}, "environment": { "KAFKA_ZOOKEEPER_CONNECT": "{containers[zookeeper][name]}:2181", From 8c0fcf56881b45144d0cc1dc0bea50e9cd1708d7 Mon Sep 17 00:00:00 2001 From: Armen Zambrano G Date: Wed, 6 Oct 2021 11:55:53 -0400 Subject: [PATCH 2/2] Feedback --- src/sentry/conf/server.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sentry/conf/server.py b/src/sentry/conf/server.py index a3042ceaae14ac..e0133c22fa4aa6 100644 --- a/src/sentry/conf/server.py +++ b/src/sentry/conf/server.py @@ -9,7 +9,7 @@ import sys import tempfile from datetime import timedelta -from platform import platform as pf +from platform import platform from urllib.parse import urlparse from django.conf.global_settings import * # NOQA @@ -1701,7 +1701,7 @@ def build_cdc_postgres_init_db_volume(settings): ) -APPLE_ARM64 = pf().startswith("mac") and pf().endswith("arm64-arm-64bit") +APPLE_ARM64 = platform().startswith("mac") and platform().endswith("arm64-arm-64bit") SENTRY_DEVSERVICES = { "redis": lambda settings, options: ( @@ -1757,6 +1757,8 @@ def build_cdc_postgres_init_db_volume(settings): { # On Apple arm64, we upgrade to version 6.x allows zookeeper to run properly on Apple's arm64 # See details https://github.com/confluentinc/kafka-images/issues/80#issuecomment-855511438 + # I'm selectively upgrading the version on Apple's arm64 since there was a bug that only affects + # Intel machines. For more details see: https://github.com/getsentry/sentry/pull/28672 "image": "confluentinc/cp-zookeeper:6.2.0" if APPLE_ARM64 else "confluentinc/cp-zookeeper:5.1.2",