From db1be1d9523ac75871624fdfcbc83290821979c2 Mon Sep 17 00:00:00 2001 From: Juliano Costa Date: Tue, 22 Oct 2024 10:07:41 +0200 Subject: [PATCH 1/4] Fix opensearch healthcheck (#1746) * Fix opensearch healthcheck * Add prune before tests * Add flag to auto approve docker prune --- .github/workflows/run-integration-tests.yml | 2 +- docker-compose.minimal.yml | 2 +- docker-compose.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index 46817bff90..fecf66abe7 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -17,4 +17,4 @@ jobs: uses: actions/checkout@v4 - name: run tracetesting run: | - make build && make run-tracetesting + make build && docker system prune -f && make run-tracetesting diff --git a/docker-compose.minimal.yml b/docker-compose.minimal.yml index afb6b12079..0eb1f96485 100644 --- a/docker-compose.minimal.yml +++ b/docker-compose.minimal.yml @@ -657,7 +657,7 @@ services: ports: - "9200" healthcheck: - test: curl -s http://localhost:9200/_cluster/health | grep '"status":"green"' + test: curl -s http://localhost:9200/_cluster/health | grep -E '"status":"(green|yellow)"' start_period: 10s interval: 5s timeout: 10s diff --git a/docker-compose.yml b/docker-compose.yml index 846a934ff8..cb91e09bc9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -799,7 +799,7 @@ services: ports: - "9200" healthcheck: - test: curl -s http://localhost:9200/_cluster/health | grep '"status":"green"' + test: curl -s http://localhost:9200/_cluster/health | grep -E '"status":"(green|yellow)"' start_period: 10s interval: 5s timeout: 10s From 5c4b58dc3ec8ed7fa0ab783440fe0876f4e0a632 Mon Sep 17 00:00:00 2001 From: Juliano Costa Date: Tue, 22 Oct 2024 10:25:18 +0200 Subject: [PATCH 2/4] [chore] Move opensearch image version to .env file (#1743) * [chore] Move opensearch image version to .env file * changelog --- .env | 4 ++-- CHANGELOG.md | 6 ++++-- docker-compose.minimal.yml | 2 +- docker-compose.yml | 2 +- src/grafana/provisioning/datasources/opensearch.yaml | 1 - 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.env b/.env index adc21721c8..1884a7157f 100644 --- a/.env +++ b/.env @@ -10,8 +10,8 @@ COLLECTOR_CONTRIB_IMAGE=otel/opentelemetry-collector-contrib:0.108.0 FLAGD_IMAGE=ghcr.io/open-feature/flagd:v0.11.2 GRAFANA_IMAGE=grafana/grafana:11.2.0 JAEGERTRACING_IMAGE=jaegertracing/all-in-one:1.60 -# must also update version field in ./src/grafana/provisioning/datasources/opensearch.yaml -OPENSEARCH_IMAGE=opensearchproject/opensearch:2.16.0 +OPENSEARCH_IMAGE_VERSION=2.17.1 +OPENSEARCH_IMAGE=opensearchproject/opensearch:${OPENSEARCH_IMAGE_VERSION} POSTGRES_IMAGE=postgres:16.4 PROMETHEUS_IMAGE=quay.io/prometheus/prometheus:v2.54.1 VALKEY_IMAGE=valkey/valkey:8.0-alpine diff --git a/CHANGELOG.md b/CHANGELOG.md index 134c058b1e..e55f3f5e51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ the release. ([#1709](https://github.com/open-telemetry/opentelemetry-demo/pull/1709)) * [chore] Add depends on to otelcol to wait on healthy opensearch ([#1724](https://github.com/open-telemetry/opentelemetry-demo/pull/1724)) +* [flagd-ui] Add UI for managing Flagd feature flags + ([#1725](https://github.com/open-telemetry/opentelemetry-demo/pull/1725)) * [accountingservice] bump OpenTelemetry .NET Automatic Instrumentation to 1.8.0 together with other dependencies ([#1727](https://github.com/open-telemetry/opentelemetry-demo/pull/1727)) @@ -23,8 +25,8 @@ the release. * [frontend] fix imageSlowLoad headers not applied to 1.8.0 together with other dependencies ([#1733](https://github.com/open-telemetry/opentelemetry-demo/pull/1733)) -* [flagd-ui] Add UI for managing Flagd feature flags - ([#1725](https://github.com/open-telemetry/opentelemetry-demo/pull/1725)) +* [chore] Move opensearch image version to .env file + ([#1743](https://github.com/open-telemetry/opentelemetry-demo/pull/1743)) ## 1.11.1 diff --git a/docker-compose.minimal.yml b/docker-compose.minimal.yml index 0eb1f96485..e01c0fb69a 100644 --- a/docker-compose.minimal.yml +++ b/docker-compose.minimal.yml @@ -565,7 +565,7 @@ services: memory: 100M restart: unless-stopped environment: - - "GF_INSTALL_PLUGINS=grafana-opensearch-datasource" + - "GF_INSTALL_PLUGINS=grafana-opensearch-datasource ${OPENSEARCH_IMAGE_VERSION}" volumes: - ./src/grafana/grafana.ini:/etc/grafana/grafana.ini - ./src/grafana/provisioning/:/etc/grafana/provisioning/ diff --git a/docker-compose.yml b/docker-compose.yml index cb91e09bc9..7580a96d4c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -707,7 +707,7 @@ services: memory: 100M restart: unless-stopped environment: - - "GF_INSTALL_PLUGINS=grafana-opensearch-datasource" + - "GF_INSTALL_PLUGINS=grafana-opensearch-datasource ${OPENSEARCH_IMAGE_VERSION}" volumes: - ./src/grafana/grafana.ini:/etc/grafana/grafana.ini - ./src/grafana/provisioning/:/etc/grafana/provisioning/ diff --git a/src/grafana/provisioning/datasources/opensearch.yaml b/src/grafana/provisioning/datasources/opensearch.yaml index 4d23b5f7b5..d1c1671762 100644 --- a/src/grafana/provisioning/datasources/opensearch.yaml +++ b/src/grafana/provisioning/datasources/opensearch.yaml @@ -17,4 +17,3 @@ datasources: logMessageField: body pplEnabled: true timeField: observedTimestamp - version: 2.16.0 From 4ee9f0c513e2f6c46a0ba82a700b1d969e22b63f Mon Sep 17 00:00:00 2001 From: Juliano Costa Date: Tue, 22 Oct 2024 10:47:11 +0200 Subject: [PATCH 3/4] [cartservice] Update cart service to fail when cartServiceFailure is enabled (#1748) * Update cart service to fail when cartServiceFailure is enabled * changelog --- CHANGELOG.md | 2 ++ src/cartservice/src/Dockerfile | 4 ++-- src/cartservice/src/cartservice.csproj | 20 ++++++++++---------- src/cartservice/src/services/CartService.cs | 3 +-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e55f3f5e51..faa6dcfde8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,8 @@ the release. ([#1733](https://github.com/open-telemetry/opentelemetry-demo/pull/1733)) * [chore] Move opensearch image version to .env file ([#1743](https://github.com/open-telemetry/opentelemetry-demo/pull/1743)) +* [cartservice] Update cart service to fail when cartServiceFailure is enabled + ([#1748](https://github.com/open-telemetry/opentelemetry-demo/pull/1748)) ## 1.11.1 diff --git a/src/cartservice/src/Dockerfile b/src/cartservice/src/Dockerfile index e2a12e7e78..812213bd5b 100644 --- a/src/cartservice/src/Dockerfile +++ b/src/cartservice/src/Dockerfile @@ -15,7 +15,7 @@ # limitations under the License. # https://mcr.microsoft.com/v2/dotnet/sdk/tags/list -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0.302 AS builder +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0.403 AS builder ARG TARGETARCH WORKDIR /usr/src/app/ @@ -30,7 +30,7 @@ RUN dotnet publish ./src/cartservice.csproj -v d -r linux-musl-$TARGETARCH --no- # ----------------------------------------------------------------------------- # https://mcr.microsoft.com/v2/dotnet/runtime-deps/tags/list -FROM mcr.microsoft.com/dotnet/runtime-deps:8.0.6-alpine3.20 +FROM mcr.microsoft.com/dotnet/runtime-deps:8.0.10-alpine3.20 WORKDIR /usr/src/app/ COPY --from=builder /cartservice/ ./ diff --git a/src/cartservice/src/cartservice.csproj b/src/cartservice/src/cartservice.csproj index ea7705e133..5b5e31373f 100644 --- a/src/cartservice/src/cartservice.csproj +++ b/src/cartservice/src/cartservice.csproj @@ -15,22 +15,22 @@ - - + + - - + + - - - - - - + + + + + + diff --git a/src/cartservice/src/services/CartService.cs b/src/cartservice/src/services/CartService.cs index ff0b32153a..7c16fce91d 100644 --- a/src/cartservice/src/services/CartService.cs +++ b/src/cartservice/src/services/CartService.cs @@ -62,8 +62,7 @@ public override async Task EmptyCart(EmptyCartRequest request, ServerCall try { - // Throw 1/10 of the time to simulate a failure when the feature flag is enabled - if (await _featureFlagHelper.GetBooleanValue("cartServiceFailure", false) && random.Next(10) == 0) + if (await _featureFlagHelper.GetBooleanValueAsync("cartServiceFailure", false)) { await _badCartStore.EmptyCartAsync(request.UserId); } From c79152c68a0121185e1d7ff0b4e26951b5bff3a5 Mon Sep 17 00:00:00 2001 From: Roger Coll Date: Tue, 22 Oct 2024 10:51:27 +0200 Subject: [PATCH 4/4] feat: propagate cartservice exceptions (#1744) * feat: propagate GetCart errors * feat: propagate AddItem errors --------- Co-authored-by: Juliano Costa --- CHANGELOG.md | 2 ++ src/cartservice/src/services/CartService.cs | 37 ++++++++++++++++----- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index faa6dcfde8..1ab0a2bcd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,8 @@ the release. ([#1733](https://github.com/open-telemetry/opentelemetry-demo/pull/1733)) * [chore] Move opensearch image version to .env file ([#1743](https://github.com/open-telemetry/opentelemetry-demo/pull/1743)) +* [cartservice] Propagate cartservice exceptions + ([#1744](https://github.com/open-telemetry/opentelemetry-demo/pull/1744)) * [cartservice] Update cart service to fail when cartServiceFailure is enabled ([#1748](https://github.com/open-telemetry/opentelemetry-demo/pull/1748)) diff --git a/src/cartservice/src/services/CartService.cs b/src/cartservice/src/services/CartService.cs index 7c16fce91d..d071c37080 100644 --- a/src/cartservice/src/services/CartService.cs +++ b/src/cartservice/src/services/CartService.cs @@ -33,8 +33,18 @@ public override async Task AddItem(AddItemRequest request, ServerCallCont activity?.SetTag("app.product.id", request.Item.ProductId); activity?.SetTag("app.product.quantity", request.Item.Quantity); - await _cartStore.AddItemAsync(request.UserId, request.Item.ProductId, request.Item.Quantity); - return Empty; + try + { + await _cartStore.AddItemAsync(request.UserId, request.Item.ProductId, request.Item.Quantity); + + return Empty; + } + catch (RpcException ex) + { + activity?.RecordException(ex); + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } public override async Task GetCart(GetCartRequest request, ServerCallContext context) @@ -43,15 +53,24 @@ public override async Task GetCart(GetCartRequest request, ServerCallConte activity?.SetTag("app.user.id", request.UserId); activity?.AddEvent(new("Fetch cart")); - var cart = await _cartStore.GetCartAsync(request.UserId); - var totalCart = 0; - foreach (var item in cart.Items) + try { - totalCart += item.Quantity; - } - activity?.SetTag("app.cart.items.count", totalCart); + var cart = await _cartStore.GetCartAsync(request.UserId); + var totalCart = 0; + foreach (var item in cart.Items) + { + totalCart += item.Quantity; + } + activity?.SetTag("app.cart.items.count", totalCart); - return cart; + return cart; + } + catch (RpcException ex) + { + activity?.RecordException(ex); + activity?.SetStatus(ActivityStatusCode.Error, ex.Message); + throw; + } } public override async Task EmptyCart(EmptyCartRequest request, ServerCallContext context)