feat(helm-reval): serve /info on the api port with consistent version and commit - #661
feat(helm-reval): serve /info on the api port with consistent version and commit#661priyaselvaganesan wants to merge 2 commits into
/info on the api port with consistent version and commit#661Conversation
📝 WalkthroughWalkthroughThe reval service now loads shared build metadata for ChangesVersion metadata and external
Estimated code review effort: 2 (Simple) | ~15 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant API_Router
participant PublicMiddleware
participant golibversion_Handler
Client->>API_Router: GET /info
API_Router->>PublicMiddleware: Apply observability and recovery middleware
PublicMiddleware->>golibversion_Handler: ServeHTTP
golibversion_Handler-->>Client: service, version, commit
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
tools/scripts/test/test-workspace-status.sh (1)
35-39: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winTest the
-dirtysuffix.The test covers only a clean fixture. It does not verify the new dirty-worktree behavior. A regression that removes
-dirtystill passes.Modify the fixture after capturing
full_sha, then assert thatSTABLE_GIT_COMMIT_FULLequals${full_sha}-dirty.As per coding guidelines, changed tool behavior requires focused tests.
Suggested assertion
full_sha="$(git -C "$fixture" rev-parse HEAD)" got_full="$( (cd "$fixture" && env -u NVCF_VERSION bash "$script") | awk '/^STABLE_GIT_COMMIT_FULL /{print $2}' )" [ "$got_full" = "$full_sha" ] || fail "STABLE_GIT_COMMIT_FULL -> '$got_full' (want $full_sha)" +dirty_marker="$fixture/.dirty-marker" +printf 'dirty\n' > "$dirty_marker" +got_dirty="$( (cd "$fixture" && env -u NVCF_VERSION bash "$script") | awk '/^STABLE_GIT_COMMIT_FULL /{print $2}' )" +[ "$got_dirty" = "${full_sha}-dirty" ] || fail "dirty STABLE_GIT_COMMIT_FULL -> '$got_dirty' (want ${full_sha}-dirty)"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tools/scripts/test/test-workspace-status.sh` around lines 35 - 39, Extend the test around full_sha in the workspace-status script to modify the fixture after capturing the clean commit hash, then invoke the script again and assert STABLE_GIT_COMMIT_FULL equals the original hash with the -dirty suffix. Preserve the existing clean-worktree assertion and use the existing fixture and extraction flow.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/control-plane-services/helm-reval/cmd/reval-service/main.go`:
- Around line 28-33: Update the version metadata initialization around Version
and GitCommit so explicit fallbacks are resolved once when build stamping is
absent, using the same values for NewRootCommand, CLI output, telemetry, and
/info. Preserve stamped values when present and reuse the resolved metadata
instead of allowing each consumer to resolve it independently.
In `@src/control-plane-services/helm-reval/cmd/reval/cli/server_internal_test.go`:
- Around line 114-122: Add a test covering the router wiring performed by
runServer: verify GET /info returns 200 through the API server and 404 through
the separate management-server handler, rather than testing serveInfo directly.
Use the repository-native test runner to execute the new coverage.
In `@src/control-plane-services/helm-reval/cmd/reval/cli/server.go`:
- Line 122: Update the route registration around serveInfo and the public
middleware setup so /info remains unauthenticated but passes through the same
structured logging, tracing, RED metrics, and recovery middleware as /v1,
explicitly excluding authzMiddleware. Ensure the middleware-wrapped route is
used for /info rather than registering it directly on the bare router.
---
Nitpick comments:
In `@tools/scripts/test/test-workspace-status.sh`:
- Around line 35-39: Extend the test around full_sha in the workspace-status
script to modify the fixture after capturing the clean commit hash, then invoke
the script again and assert STABLE_GIT_COMMIT_FULL equals the original hash with
the -dirty suffix. Preserve the existing clean-worktree assertion and use the
existing fixture and extraction flow.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: cb9cdcca-0010-4f7f-a4c2-b523bbe60397
📒 Files selected for processing (6)
src/control-plane-services/helm-reval/cmd/reval-service/BUILD.bazelsrc/control-plane-services/helm-reval/cmd/reval-service/main.gosrc/control-plane-services/helm-reval/cmd/reval/cli/server.gosrc/control-plane-services/helm-reval/cmd/reval/cli/server_internal_test.gotools/scripts/test/test-workspace-status.shtools/workspace_status.sh
56b62fd to
ce8d17c
Compare
/info on the api port with consistent version and commit
|
Do we need to protect new endpoint with some rate limiting feature as it does not require auth anymore? |
reval has no rate limiting on any endpoint today, and I would prefer keeping this PR scoped to the endpoint move and adding that as a follow-up. |
Why
The
/infobuild-info endpoint was mounted on the management port, so it was not reachable through the ingress, which routes to the traffic/API port. Consumers outside the cluster could not query the deployed build. The reported metadata was also inconsistent:/inforead the shared go-libversionpackage while logs and the OTelservice.versionreadmain.Version, and thecommitfield had regressed tounknown.What changed
GET /info(unauthenticated) on the API/traffic router via aserveInfohelper so it is reachable through the ingress./infothrough the shared observability middleware (metrics, tracing, logging, recovery) without authz, so it stays unauthenticated but is still metered, traced, logged, and panic-safe.main.Versionandmain.GitCommitfrom the shared go-libversionpackage, so/info, logs, and the OTelservice.versionall report the same build from a single link-time stamp.STABLE_GIT_COMMIT_FULLstamp key (full hash) to the sharedtools/workspace_status.sh, with a test. The revalversion.GitHashx_def references it, but the feat(bazel): consolidate every service into the root Bazel module #593 consolidation to a shared status script left it unemitted, so/inforeportedcommit: unknown.Customer Release Notes
The helm-reval
/infoendpoint is reachable externally and reports service name, build version, and full git commit consistently with logs and traces.Usage
curl http://<reval-host>/inforeturns{"service": ..., "version": ..., "commit": ...}.Testing
bazel test //src/control-plane-services/helm-reval/cmd/reval/cli:cli_testbash tools/scripts/test/test-workspace-status.sh/infothrough the Envoy gateway. Confirmedversionequals the OTelservice.versionandcommitequalsgit rev-parse HEAD(full hash), and that an unknown path returns reval's own 404, proving the request reaches the service unauthenticated through the ingress.Issues
Relates to #315