envoyproxy / gateway

Manages Envoy Proxy as a Standalone or Kubernetes-based Application Gateway
https://gateway.envoyproxy.io
Apache License 2.0
1.71k stars 393 forks source link

Make healthz server port in file-provider configurable #5149

Open shawnh2 opened 2 weeks ago

shawnh2 commented 2 weeks ago

When ran the script make go.test.coverage as is, got the same error as in the CI right now:

--- FAIL: TestNamespaceSelectorProvider (6.11s)
    kubernetes_test.go:1338: 
                Error Trace:    /home/eshaan/Documents/projects/gateway/internal/provider/kubernetes/kubernetes_test.go:1338
                Error:          Received unexpected error:
                                failed to create manager: error listening on :8081: listen tcp :8081: bind: address already in use

but when I modified the definition of the same to use only 1 process (via the -p 1 argument)

.PHONY: go.test.coverage
go.test.coverage: go.test.cel ## Run go unit and integration tests in GitHub Actions
    @$(LOG_TARGET)
    KUBEBUILDER_ASSETS="$(shell $(tools/setup-envtest) use $(ENVTEST_K8S_VERSION) -p path)" \
        go test ./... --tags=integration -race -coverprofile=coverage.xml -covermode=atomic -p 1

the same completes without any errors!

