ci: Lint that every published host port is deconflicted under the port scheme

Đang mở
#1,515 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
docker-compose, shell, yaml
Lĩnh vực
ci-cd, devops, testing

Hướng nghiên cứu

Start with verify-common.sh for the port scheme and verify.sh plus the Docker Compose files for each in-scope example. Review the existing Bazel yq and jq rules, then decide how to extract and join their data while covering short and long port syntax. Done means Bazel lint checks the listed allocation and linkage failures, exposes the allocation table, and the runtime check verifies published ports after compose starts.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement

#1509 / #1513 audited every example's host ports against the CI port scheme (documented in verify-common.sh) and fixed the violations found. But every fix was by hand, and nothing stops the next example reintroducing one. The scheme only works if a port is both exported in verify.sh and consumed via ${PORT_<ROLE>:-default} in compose — and that linkage is currently unenforced.

Ways it silently breaks today:

  1. Compose publishes a bare NNNN:MMMM with no ${PORT_*} substitution → runs at a fixed, undeconflicted host port in CI (pre-#1513 state of filter-cc, wasm-cc, datadog-tracing, fault-injection).
  2. Compose has ${PORT_X:-default} but verify.sh never exports PORT_X → the user default wins in CI, bypassing the scheme.
  3. verify.sh exports PORT_X that no compose file references → dead export, misleading (was lua-cluster-specifier PORT_WEB).
  4. A new example picks a default in the wrong letter block, or one that collides with an existing example.

Proposal

Do this in Bazel, as the inputs are YAML. Use the existing yq/jq rules (@aspect_bazel_lib) rather than a standalone script, so the check runs as part of bazel test //... and lint CI with no new tooling.

Rough shape:

  • A yq target per example (or one glob) that converts every */docker-compose*.y*ml to JSON and extracts .services[].ports[] into a normalised {example, service, host, container, proto} list. Must handle long syntax, short syntax, and host_ip:host:container.
  • A small genrule/sh_test (or jq target) that greps each */verify.sh for export PORT_<ROLE>="${<EXAMPLE>_PORT_<ROLE>:-<ci-default>}" lines and emits them as JSON {example, role, override_var, ci_default}.
  • A jq target that joins the two and fails (non-zero exit via jq -e / error()) on any of:
    • compose host side not exactly ${PORT_<ROLE>:-<default>};
    • a compose <ROLE> with no matching verify.sh export;
    • a verify.sh export with no compose consumer (dead);
    • override_var ≠ upper-cased dir name (-/_ → _) + _PORT_<ROLE>;
    • ci_default outside 1LLBN for the dir's first letter;
    • two examples sharing a 1LLB block, or any two exports sharing an absolute default.
  • Examples with no verify.sh (grpc-bridge, locality-load-balancing) are in scope: any published host port is a failure.
  • Expose the joined JSON as a build artefact so bazel build //:port_allocations (or similar) prints the allocation table and free blocks per letter — replacing the hand-maintained tables in #1509/#1513.

Runtime check (secondary)

Static analysis won't see ports published via extends, override files, or network_mode: host. In verify-common.sh bring_up_example, after up, run docker compose ps --format json, collect every PublishedPort, and fail if any is not one of the exported PORT_* values. Cheap and catches anything the Bazel lint misses.

Out of scope

  • vrp-litmus / vrp-local — being removed.
  • filter-cc / wasm-cc run on a separate CI leg for build cost, not port reasons — they follow the scheme and are linted identically.
Ngôn ngữ chính
Shell
Star
75
Fork
39
Merge trung bình
1 ngày 9 giờ
Pull request đã merge (30 ngày)
31

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của envoyproxy/examples

Tất cả issue của envoyproxy/examples

Issue tương tự

Thêm issue về Shell/Bash

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.