Skip to content

Conversation

@tolgaozen
Copy link
Member

@tolgaozen tolgaozen commented Oct 27, 2025

…ion to v1.4.9

Summary by CodeRabbit

  • Chores

    • Version bumped to v1.4.9
    • Updated service health check mechanism for improved reliability and monitoring accuracy
    • Enhanced deployment infrastructure with additional tools and optimizations
  • Tests

    • Added comprehensive test coverage validating request deduplication and multi-tenant isolation behavior

@coderabbitai
Copy link

coderabbitai bot commented Oct 27, 2025

Walkthrough

Version bumped from v1.4.8 to v1.4.9 across metadata and API documentation. Dockerfile configured to build and install grpc-health-probe binary. Health check updated to use grpc_health_probe targeting port 3478. Comprehensive test suite added for singleflight tenant-isolation behavior. Code comments added for clarity, and debug logging removed.

Changes

Cohort / File(s) Summary
Version Metadata Bump
internal/info.go, docs/api-reference/apidocs.swagger.json, docs/api-reference/openapiv2/apidocs.swagger.json, proto/base/v1/openapi.proto
Version constant and API metadata bumped from v1.4.8 to v1.4.9
Docker Image & Health Probe
Dockerfile.local, docker-compose.yaml
Added grpc package and git to dependencies; implemented build and installation of grpc-health-probe binary; updated healthcheck to use grpc_health_probe at port 3478; configured runtime with /app working directory and air entrypoint
Singleflight Test Suite
internal/storage/decorators/singleflight/singleflight_test.go, internal/storage/decorators/singleflight/data_reader_test.go, internal/storage/decorators/singleflight/schema_reader_test.go
Comprehensive test suite validating tenant isolation and deduplication behavior: concurrent requests per tenant are deduplicated to single delegate call; different tenants are isolated; sequential requests bypass deduplication
Code Refinement
internal/storage/decorators/singleflight/data_reader.go, internal/storage/decorators/singleflight/schema_reader.go, internal/storage/postgres/utils/common.go
Clarifying comments added to singleflight functions; debug logging removed from SnapshotQuery

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Dockerfile.local — Multi-stage grpc-health-probe build process requires verification of CGO flags, clone/build logic, and binary path correctness
  • docker-compose.yaml — Health check endpoint and port change (3476 → 3478) should be verified against service configuration
  • Singleflight test files — Review test logic for concurrent map access, tenant isolation assertions, and deduplication verification across multiple test cases
  • Version metadata consistency — Ensure v1.4.9 is applied uniformly across all API/documentation files

Possibly related PRs

  • #2577: Overlaps on same version metadata files and internal/storage/postgres/utils/common.go (SnapshotQuery logging removal)
  • #2064: Modifies grpc-health-probe provisioning strategy in Docker build
  • #2560: Version metadata bumps across internal/info.go and OpenAPI/Swagger files

Poem

🐰 From v1.4.8 we hop to new ground,
A health probe built in Docker's round.
Tests ensure tenants stay apart,
Each one isolated, playing their part!
🏥✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "feat(docker): add grpc-health-probe for health checks and update vers…" directly aligns with the primary changes in this changeset. The main modifications across Dockerfile.local and docker-compose.yaml implement grpc-health-probe to replace curl-based health checks and change the health check port, while the version is bumped from v1.4.8 to v1.4.9 across multiple files. The title accurately captures these core objectives, uses clear conventional commit formatting, and is specific enough to convey the essential changes. While the PR also includes complementary test additions for singleflight deduplication behavior and minor logging/comment updates, these are supporting changes rather than the primary focus, which the title appropriately prioritizes.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch update-docker-compose-healthcheck

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
Dockerfile.local (1)

6-12: Consider pinning grpc-health-probe to a specific version.

The Dockerfile clones grpc-health-probe from the main branch without specifying a version or commit SHA. This could lead to non-reproducible builds if the upstream repository changes.

Consider pinning to a specific version or commit:

 # Build grpc-health-probe
 WORKDIR /tmp
-RUN git clone https://github.com/grpc-ecosystem/grpc-health-probe.git && \
+RUN git clone --depth 1 --branch v0.4.35 https://github.com/grpc-ecosystem/grpc-health-probe.git && \
     cd grpc-health-probe && \
     CGO_ENABLED=0 go install -a -tags netgo -ldflags=-w && \
     cp /go/bin/grpc-health-probe /usr/local/bin/grpc_health_probe && \
     cd / && rm -rf /tmp/grpc-health-probe

This ensures reproducible builds and prevents unexpected breakage from upstream changes.

internal/storage/decorators/singleflight/data_reader_test.go (1)

43-43: Consider making test delays configurable or environment-aware.

The hardcoded 10ms sleep simulates work but could cause flaky tests in slower CI environments or under load. While this is acceptable for local development tests, consider if the delay is necessary or if there are alternative ways to test the deduplication behavior.

If timing becomes an issue, you could use channels or other synchronization primitives instead of sleep:

 func (m *MockDataReader) HeadSnapshot(ctx context.Context, tenantID string) (token.SnapToken, error) {
 	// Track call count per tenant
 	m.mu.Lock()
 	counter, exists := m.headSnapshotCalls[tenantID]
 	if !exists {
 		counter = new(int64)
 		m.headSnapshotCalls[tenantID] = counter
 	}
 	m.mu.Unlock()
 
 	// Increment call count
 	atomic.AddInt64(counter, 1)
 
-	// Simulate some work
-	time.Sleep(10 * time.Millisecond)
+	// Brief yield to allow concurrent goroutines to pile up
+	runtime.Gosched()
 
 	return token.NoopToken{Value: "snapshot-" + tenantID}, nil
 }
