Skip to content

fix bug - #3120

Open
tharindu1st wants to merge 1 commit into
wso2:mainfrom
tharindu1st:config-dump-disable
Open

fix bug#3120
tharindu1st wants to merge 1 commit into
wso2:mainfrom
tharindu1st:config-dump-disable

Conversation

@tharindu1st

Copy link
Copy Markdown
Contributor

fix bug

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@tharindu1st, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 10 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f448b9f0-cc14-4bfb-9c4d-cd347302ea61

📥 Commits

Reviewing files that changed from the base of the PR and between 067f59f and 6f36a61.

📒 Files selected for processing (28)
  • gateway/configs/config-template.toml
  • gateway/configs/config.toml
  • gateway/distribution/docker-compose.yaml
  • gateway/docker-compose-perf.yaml
  • gateway/docker-compose.debug.yaml
  • gateway/gateway-controller/pkg/adminserver/server.go
  • gateway/gateway-controller/pkg/adminserver/server_test.go
  • gateway/gateway-controller/pkg/config/config.go
  • gateway/gateway-runtime/docker-entrypoint-debug.sh
  • gateway/gateway-runtime/docker-entrypoint.sh
  • gateway/gateway-runtime/health-check.sh
  • gateway/gateway-runtime/policy-engine/internal/admin/server.go
  • gateway/gateway-runtime/policy-engine/internal/admin/server_test.go
  • gateway/gateway-runtime/policy-engine/internal/config/config.go
  • gateway/gateway-runtime/router/config/envoy-bootstrap.yaml
  • gateway/it/docker-compose.test.postgres.yaml
  • gateway/it/docker-compose.test.sqlserver.yaml
  • gateway/it/docker-compose.test.vhosts-multi.yaml
  • gateway/it/docker-compose.test.vhosts-single.yaml
  • gateway/it/docker-compose.test.yaml
  • gateway/it/test-config.toml
  • gateway/it/test-config.vhosts-multi.toml
  • gateway/it/test-config.vhosts-single.toml
  • kubernetes/gateway-operator/internal/controller/resources/api-platform-gateway-k8s-manifests.yaml
  • kubernetes/helm/gateway-helm-chart/README.md
  • kubernetes/helm/gateway-helm-chart/templates/gateway/gateway-config.yaml
  • kubernetes/helm/gateway-helm-chart/templates/gateway/gateway-runtime/deployment.yaml
  • kubernetes/helm/gateway-helm-chart/values.yaml
📝 Walkthrough

Walkthrough

The change adds explicit gating for controller and policy-engine /config_dump endpoints. It makes the Envoy router admin interface opt-in, updates health checks and shutdown behavior, and wires the settings through Compose, Helm, Kubernetes, and integration-test configurations.

Changes

Admin endpoint controls

Layer / File(s) Summary
Config-dump contracts and enforcement
gateway/gateway-controller/pkg/config/config.go, gateway/gateway-controller/pkg/adminserver/*, gateway/gateway-runtime/policy-engine/internal/config/config.go, gateway/gateway-runtime/policy-engine/internal/admin/*, gateway/configs/*
Controller and policy-engine config dumps now use explicit enabled settings. Disabled requests return 404. Tests cover disabled defaults and enabled access.
Router admin runtime flow
gateway/gateway-runtime/docker-entrypoint*.sh, gateway/gateway-runtime/health-check.sh, gateway/gateway-runtime/router/config/envoy-bootstrap.yaml
The Envoy admin listener is injected only when ROUTER_ADMIN_ENABLED=true. Health checks use /ready when enabled and a TCP check otherwise. Shutdown skips graceful draining when admin access is disabled.
Deployment, integration, and documentation wiring
gateway/docker-compose*.yaml, gateway/distribution/docker-compose.yaml, gateway/it/*, kubernetes/helm/gateway-helm-chart/*, kubernetes/gateway-operator/...
Compose and integration-test environments enable the required admin interfaces. Helm values and templates default the controls to disabled. Kubernetes service exposure no longer publishes port 9901. Documentation describes the settings and defaults.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DockerEntrypoint
  participant Envoy
  participant HealthCheck
  participant AdminServer
  DockerEntrypoint->>Envoy: Inject admin listener when enabled
  HealthCheck->>Envoy: Use /ready or TCP fallback
  AdminServer-->>AdminServer: Gate /config_dump by enabled setting
  DockerEntrypoint->>Envoy: Request graceful drain when admin is enabled
Loading

Possibly related PRs

Suggested reviewers: krishanx92, piumal1999, thushani-jayasekera

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description contains only "fix bug" and omits all required template sections, including purpose, goals, approach, tests, security checks, and environment. Complete the repository template with the purpose, goals, implementation approach, documentation, tests, security checks, related PRs, and test environment.
Docstring Coverage ⚠️ Warning Docstring coverage is 64.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title "fix bug" is too generic and does not identify the configuration or admin endpoint changes. Use a specific title that summarizes the main change, such as "Gate admin configuration dump and Envoy admin endpoints by default".
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
gateway/gateway-runtime/policy-engine/internal/admin/server_test.go (1)

79-79: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add disabled-state coverage for /config_dump.

The changed test verifies only the enabled route. Add a separate test that leaves ConfigDump.Enabled false and asserts that /config_dump returns HTTP 404. This protects the fail-closed default.

🤖 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 `@gateway/gateway-runtime/policy-engine/internal/admin/server_test.go` at line
79, Add a separate test function that verifies the disabled-state behavior of
the /config_dump endpoint. In this new test, set ConfigDump.Enabled to false in
the configuration, then make a request to /config_dump and assert that it
returns HTTP 404. This ensures the endpoint properly enforces the fail-closed
default when the feature is disabled.
🤖 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 `@gateway/gateway-runtime/docker-entrypoint.sh`:
- Around line 184-193: Enforce loopback-only Router admin binding before
generating the admin configuration in the ROUTER_ADMIN_ENABLED branch of
gateway/gateway-runtime/docker-entrypoint.sh and the corresponding branch at
gateway/gateway-runtime/docker-entrypoint-debug.sh; reject non-loopback
ROUTER_ADMIN_HOST values. Update the debug entrypoint’s loopback documentation
to match the enforced behavior. In kubernetes/helm/gateway-helm-chart/README.md,
do not describe the admin interface as loopback-only unless both entrypoints
enforce that boundary.

In `@gateway/gateway-runtime/health-check.sh`:
- Around line 32-46: Remove the HTTP listener TCP fallback from the
ROUTER_ADMIN_ENABLED=false branch of health-check.sh, since it cannot establish
Envoy readiness. Use a genuine Envoy readiness check instead, or separate the
probe behavior so TCP is used only for liveness and readiness validates loaded
routes, clusters, listeners, and ext_proc configuration.

In
`@kubernetes/gateway-operator/internal/controller/resources/api-platform-gateway-k8s-manifests.yaml`:
- Around line 37-40: Update the Deployment readiness and liveness probes near
the existing port 9901 `/ready` checks to target a listener that is enabled and
reachable, such as the runtime health endpoint or a TCP probe on the HTTP
listener. Do not rely on the disabled or loopback-only Envoy admin listener
unless the Deployment explicitly enables and locally exposes it.

---

Nitpick comments:
In `@gateway/gateway-runtime/policy-engine/internal/admin/server_test.go`:
- Line 79: Add a separate test function that verifies the disabled-state
behavior of the /config_dump endpoint. In this new test, set ConfigDump.Enabled
to false in the configuration, then make a request to /config_dump and assert
that it returns HTTP 404. This ensures the endpoint properly enforces the
fail-closed default when the feature is disabled.
🪄 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: Pro Plus

Run ID: 34116d44-b762-4c78-be7c-afb6645f9a24

📥 Commits

Reviewing files that changed from the base of the PR and between e498dd0 and 067f59f.

📒 Files selected for processing (29)
  • gateway/configs/config-template.toml
  • gateway/configs/config.toml
  • gateway/distribution/docker-compose.yaml
  • gateway/docker-compose-perf.yaml
  • gateway/docker-compose.debug.yaml
  • gateway/docker-compose.yaml
  • gateway/gateway-controller/pkg/adminserver/server.go
  • gateway/gateway-controller/pkg/adminserver/server_test.go
  • gateway/gateway-controller/pkg/config/config.go
  • gateway/gateway-runtime/docker-entrypoint-debug.sh
  • gateway/gateway-runtime/docker-entrypoint.sh
  • gateway/gateway-runtime/health-check.sh
  • gateway/gateway-runtime/policy-engine/internal/admin/server.go
  • gateway/gateway-runtime/policy-engine/internal/admin/server_test.go
  • gateway/gateway-runtime/policy-engine/internal/config/config.go
  • gateway/gateway-runtime/router/config/envoy-bootstrap.yaml
  • gateway/it/docker-compose.test.postgres.yaml
  • gateway/it/docker-compose.test.sqlserver.yaml
  • gateway/it/docker-compose.test.vhosts-multi.yaml
  • gateway/it/docker-compose.test.vhosts-single.yaml
  • gateway/it/docker-compose.test.yaml
  • gateway/it/test-config.toml
  • gateway/it/test-config.vhosts-multi.toml
  • gateway/it/test-config.vhosts-single.toml
  • kubernetes/gateway-operator/internal/controller/resources/api-platform-gateway-k8s-manifests.yaml
  • kubernetes/helm/gateway-helm-chart/README.md
  • kubernetes/helm/gateway-helm-chart/templates/gateway/gateway-config.yaml
  • kubernetes/helm/gateway-helm-chart/templates/gateway/gateway-runtime/deployment.yaml
  • kubernetes/helm/gateway-helm-chart/values.yaml

Comment on lines +184 to +193
# The admin interface has no entry in the static bootstrap (envoy-bootstrap.yaml) at all, so
# it only exists when explicitly opted into here — bound to ROUTER_ADMIN_HOST (loopback by
# default), never 0.0.0.0, so it is unreachable outside the pod's network namespace regardless.
if [ "${ROUTER_ADMIN_ENABLED}" = "true" ]; then
CONFIG_OVERRIDE="${CONFIG_OVERRIDE}
admin:
address:
socket_address:
address: ${ROUTER_ADMIN_HOST}
port_value: ${ROUTER_ADMIN_PORT}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate files =="
git ls-files | rg '(^gateway/gateway-runtime/docker-entrypoint(.*\.sh)?$|^kubernetes/helm/gateway-helm-chart/README.md$|^gateway/it/docker-compose.*\.ya?ml$)' || true

echo
echo "== entrypoint relevant sections =="
for f in gateway/gateway-runtime/docker-entrypoint.sh gateway/gateway-runtime/docker-entrypoint-debug.sh; do
  if [ -f "$f" ]; then
    echo "--- $f defaults/usages ---"
    rg -n 'ROUTER_ADMIN_(ENABLED|HOST|PORT)|routerAdminEnabled|admin_server|admin:' "$f" -C 3 || true
    echo
  fi
done

echo
echo "== compose relevant admin exposure =="
for f in gateway/it/docker-compose.test.yaml gateway/it/docker-compose.test.vhosts-single.yaml; do
  if [ -f "$f" ]; then
    echo "--- $f ---"
    rg -n 'routerAdmin|9901|admin|host|ports:' "$f" -C 4 || true
  fi
done

echo
echo "== helm values/schema references =="
fd -i 'values.*\.ya?ml|schema\.json|README\.md' kubernetes/helm/gateway-helm-chart gateway -d 3 | xargs -r rg -n 'routerAdminEnabled|routerAdminHost|admin_server|9901|config_dump' -C 3 || true

echo
echo "== shell-like validation impact probe =="
python3 - <<'PY'
from pathlib import Path
for path in [
    Path("gateway/gateway-runtime/docker-entrypoint.sh"),
    Path("gateway/gateway-runtime/docker-entrypoint-debug.sh"),
]:
    text = path.read_text()
    snippet = text[text.find("if [ \"${ROUTER_ADMIN_ENABLED}\" = \"true\" ];"):text.find("fi", text.find("if [ \"${ROUTER_ADMIN_HOST}\"", text.find("if [ \"${ROUTER_ADMIN_ENABLED}\" = \"true\" ];")) if "if [ \"${ROUTER_ADMIN_HOST}\"" in text[text.find("if [ \"${ROUTER_ADMIN_ENABLED}\" = \"true\" ];"):] else -1)+1] if "if [ \"${ROUTER_ADMIN_ENABLED}\" = \"true\" ]; else " in text[text.find("if [ \"${ROUTER_ADMIN_ENABLED}\" = \"true\" ];"):] else text[text.find("if [ \"${ROUTER_ADMIN_ENABLED}\" = \"true\" ];"):text.find("\n\ncat", text.find("if [ \"${ROUTER_ADMIN_ENABLED}\" = \"true\" ];"))]]
    print(f"{path}:")
    print(text[text.find("if [ \"${ROUTER_ADMIN_ENABLED}\" = \"true\" ];"):].split("\n\n",1)[0][:800])
PY

Repository: wso2/api-platform

Length of output: 35046


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== admin host source/defaults =="
rg -n 'ROUTER_ADMIN_(ENABLED|HOST|PORT)|gateway\.gatewayRuntime\.deployment\.env\.routerAdmin|deployment\.env:' gateway kubernetes -C 4 || true

echo
echo "== compose explicit non-localhost exposure =="
python3 - <<'PY'
from pathlib import Path
for path in Path("gateway/it").glob("docker-compose*.yaml"):
    text = path.read_text()
    lines = text.splitlines()
    for i,l in enumerate(lines, 1):
        if "9901:9901" in l:
            print(path, i, l.strip())
    for i,l in enumerate(lines, 1):
        if "ROUTER_ADMIN_HOST" in l:
            print(path, i, l.strip())
PY

Repository: wso2/api-platform

Length of output: 31399


Security Misconfiguration (CWE-16)

Reachability: Internal

Reachability path
● Entry
  gateway/gateway-runtime/docker-entrypoint-debug.sh:220
  shutdown
│
▼
● Sink
  gateway/gateway-runtime/docker-entrypoint.sh

Enforce or accurately document the Router admin bind boundary.

ROUTER_ADMIN_HOST is documented as loopback-only but is accepted as-is when ROUTER_ADMIN_ENABLED=true; a non-loopback value makes the enabled Envoy admin listener reachable over any network path. Reject non-loopback values before writing admin.address in both gateway/gateway-runtime/docker-entrypoint.sh and gateway/gateway-runtime/docker-entrypoint-debug.sh; update gateway/gateway-runtime/docker-entrypoint-debug.sh’s loopback claim accordingly. Do not document Envoy admin in kubernetes/helm/gateway-helm-chart/README.md as loopback-only unless the entrypoints enforce that boundary.

📍 Affects 3 files
  • gateway/gateway-runtime/docker-entrypoint.sh#L184-L193 (this comment)
  • gateway/gateway-runtime/docker-entrypoint-debug.sh#L145-L153
  • kubernetes/helm/gateway-helm-chart/README.md#L168-L168
🤖 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 `@gateway/gateway-runtime/docker-entrypoint.sh` around lines 184 - 193, Enforce
loopback-only Router admin binding before generating the admin configuration in
the ROUTER_ADMIN_ENABLED branch of gateway/gateway-runtime/docker-entrypoint.sh
and the corresponding branch at
gateway/gateway-runtime/docker-entrypoint-debug.sh; reject non-loopback
ROUTER_ADMIN_HOST values. Update the debug entrypoint’s loopback documentation
to match the enforced behavior. In kubernetes/helm/gateway-helm-chart/README.md,
do not describe the admin interface as loopback-only unless both entrypoints
enforce that boundary.

Comment on lines +32 to +46
# Check Router (Envoy) readiness.
# The admin interface (/ready) is disabled by default (see docker-entrypoint.sh /
# ROUTER_ADMIN_ENABLED) — fall back to a raw TCP check against the main listener,
# which confirms Envoy is up and accepting connections.
if [ "${ROUTER_ADMIN_ENABLED}" = "true" ]; then
ROUTER_STATUS=$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:${ROUTER_ADMIN_PORT}/ready")
if [ "$ROUTER_STATUS" != "200" ]; then
echo "Router not ready (HTTP ${ROUTER_STATUS})"
exit 1
fi
else
if ! (exec 3<>"/dev/tcp/127.0.0.1/${ROUTER_HTTP_PORT}") 2>/dev/null; then
echo "Router not accepting connections on port ${ROUTER_HTTP_PORT}"
exit 1
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== file header and relevant lines =="
sed -n '1,90p' gateway/gateway-runtime/health-check.sh 2>/dev/null || true

echo
echo "== references to health-check/router ports/admin =="
rg -n "health-check|ROUTER_ADMIN_ENABLED|ROUTER_ADMIN_PORT|ROUTER_HTTP_PORT|readiness|liveness|/dev/tcp|/ready|curl" gateway -S || true

echo
echo "== files mentioning envoy readiness/admin routes =="
rg -n "ready|admin|readiness|Envoy" -S gateway/gateway-runtime gateway 2>/dev/null | head -200 || true

Repository: wso2/api-platform

Length of output: 46070


Do not use the HTTP listener connection as a readiness probe.

health-check.sh is used by Kubernetes readiness probes, but the ROUTER_ADMIN_ENABLED=false path returns healthy after a TCP connection to 127.0.0.1:${ROUTER_HTTP_PORT}. A listening port does not prove Envoy has loaded usable routes, clusters, listeners, or the ext_proc policy engine. Use a real readiness check for readiness, or split liveness/readiness probes so this TCP fallback is not used as readiness.

🤖 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 `@gateway/gateway-runtime/health-check.sh` around lines 32 - 46, Remove the
HTTP listener TCP fallback from the ROUTER_ADMIN_ENABLED=false branch of
health-check.sh, since it cannot establish Envoy readiness. Use a genuine Envoy
readiness check instead, or separate the probe behavior so TCP is used only for
liveness and readiness validates loaded routes, clusters, listeners, and
ext_proc configuration.

Comment on lines +37 to +40
# Envoy admin (9901) is intentionally NOT published here — it's disabled by
# default in the image (ROUTER_ADMIN_ENABLED=false) and, even when enabled,
# binds loopback-only; publishing it on a Service would defeat that. See
# kubernetes/helm/gateway-helm-chart's expose.routerAdmin (default false).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Change the probes to use a listener that remains enabled.

The runtime defaults ROUTER_ADMIN_ENABLED to false, but this Deployment still probes /ready on port 9901 at Lines 268-289. No listener exists, so the pod can fail readiness and liveness checks. If administration is enabled later, the default 127.0.0.1 bind is still unreachable from a kubelet probe sent to the pod IP. Use the runtime health check or a TCP probe on the HTTP listener, or explicitly configure a local probe and enable the admin listener.

🤖 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
`@kubernetes/gateway-operator/internal/controller/resources/api-platform-gateway-k8s-manifests.yaml`
around lines 37 - 40, Update the Deployment readiness and liveness probes near
the existing port 9901 `/ready` checks to target a listener that is enabled and
reachable, such as the runtime health endpoint or a TCP probe on the HTTP
listener. Do not rely on the disabled or loopback-only Envoy admin listener
unless the Deployment explicitly enables and locally exposes it.

@tharindu1st
tharindu1st force-pushed the config-dump-disable branch from 067f59f to 6f36a61 Compare August 4, 2026 12:34
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.

1 participant