Logs ``` make[1]: Entering directory '/home/eshaan/Documents/projects/gateway' ===========> Running generate-gwapi-manifests ... curl -sLo /home/eshaan/Documents/projects/gateway/bin/gatewayapi-crds.yaml https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.1/experimental-install.yaml mv /home/eshaan/Documents/projects/gateway/bin/gatewayapi-crds.yaml charts/gateway-helm/crds/gatewayapi-crds.yaml ===========> Running manifests ... tools/bin/controller-gen crd:allowDangerousTypes=true paths="./api/..." output:crd:artifacts:config=charts/gateway-helm/crds/generated ===========> Running go.test.cel ... Run CEL Validation on k8s 1.29.4 ok github.com/envoyproxy/gateway/test/cel-validation11.289s Run CEL Validation on k8s 1.30.3 ok github.com/envoyproxy/gateway/test/cel-validation11.742s Run CEL Validation on k8s 1.31.0 ok github.com/envoyproxy/gateway/test/cel-validation11.453s Run CEL Validation on k8s 1.32.0 ok github.com/envoyproxy/gateway/test/cel-validation11.309s ===========> Running go.test.coverage ... KUBEBUILDER_ASSETS="/home/eshaan/.local/share/kubebuilder-envtest/k8s/1.29.4-linux-amd64" \ go test ./... --tags=integration -race -coverprofile=coverage.xml -covermode=atomic -p 1 ? github.com/envoyproxy/gateway [no test files] ? github.com/envoyproxy/gateway/api [no test files] github.com/envoyproxy/gateway/api/v1alpha1coverage: 0.0% of statements ok github.com/envoyproxy/gateway/api/v1alpha1/validation1.074s coverage: 91.0% of statements github.com/envoyproxy/gateway/cmd/egctl coverage: 0.0% of statements github.com/envoyproxy/gateway/cmd/envoy-gatewaycoverage: 0.0% of statements ok github.com/envoyproxy/gateway/internal/admin 1.101scoverage: 57.1% of statements ok github.com/envoyproxy/gateway/internal/cmd 3.121scoverage: 37.5% of statements ok github.com/envoyproxy/gateway/internal/cmd/egctl21.959s coverage: 38.3% of statements github.com/envoyproxy/gateway/internal/cmd/envoy coverage: 0.0% of statements github.com/envoyproxy/gateway/internal/cmd/options coverage: 0.0% of statements github.com/envoyproxy/gateway/internal/cmd/version coverage: 0.0% of statements ok github.com/envoyproxy/gateway/internal/crypto 2.911scoverage: 67.0% of statements github.com/envoyproxy/gateway/internal/envoygateway coverage: 0.0% of statements ok github.com/envoyproxy/gateway/internal/envoygateway/config 1.124s coverage: 90.0% of statements ok github.com/envoyproxy/gateway/internal/envoygateway/config/loader 4.147scoverage: 77.5% of statements ok github.com/envoyproxy/gateway/internal/extension/registry 2.712s coverage: 14.0% of statements ? github.com/envoyproxy/gateway/internal/extension/types[no test files] ok github.com/envoyproxy/gateway/internal/filewatcher1.033s coverage: 93.4% of statements ok github.com/envoyproxy/gateway/internal/gatewayapi24.080s coverage: 91.2% of statements github.com/envoyproxy/gateway/internal/gatewayapi/conformance coverage: 0.0% of statements ok github.com/envoyproxy/gateway/internal/gatewayapi/resource 4.387s coverage: 9.2% of statements ok github.com/envoyproxy/gateway/internal/gatewayapi/runner 2.485s coverage: 36.5% of statements ok github.com/envoyproxy/gateway/internal/gatewayapi/status 1.130s coverage: 56.2% of statements ok github.com/envoyproxy/gateway/internal/globalratelimit/runner 2.487s coverage: 40.5% of statements github.com/envoyproxy/gateway/internal/infrastructure coverage: 0.0% of statements github.com/envoyproxy/gateway/internal/infrastructure/common coverage: 0.0% of statements ok github.com/envoyproxy/gateway/internal/infrastructure/host 1.903s coverage: 19.1% of statements ok github.com/envoyproxy/gateway/internal/infrastructure/kubernetes 2.722scoverage: 65.5% of statements ok github.com/envoyproxy/gateway/internal/infrastructure/kubernetes/proxy 2.898scoverage: 87.0% of statements ok github.com/envoyproxy/gateway/internal/infrastructure/kubernetes/ratelimit 2.420s coverage: 87.4% of statements ok github.com/envoyproxy/gateway/internal/infrastructure/kubernetes/resource 1.086s coverage: 93.5% of statements github.com/envoyproxy/gateway/internal/infrastructure/runner coverage: 0.0% of statements ok github.com/envoyproxy/gateway/internal/ir 1.126scoverage: 17.5% of statements github.com/envoyproxy/gateway/internal/kubernetes coverage: 0.0% of statements ok github.com/envoyproxy/gateway/internal/logging 1.082scoverage: 95.0% of statements ok github.com/envoyproxy/gateway/internal/message 3.113scoverage: 45.6% of statements ok github.com/envoyproxy/gateway/internal/metrics 1.163scoverage: 35.6% of statements ? github.com/envoyproxy/gateway/internal/provider [no test files] ok github.com/envoyproxy/gateway/internal/provider/file35.825s coverage: 87.8% of statements ok github.com/envoyproxy/gateway/internal/provider/kubernetes 35.421s coverage: 55.0% of statements github.com/envoyproxy/gateway/internal/provider/kubernetes/test coverage: 0.0% of statements github.com/envoyproxy/gateway/internal/provider/runner coverage: 0.0% of statements github.com/envoyproxy/gateway/internal/troubleshoot coverage: 0.0% of statements github.com/envoyproxy/gateway/internal/troubleshoot/collect coverage: 0.0% of statements ok github.com/envoyproxy/gateway/internal/utils 1.085scoverage: 64.3% of statements ok github.com/envoyproxy/gateway/internal/utils/env1.022s coverage: 100.0% of statements ok github.com/envoyproxy/gateway/internal/utils/field1.023s coverage: 78.8% of statements ok github.com/envoyproxy/gateway/internal/utils/file1.020s coverage: 78.6% of statements ok github.com/envoyproxy/gateway/internal/utils/helm1.123s coverage: 10.4% of statements ok github.com/envoyproxy/gateway/internal/utils/jsonpatch1.092s coverage: 87.7% of statements ok github.com/envoyproxy/gateway/internal/utils/naming1.027s coverage: 100.0% of statements github.com/envoyproxy/gateway/internal/utils/net coverage: 0.0% of statements ok github.com/envoyproxy/gateway/internal/utils/path1.026s coverage: 73.1% of statements github.com/envoyproxy/gateway/internal/utils/proto coverage: 0.0% of statements github.com/envoyproxy/gateway/internal/utils/protocov coverage: 0.0% of statements github.com/envoyproxy/gateway/internal/utils/ratelimit coverage: 0.0% of statements ok github.com/envoyproxy/gateway/internal/utils/regex1.017s coverage: 100.0% of statements ok github.com/envoyproxy/gateway/internal/utils/slice1.018s coverage: 100.0% of statements ok github.com/envoyproxy/gateway/internal/wasm 28.293scoverage: 86.6% of statements ok github.com/envoyproxy/gateway/internal/xds/bootstrap1.491s coverage: 84.1% of statements github.com/envoyproxy/gateway/internal/xds/cache coverage: 0.0% of statements ? github.com/envoyproxy/gateway/internal/xds/extensions[no test files] github.com/envoyproxy/gateway/internal/xds/filters coverage: 0.0% of statements ok github.com/envoyproxy/gateway/internal/xds/server/runner 3.144s coverage: 12.3% of statements ok github.com/envoyproxy/gateway/internal/xds/translator5.325s coverage: 83.9% of statements ok github.com/envoyproxy/gateway/internal/xds/translator/runner 2.691s coverage: 69.2% of statements ok github.com/envoyproxy/gateway/internal/xds/types1.150s coverage: 89.4% of statements github.com/envoyproxy/gateway/internal/xds/utils coverage: 0.0% of statements github.com/envoyproxy/gateway/proto/extensioncoverage: 0.0% of statements github.com/envoyproxy/gateway/test/e2e/testscoverage: 0.0% of statements github.com/envoyproxy/gateway/test/utils/kubernetes coverage: 0.0% of statements github.com/envoyproxy/gateway/test/utils/prometheus coverage: 0.0% of statements make[1]: Leaving directory '/home/eshaan/Documents/projects/gateway' ```

_Originally posted by @EshaanAgg in https://github.com/envoyproxy/gateway/pull/5126#discussion_r1929479266_


We need to make the healthz server port configurable, for now it is a static port 8081, may cause port conflicts problem when running k8s provider test in CI.

EshaanAgg commented 2 weeks ago

I would like to work on this issue!

arkodg commented 5 days ago

@shawnh2 is this a clean up issue or is there a user need to make this configurable ?

shawnh2 commented 5 days ago

@shawnh2 is this a clean up issue or is there a user need to make this configurable ?

is a clean-up issue

arkodg commented 5 days ago

Can we fix the clean up w/o updating API atm ?

shawnh2 commented 3 days ago

making the healthz server port for standalone provider configurable sounds like a reasonable request to me, the port on host may be occupied by other programs if user is running eg in standalone mode, make it confgurable can let users to use other port for healthz server.

arkodg commented 1 day ago

sure, we'll then need to think through it, gather data to see if we need a top level ports or not, and what else may go in there, no objection to this, but its going to take more time