Skip to content

Conversation

@achernev
Copy link

@achernev achernev commented Jan 5, 2026

What type of PR is this?
This implements an existing API.

What this PR does / why we need it:
This change wires in the existing API for configuring TLS when obtaining WASM code from a remote source. It covers both HTTP and OCI sources, and expands the feature to support ClusterTrustBundles alongside ConfigMaps and Secrets.

The only change under /api is to remove the +notImplementedHide flags from the WasmCodeSourceTLSConfig parts of the configuration.

Which issue(s) this PR fixes:
Fixes #4466.

Release Notes: Yes

@achernev
Copy link
Author

achernev commented Jan 6, 2026

Tested and working with the following (certain elements removed for brevity):

apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyExtensionPolicy
spec:
  wasm:
    - name: wasm-image-test
      code:
        type: Image
        image:
          url: registry.example.com/library/wasm-filter:latest
          tls:
            caCertificateRef:
              name: existing-cluster-trust-bundle
              group: ""
              kind: ClusterTrustBundle

@zhaohuabing
Copy link
Member

zhaohuabing commented Jan 6, 2026

@achernev Thanks for picking this up!

Can we add an e2e test for the https wasm source?
You need to modify the existing test/e2e/testdata/wasm-oci.yaml, and you can find an example of setting TLS for e2e in test/e2e/testdata/jwt-backend-remote-jwks.yaml .

@achernev
Copy link
Author

achernev commented Jan 6, 2026

@zhaohuabing Will do. A couple of questions:

  • What's the best way to run these myself? Is there a Makefile target or something?
  • Should I use the envoyproxy/gateway-static-file-server for serving the WASM?

@zhaohuabing
Copy link
Member

zhaohuabing commented Jan 6, 2026

@zhaohuabing Will do. A couple of questions:

  • What's the best way to run these myself? Is there a Makefile target or something?

You should be able to run WASM e2e test using " E2E_RUN_TEST=WasmHTTPCodeSource make e2e", it'll create a local kind cluster, install EG, and run the test.

  • Should I use the envoyproxy/gateway-static-file-server for serving the WASM?

Yes, you can modify the existing test:
test/e2e/testdata/wasm-oci.yaml
test/e2e/tests/wasm_http.go

@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 51.23457% with 79 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.70%. Comparing base (d8283d0) to head (bc561d7).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
internal/provider/kubernetes/indexers.go 7.50% 32 Missing and 5 partials ⚠️
internal/provider/kubernetes/controller.go 48.00% 23 Missing and 3 partials ⚠️
internal/provider/kubernetes/predicates.go 0.00% 10 Missing and 1 partial ⚠️
internal/wasm/httpfetcher.go 86.66% 1 Missing and 1 partial ⚠️
internal/wasm/imagefetcher.go 77.77% 1 Missing and 1 partial ⚠️
internal/wasm/cache.go 80.00% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (51.23%) is below the target coverage (60.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7865      +/-   ##
==========================================
- Coverage   72.82%   72.70%   -0.13%     
==========================================
  Files         235      235              
  Lines       35176    35332     +156     
==========================================
+ Hits        25618    25688      +70     
- Misses       7743     7817      +74     
- Partials     1815     1827      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@netlify
Copy link

netlify bot commented Jan 7, 2026

Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit e8b6457
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6969bbb16d0f550008bdb347
😎 Deploy Preview https://deploy-preview-7865--cerulean-figolla-1f9435.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@achernev
Copy link
Author

achernev commented Jan 7, 2026

@zhaohuabing Added an HTTP TLS e2e test. Had to expand the resource indexer a bit to include objects referenced by the code source configuration because it was only considering ConfigMaps from the LUA section.
The test uses a ConfigMap as cert source but I also tried using a Secret; both work fine. Also ran the full e2e suite which also ran fine with:

E2E_TIMEOUT=90m ENABLE_CLUSTER_TRUST_BUNDLE=true KIND_NODE_TAG=v1.35.0 NUM_WORKERS=2 make e2e

With regard to the Codecov report: the lines not covered by tests are the fallback to an empty cert pool when x509.SystemCertPool() returns an error. I'm not even sure how to emulate an error when calling x509.SystemCertPool. Ideas? Can we overlook this?

Signed-off-by: Anton Chernev <[email protected]>
@achernev
Copy link
Author

achernev commented Jan 9, 2026

@zhaohuabing Regarding the failing test called TestE2E/WeightedRoute/MixedValidAndInvalid: This one is runs for 50 requests, expecting that the result is within +/-3 of 90% of the number of requests, i.e. 50 * 0.9 = 45, lower bound 42, upper bound 48. The test failed because it got 49 successful requests, which is above the upper bound. However, with 50 requests, offset of 3, and a binomial distribution (200/500), there is always a non-zero chance that the result would be out-of-bounds (~84% pass rate, 1 in 6 fails). It would be helpful to raise the offset a bit to mitigate (but not eliminate) the chance of failures (offset 5 would mean ~98.4% pass rate, 1 in 60, offset 7 would mean ~99.9% pass rate, 1 in 1000). This actually failed once for me whilst running this exact test on my own machine, passed the second time.

This is to say nothing of the fact that the logic in AlmostEquals appears to be flipped: it is applying the offset to the actual and not the expect:

func AlmostEquals(actual, expect, offset int) bool {
	upper := actual + offset
	lower := actual - offset
	if expect < lower || expect > upper {
		return false
	}
	return true
}

With this run's success number (49), that means that the numbers are: upper = 49 + 3 = 52, lower = 49 - 3 = 46, expect = 50 * 0.9 = 45, 45 < 46 is still a fail, hence the outcome.

I am not sure why the TestE2E/RateLimitMethodMatch/matched_method_can_got_limited test failed.

@zhaohuabing
Copy link
Member

Hi @achernev No worries. These tests are flaky and they are not related to this PR. I'll review the PR later when I get a moment. Thanks for your patience!

@achernev
Copy link
Author

@zhaohuabing Apologies for the delay here. I've fixed the test that broke and added a couple more to cover for most of the changes in the indexer.

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.

Allow to pull wasm image from insecure registry while using envoy extension policy

2 participants