internal/storage/decorators/singleflight/schema_reader_test.go (1)

42-42: Same timing consideration as in data_reader_test.go.

The 10ms sleep could potentially cause flaky tests in slower environments. See the comment in data_reader_test.go for suggested alternatives if this becomes an issue.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c219fe8 and 458bcc7.

⛔ Files ignored due to path filters (1)
  • pkg/pb/base/v1/openapi.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (12)
  • Dockerfile.local (1 hunks)
  • docker-compose.yaml (1 hunks)
  • docs/api-reference/apidocs.swagger.json (1 hunks)
  • docs/api-reference/openapiv2/apidocs.swagger.json (1 hunks)
  • internal/info.go (1 hunks)
  • internal/storage/decorators/singleflight/data_reader.go (1 hunks)
  • internal/storage/decorators/singleflight/data_reader_test.go (1 hunks)
  • internal/storage/decorators/singleflight/schema_reader.go (1 hunks)
  • internal/storage/decorators/singleflight/schema_reader_test.go (1 hunks)
  • internal/storage/decorators/singleflight/singleflight_test.go (1 hunks)
  • internal/storage/postgres/utils/common.go (0 hunks)
  • proto/base/v1/openapi.proto (1 hunks)
💤 Files with no reviewable changes (1)
  • internal/storage/postgres/utils/common.go
🧰 Additional context used
🧬 Code graph analysis (2)
internal/storage/decorators/singleflight/data_reader_test.go (2)
internal/storage/storage.go (1)
  • NoopDataReader (42-42)
internal/storage/decorators/singleflight/data_reader.go (2)
  • DataReader (15-18)
  • NewDataReader (21-23)
internal/storage/decorators/singleflight/schema_reader_test.go (2)
internal/storage/storage.go (1)
  • NoopSchemaReader (124-124)
internal/storage/decorators/singleflight/schema_reader.go (2)
  • SchemaReader (14-17)
  • NewSchemaReader (20-22)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Analyze (go)
  • GitHub Check: Test with Coverage
  • GitHub Check: Test with Coverage
🔇 Additional comments (12)
internal/storage/decorators/singleflight/schema_reader.go (1)

46-46: LGTM! Good clarification.

The inline comment clearly explains the tenant isolation mechanism in the singleflight deduplication pattern, improving code maintainability.

docs/api-reference/apidocs.swagger.json (1)

6-6: Version bump looks good.

The API documentation version is correctly updated to v1.4.9, consistent with the version changes in other files.

internal/info.go (1)

26-26: Version constant updated correctly.

The primary version identifier is now v1.4.9, which will be reflected in the application banner and aligns with the version metadata in API documentation.

proto/base/v1/openapi.proto (1)

12-12: OpenAPI version metadata updated consistently.

The proto annotation version matches the application version (v1.4.9), ensuring consistency between the codebase and generated API documentation.

Dockerfile.local (1)

4-4: Git dependency added for grpc-health-probe build.

The addition of git is necessary for cloning the grpc-health-probe repository. This is a minimal change for the build process.

internal/storage/decorators/singleflight/data_reader.go (1)

57-57: Good documentation of tenant isolation behavior.

The added comment clarifies that tenantID is used as the deduplication key, ensuring proper tenant isolation. This is important context for understanding the singleflight behavior in a multi-tenant system.

internal/storage/decorators/singleflight/singleflight_test.go (1)

1-13: Clean test suite setup.

The test file correctly sets up a Ginkgo test suite for the singleflight package. The structure is standard and appropriate.

internal/storage/decorators/singleflight/data_reader_test.go (2)

16-46: Well-designed mock with proper concurrency handling.

The MockDataReader correctly uses:

  • Per-tenant call tracking with a mutex-protected map
  • Atomic operations for thread-safe counter increments
  • Embedded NoopDataReader for default implementations

57-181: Comprehensive test coverage for singleflight behavior.

The test suite effectively validates:

  • Deduplication of concurrent requests for the same tenant
  • Proper isolation between different tenants
  • Correct results returned to each tenant
  • No deduplication for sequential requests

This provides strong confidence in the singleflight decorator's correctness.

internal/storage/decorators/singleflight/schema_reader_test.go (2)

15-45: Consistent mock implementation pattern.

The MockSchemaReader follows the same well-designed pattern as MockDataReader, with proper concurrency handling using mutexes and atomic operations. This consistency makes the test suite easier to understand and maintain.


56-180: Thorough test coverage for SchemaReader singleflight behavior.

The test suite validates the same critical behaviors as the DataReader tests:

  • Concurrent request deduplication per tenant
  • Cross-tenant isolation
  • Correct version strings per tenant
  • Sequential request handling

The parallel test structure across both reader types provides confidence in the singleflight decorator's general correctness.

docker-compose.yaml (1)

15-15: No issues found. The healthcheck configuration is correct.

The verification confirms:

  • Port 3478 is the correct and consistent gRPC service port throughout the codebase (default address configured in pkg/grpcserver/server.go)
  • The -addr flag format is valid; grpc_health_probe accepts both space-separated (-addr localhost:3478) and equals-separated (-addr=127.0.0.1:3478) syntax
  • The grpc-health-probe binary is properly installed from the grpc-ecosystem repository in Dockerfile.local
  • The distinction between port 3476 (HTTP/REST API) and 3478 (gRPC) is maintained correctly throughout the codebase

@tolgaozen tolgaozen merged commit b313991 into master Oct 27, 2025
12 of 14 checks passed
@tolgaozen tolgaozen deleted the update-docker-compose-healthcheck branch October 27, 2025 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants