From 11ef3c6ccfc27280cce8b552359d2db15f1fcf62 Mon Sep 17 00:00:00 2001 From: Juliano Costa Date: Fri, 21 Jun 2024 18:23:09 +0200 Subject: [PATCH 1/6] [Valkey] Replace Redis with Valkey (#1619) * replace redis with valkey * changelog --------- Co-authored-by: Mikko Viitanen <74129181+mviitane@users.noreply.github.com> --- .env | 8 ++++---- CHANGELOG.md | 2 ++ docker-compose.minimal.yml | 16 ++++++++-------- docker-compose.yml | 16 ++++++++-------- src/cartservice/README.md | 2 +- src/cartservice/src/Program.cs | 14 +++++++------- .../{RedisCartStore.cs => ValkeyCartStore.cs} | 6 +++--- src/otelcollector/otelcol-config.yml | 3 ++- 8 files changed, 35 insertions(+), 32 deletions(-) rename src/cartservice/src/cartstore/{RedisCartStore.cs => ValkeyCartStore.cs} (96%) diff --git a/.env b/.env index dd86d9dbe2..8383b2ec71 100644 --- a/.env +++ b/.env @@ -14,7 +14,7 @@ JAEGERTRACING_IMAGE=jaegertracing/all-in-one:1.57 OPENSEARCH_IMAGE=opensearchproject/opensearch:2.14.0 POSTGRES_IMAGE=postgres:16.3 PROMETHEUS_IMAGE=quay.io/prometheus/prometheus:v2.52.0 -REDIS_IMAGE=redis:7.2-alpine +VALKEY_IMAGE=valkey/valkey:7.2-alpine # must also update the version arg in ./test/tracetesting/Dockerfile TRACETEST_IMAGE=kubeshop/tracetest:v1.3.0 @@ -129,9 +129,9 @@ FLAGD_PORT=8013 KAFKA_SERVICE_PORT=9092 KAFKA_SERVICE_ADDR=kafka:${KAFKA_SERVICE_PORT} -# Redis -REDIS_PORT=6379 -REDIS_ADDR=redis-cart:${REDIS_PORT} +# Valkey +VALKEY_PORT=6379 +VALKEY_ADDR=valkey-cart:${VALKEY_PORT} # ******************** # Telemetry Components diff --git a/CHANGELOG.md b/CHANGELOG.md index 43ca967331..23c53b3f08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ the release. * [cartservice] bump .NET package to 1.9.0 release ([#1610](https://github.com/open-telemetry/opentelemetry-demo/pull/1610)) +* [Valkey] Replace Redis with Valkey + ([#1619](https://github.com/open-telemetry/opentelemetry-demo/pull/1619)) ## 1.10.0 diff --git a/docker-compose.minimal.yml b/docker-compose.minimal.yml index 8d1fa8961b..2f8a5eae88 100644 --- a/docker-compose.minimal.yml +++ b/docker-compose.minimal.yml @@ -66,13 +66,13 @@ services: environment: - CART_SERVICE_PORT - FLAGD_HOST - - REDIS_ADDR + - VALKEY_ADDR - OTEL_EXPORTER_OTLP_ENDPOINT - OTEL_RESOURCE_ATTRIBUTES - OTEL_SERVICE_NAME=cartservice - ASPNETCORE_URLS=http://*:${CART_SERVICE_PORT} depends_on: - redis-cart: + valkey-cart: condition: service_started otelcol: condition: service_started @@ -515,18 +515,18 @@ services: logging: *logging - # Redis used by Cart service - redis-cart: - image: ${REDIS_IMAGE} - container_name: redis-cart - user: redis + # Valkey used by Cart service + valkey-cart: + image: ${VALKEY_IMAGE} + container_name: valkey-cart + user: valkey deploy: resources: limits: memory: 20M restart: unless-stopped ports: - - "${REDIS_PORT}" + - "${VALKEY_PORT}" logging: *logging diff --git a/docker-compose.yml b/docker-compose.yml index 2ddfa71221..6bdb0374fe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -96,13 +96,13 @@ services: - CART_SERVICE_PORT - FLAGD_HOST - FLAGD_PORT - - REDIS_ADDR + - VALKEY_ADDR - OTEL_EXPORTER_OTLP_ENDPOINT - OTEL_RESOURCE_ATTRIBUTES - OTEL_SERVICE_NAME=cartservice - ASPNETCORE_URLS=http://*:${CART_SERVICE_PORT} depends_on: - redis-cart: + valkey-cart: condition: service_started otelcol: condition: service_started @@ -625,18 +625,18 @@ services: retries: 10 logging: *logging - # Redis used by Cart service - redis-cart: - image: ${REDIS_IMAGE} - container_name: redis-cart - user: redis + # Valkey used by Cart service + valkey-cart: + image: ${VALKEY_IMAGE} + container_name: valkey-cart + user: valkey deploy: resources: limits: memory: 20M restart: unless-stopped ports: - - "${REDIS_PORT}" + - "${VALKEY_PORT}" logging: *logging diff --git a/src/cartservice/README.md b/src/cartservice/README.md index 1de0ee0c33..fbc6fbc1ee 100644 --- a/src/cartservice/README.md +++ b/src/cartservice/README.md @@ -1,6 +1,6 @@ # Cart Service -This service stores user shopping carts in Redis. +This service stores user shopping carts in Valkey. ## Local Build diff --git a/src/cartservice/src/Program.cs b/src/cartservice/src/Program.cs index 15baaa64df..e4e6a28e11 100644 --- a/src/cartservice/src/Program.cs +++ b/src/cartservice/src/Program.cs @@ -20,10 +20,10 @@ using OpenFeature.Contrib.Hooks.Otel; var builder = WebApplication.CreateBuilder(args); -string redisAddress = builder.Configuration["REDIS_ADDR"]; -if (string.IsNullOrEmpty(redisAddress)) +string valkeyAddress = builder.Configuration["VALKEY_ADDR"]; +if (string.IsNullOrEmpty(valkeyAddress)) { - Console.WriteLine("REDIS_ADDR environment variable is required."); + Console.WriteLine("VALKEY_ADDR environment variable is required."); Environment.Exit(1); } @@ -33,7 +33,7 @@ builder.Services.AddSingleton(x=> { - var store = new RedisCartStore(x.GetRequiredService>(), redisAddress); + var store = new ValkeyCartStore(x.GetRequiredService>(), valkeyAddress); store.Initialize(); return store; }); @@ -48,7 +48,7 @@ builder.Services.AddSingleton(x => new CartService( x.GetRequiredService(), - new RedisCartStore(x.GetRequiredService>(), "badhost:1234"), + new ValkeyCartStore(x.GetRequiredService>(), "badhost:1234"), x.GetRequiredService() )); @@ -79,8 +79,8 @@ var app = builder.Build(); -var redisCartStore = (RedisCartStore) app.Services.GetRequiredService(); -app.Services.GetRequiredService().AddConnection(redisCartStore.GetConnection()); +var ValkeyCartStore = (ValkeyCartStore) app.Services.GetRequiredService(); +app.Services.GetRequiredService().AddConnection(ValkeyCartStore.GetConnection()); app.MapGrpcService(); app.MapGrpcHealthChecksService(); diff --git a/src/cartservice/src/cartstore/RedisCartStore.cs b/src/cartservice/src/cartstore/ValkeyCartStore.cs similarity index 96% rename from src/cartservice/src/cartstore/RedisCartStore.cs rename to src/cartservice/src/cartstore/ValkeyCartStore.cs index b9f54bcca0..aa79afedea 100644 --- a/src/cartservice/src/cartstore/RedisCartStore.cs +++ b/src/cartservice/src/cartstore/ValkeyCartStore.cs @@ -10,7 +10,7 @@ namespace cartservice.cartstore; -public class RedisCartStore : ICartStore +public class ValkeyCartStore : ICartStore { private readonly ILogger _logger; private const string CartFieldName = "cart"; @@ -25,13 +25,13 @@ public class RedisCartStore : ICartStore private readonly ConfigurationOptions _redisConnectionOptions; - public RedisCartStore(ILogger logger, string redisAddress) + public ValkeyCartStore(ILogger logger, string valkeyAddress) { _logger = logger; // Serialize empty cart into byte array. var cart = new Oteldemo.Cart(); _emptyCartBytes = cart.ToByteArray(); - _connectionString = $"{redisAddress},ssl=false,allowAdmin=true,abortConnect=false"; + _connectionString = $"{valkeyAddress},ssl=false,allowAdmin=true,abortConnect=false"; _redisConnectionOptions = ConfigurationOptions.Parse(_connectionString); diff --git a/src/otelcollector/otelcol-config.yml b/src/otelcollector/otelcol-config.yml index a6aebeb293..f8a34399cd 100644 --- a/src/otelcollector/otelcol-config.yml +++ b/src/otelcollector/otelcol-config.yml @@ -14,7 +14,8 @@ receivers: targets: - endpoint: http://frontendproxy:${env:ENVOY_PORT} redis: - endpoint: "redis-cart:6379" + endpoint: "valkey-cart:6379" + username: "valkey" collection_interval: 10s exporters: From e5e1a0da7fdaaf18f50fa27662c90ac21b842044 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Jun 2024 01:44:50 -0400 Subject: [PATCH 2/6] build(deps): bump docker/build-push-action from 6.0.1 to 6.1.0 (#1620) Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6.0.1 to 6.1.0. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v6.0.1...v6.1.0) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mikko Viitanen <74129181+mviitane@users.noreply.github.com> --- .github/workflows/component_build-images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/component_build-images.yml b/.github/workflows/component_build-images.yml index f10d648878..179e8d3d9c 100644 --- a/.github/workflows/component_build-images.yml +++ b/.github/workflows/component_build-images.yml @@ -162,7 +162,7 @@ jobs: max-parallelism = 2 - name: Matrix Build and push demo images if: steps.check_changes.outputs.skip == 'false' - uses: docker/build-push-action@v6.0.1 + uses: docker/build-push-action@v6.1.0 with: context: ${{ matrix.file_tag.context }} file: ${{ matrix.file_tag.file }} From 49992a3adc1f80cdf113796184ab07469465344e Mon Sep 17 00:00:00 2001 From: Roger Coll Date: Wed, 26 Jun 2024 11:00:16 +0200 Subject: [PATCH 3/6] fix: emailservice docker compose image (#1630) Co-authored-by: Pierre Tessier --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6bdb0374fe..3848155f35 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -190,7 +190,7 @@ services: # Email service emailservice: - image: demo/emailservice-contrib:latest + image: ${IMAGE_NAME}:${DEMO_VERSION}-emailservice container_name: email-service build: context: ./ From 3058ede931dc0640c6c6642b56e58565350e71de Mon Sep 17 00:00:00 2001 From: Roger Coll Date: Wed, 26 Jun 2024 15:27:41 +0200 Subject: [PATCH 4/6] add collector configs as environment variable (#1632) Co-authored-by: Mikko Viitanen <74129181+mviitane@users.noreply.github.com> --- .env | 2 ++ docker-compose.minimal.yml | 4 ++-- docker-compose.yml | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.env b/.env index 8383b2ec71..f85b34f366 100644 --- a/.env +++ b/.env @@ -25,6 +25,8 @@ ENV_PLATFORM=local OTEL_COLLECTOR_HOST=otelcol OTEL_COLLECTOR_PORT_GRPC=4317 OTEL_COLLECTOR_PORT_HTTP=4318 +OTEL_COLLECTOR_CONFIG=./src/otelcollector/otelcol-config.yml +OTEL_COLLECTOR_CONFIG_EXTRAS=./src/otelcollector/otelcol-config-extras.yml OTEL_EXPORTER_OTLP_ENDPOINT=http://${OTEL_COLLECTOR_HOST}:${OTEL_COLLECTOR_PORT_GRPC} PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:8080/otlp-http/v1/traces diff --git a/docker-compose.minimal.yml b/docker-compose.minimal.yml index 2f8a5eae88..5720b4e0c8 100644 --- a/docker-compose.minimal.yml +++ b/docker-compose.minimal.yml @@ -584,8 +584,8 @@ services: restart: unless-stopped command: [ "--config=/etc/otelcol-config.yml", "--config=/etc/otelcol-config-extras.yml" ] volumes: - - ./src/otelcollector/otelcol-config.yml:/etc/otelcol-config.yml - - ./src/otelcollector/otelcol-config-extras.yml:/etc/otelcol-config-extras.yml + - ${OTEL_COLLECTOR_CONFIG}:/etc/otelcol-config.yml + - ${OTEL_COLLECTOR_CONFIG_EXTRAS}:/etc/otelcol-config-extras.yml ports: - "${OTEL_COLLECTOR_PORT_GRPC}" - "${OTEL_COLLECTOR_PORT_HTTP}" diff --git a/docker-compose.yml b/docker-compose.yml index 3848155f35..bf2c75a3c9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -694,8 +694,8 @@ services: restart: unless-stopped command: [ "--config=/etc/otelcol-config.yml", "--config=/etc/otelcol-config-extras.yml" ] volumes: - - ./src/otelcollector/otelcol-config.yml:/etc/otelcol-config.yml - - ./src/otelcollector/otelcol-config-extras.yml:/etc/otelcol-config-extras.yml + - ${OTEL_COLLECTOR_CONFIG}:/etc/otelcol-config.yml + - ${OTEL_COLLECTOR_CONFIG_EXTRAS}:/etc/otelcol-config-extras.yml ports: - "${OTEL_COLLECTOR_PORT_GRPC}" - "${OTEL_COLLECTOR_PORT_HTTP}" From 5caa07d1781cd930ac15a8e0ba9aa07456bf979b Mon Sep 17 00:00:00 2001 From: Sven Kirschbaum Date: Wed, 26 Jun 2024 17:32:53 +0200 Subject: [PATCH 5/6] fix(frontend): Use port 443 as default to connect to flagd if https is in use (#1609) * fix(frontend): Use port 443 as default to connect to flagd if https is in use * chore: Update CHANGELOG.md --------- Co-authored-by: Pierre Tessier --- CHANGELOG.md | 2 ++ src/frontend/pages/_app.tsx | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23c53b3f08..40a7b61d10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ the release. ([#1610](https://github.com/open-telemetry/opentelemetry-demo/pull/1610)) * [Valkey] Replace Redis with Valkey ([#1619](https://github.com/open-telemetry/opentelemetry-demo/pull/1619)) +* [frontend] fixed default flagd port for HTTPS connections + ([#1609](https://github.com/open-telemetry/opentelemetry-demo/pull/1609)) ## 1.10.0 diff --git a/src/frontend/pages/_app.tsx b/src/frontend/pages/_app.tsx index 00a7e696b5..e49b51f7c6 100755 --- a/src/frontend/pages/_app.tsx +++ b/src/frontend/pages/_app.tsx @@ -37,12 +37,19 @@ if (typeof window !== 'undefined') { * We connect to flagd through the envoy proxy, straight from the browser, * for this we need to know the current hostname and port. */ + + const useTLS = window.location.protocol === 'https:'; + let port = useTLS ? 443 : 80; + if (window.location.port) { + port = parseInt(window.location.port, 10); + } + OpenFeature.setProvider( new FlagdWebProvider({ host: window.location.hostname, pathPrefix: 'flagservice', - port: window.location.port ? parseInt(window.location.port, 10) : 80, - tls: window.location.protocol === 'https:', + port: port, + tls: useTLS, maxRetries: 3, maxDelay: 10000, }) From 918e86a7e8fddc3a0efe8e1dce632e2db88762ac Mon Sep 17 00:00:00 2001 From: Steve Flanders Date: Thu, 27 Jun 2024 09:13:03 -0400 Subject: [PATCH 6/6] Update recommendation flag to match flagd configuration (#1634) Address #1626 --- CHANGELOG.md | 2 ++ src/recommendationservice/recommendation_server.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40a7b61d10..1af53902e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ the release. ([#1619](https://github.com/open-telemetry/opentelemetry-demo/pull/1619)) * [frontend] fixed default flagd port for HTTPS connections ([#1609](https://github.com/open-telemetry/opentelemetry-demo/pull/1609)) +* ([recommendation] updated flag name to match flagd configuration + ([#1634](https://github.com/open-telemetry/opentelemetry-demo/pull/1634)) ## 1.10.0 diff --git a/src/recommendationservice/recommendation_server.py b/src/recommendationservice/recommendation_server.py index c7302bcac5..1a6826d80d 100644 --- a/src/recommendationservice/recommendation_server.py +++ b/src/recommendationservice/recommendation_server.py @@ -75,7 +75,7 @@ def get_product_list(request_product_ids): request_product_ids = request_product_ids_str.split(',') # Feature flag scenario - Cache Leak - if check_feature_flag("recommendationCache"): + if check_feature_flag("recommendationServiceCacheFailure"): span.set_attribute("app.recommendation.cache_enabled", True) if random.random() < 0.5 or first_run: first_run = False