perf: skip prod Docker steps on PRs, use larger runner#8057
perf: skip prod Docker steps on PRs, use larger runner#8057buger wants to merge 12 commits intorelease-5.12.1from
Conversation
<!-- Provide a general summary of your changes in the Title above -->
## Description
Fix a critical regression introduced in TT-16265 (unified path matching,
released in 5.12.0/5.8.12) where `validateRequest` and `mockResponse`
middleware on a parameterised OAS path (e.g. `/employees/{id}`)
incorrectly fires for requests to a static path (e.g.
`/employees/static`) that does not have that middleware configured.
The fix applies two changes at API load time (no request-time changes):
**Layer 1 — Path ordering:** Both `compileOASValidateRequestPathSpec`
and `compileOASMockResponsePathSpec` now sort their output using the
same algorithm as `oasutil.SortByPathLength` (used by Classic
middleware). This ensures deterministic ordering across gateway restarts
and places static paths before parameterised paths in the `rxPaths`
list. Previously, these functions iterated a Go map, producing
non-deterministic ordering.
**Option D — Synthetic shield entries:** For every static path in the
OAS spec that does NOT have `validateRequest` (or `mockResponse`)
configured, a disabled entry (`Enabled: false`) is injected into the
path list. Because static entries are sorted before parameterised ones,
`FindSpecMatchesStatus` matches the shield first. The middleware sees
`Enabled == false` and short-circuits — preventing the parameterised
regex from cross-matching.
A shared helper `addStaticPathShields` eliminates duplication between
the two compile functions. The sort comparator `PathLess` was extracted
from `oasutil.SortByPathLength` into an exported function, ensuring both
Classic and OAS middleware use the exact same ordering logic with no
risk of drift.
## Related Issue
TT-16890
Related tickets:
- TT-16265 (introduced the regression by unifying path matching)
- TT-16292 (OAS path parameter normalization — separate issue, not
addressed here)
## Motivation and Context
This regression is blocking a customer from upgrading to v5.12.x. In
5.11.x, `validateRequest` used the OAS router (kin-openapi) which
naturally prioritised static paths over parameterised paths. In 5.12.0,
it was moved to the standard regex-based path list to fix
inconsistencies with gateway path matching config. However, the regex
`([^/]+)` compiled from `{id}` matches any single-segment value
including `static`, causing cross-matching.
Additionally, the path list for OAS-specific middleware was built by
iterating a Go map without sorting, making the order non-deterministic
across gateway restarts — inconsistent with Classic middleware which
always sorts paths.
## How This Has Been Tested
**Unit tests:**
- `TestSortURLSpecsByPathPriority` — 5 table-driven cases verifying sort
correctness (static before parameterised, segment count, length,
alphabetical tiebreaker, mixed paths)
**Integration tests:**
- `TestStaticPathTakesPrecedenceOverParameterised` — Exact customer
scenario: `/employees/static` (no validateRequest) alongside
`/employees/{id}` (validateRequest with pattern `^[a-zA-Z]+$`).
Verifies:
- `GET /employees/static` → 200 (validateRequest does NOT fire)
- `GET /employees/john` → 200 (validateRequest fires, passes pattern)
- `GET /employees/123` → 422 (validateRequest fires, fails pattern)
- `TestMockResponseStaticPathPriority` — Same pattern for mockResponse:
`/items/special` (no mock) alongside `/items/{id}` (mock enabled).
Verifies static path does not return mock body.
- `TestStaticPathPriorityWithPrefixMatching` — Both paths have
validateRequest with different validators (header vs path param). With
`EnablePathPrefixMatching` enabled, verifies each path matches its own
validator.
**Benchmarks:**
- `BenchmarkSortURLSpecsByPathPriority` — Sort overhead at 10/50/200
paths (< 0.5ms even at 200 paths, runs only at API load time)
- `BenchmarkOASValidateRequestStaticVsParameterized` — Request-time
performance with 52 OAS paths: ~2.5µs/op, 26 allocs/op for both static
(shield hit) and parameterised (validation hit) paths — no measurable
overhead from shield entries
**Existing test suites:** All existing tests pass, including
`TestValidateRequest`, `TestValidateRequest_PrefixMatching`,
`TestValidateRequest_SuffixMatching`,
`TestValidateRequest_BothMatchingEnabled`,
`TestValidateRequest_PathParameters`,
`TestOASMockResponseUnifiedPathMatching`,
`TestOASPathMatchingRespectGatewayConfig`, and `TestSortByPathLength`.
## Screenshots (if appropriate)
## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Refactoring or add test (improvements in base code or adds test
coverage to functionality)
## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply -->
<!-- If there are no documentation updates required, mark the item as
checked. -->
<!-- Raise up any additional concerns not covered by the checklist. -->
- [ ] I ensured that the documentation is up to date
- [ ] I explained why this PR updates go.mod in detail with reasoning
why it's required
- [ ] I would like a code coverage CI quality gate exception and have
explained why
---------
Co-authored-by: Laurentiu <6229829+lghiur@users.noreply.github.com>
(cherry picked from commit a48ebe5)
<!-- Provide a general summary of your changes in the Title above --> [TT-16693](https://tyktech.atlassian.net/browse/TT-16693) [TT-16695](https://tyktech.atlassian.net/browse/TT-16695) [TT-16696](https://tyktech.atlassian.net/browse/TT-16696) ## Description When running tests that use the StartTest helper with `config.SlaveOptions.UseRPC` enabled, the gateway enters an "emergency mode" and the gateway falls back to loading API Definitions and Policies from a Redis backup instead of the master nodes. Because the entire test suite runs against a single shared Redis instance, tests running in parallel would often write to the same Redis keys. This created a race condition where a test could read data written by another test. The data, while often valid JSON, would have an incorrect structure for the context in which it was being read. The unmarshaling process would succeed but produce a slice containing nil values ([]model.MergedAPI{nil}). Subsequent code that did not anticipate these nil values would then panic, causing the test to fail unpredictably. Subsequently, the `prepareSpecs` function iterates over this slice and calls methods on the APIDefinition. This leads to a nil pointer dereference panic when it encounters one of the nil entries. ## List of change 1. Update dispatcher setup at tests to assign default func handlers and make code cleaner 2. Update the expected response values to provide better documentation 3. Add unique tags for RPC based tests to avoid fetching invalid values populated by other tests ## How This Has Been Tested This change is targeting flaky tests not the production code in particular ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [x] I ensured that the documentation is up to date - [x] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why <!---TykTechnologies/jira-linter starts here--> ### Ticket Details <details> <summary> <a href="https://tyktech.atlassian.net/browse/TT-16693" title="TT-16693" target="_blank">TT-16693</a> </summary> | | | |---------|----| | Status | In Code Review | | Summary | [CI GW] Failing Unit Test: TestProcessKeySpaceChanges_UserKeyReset | Generated at: 2026-03-10 06:40:24 </details> <!---TykTechnologies/jira-linter ends here--> [TT-16693]: https://tyktech.atlassian.net/browse/TT-16693?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TT-16695]: https://tyktech.atlassian.net/browse/TT-16695?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TT-16696]: https://tyktech.atlassian.net/browse/TT-16696?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: Vlad Zabolotnyi <vlad.z@tyk.io>
…5fd2348abc2f377e69ec6ec227b/TT-16890
…5fd2348abc2f377e69ec6ec227b/TT-16890
…5fd2348abc2f377e69ec6ec227b/TT-16890
…5fd2348abc2f377e69ec6ec227b/TT-16890
…5fd2348abc2f377e69ec6ec227b/TT-16890
- Use vars.BUILD_RUNNER (falls back to vars.DEFAULT_RUNNER) so the goreleaser job can use a larger runner (e.g. warp-8x-x64) without affecting other jobs - Skip prod Docker metadata + build-push steps entirely on non-tag builds (saves ~9 min of unnecessary multi-platform builds, SBOM, provenance, and cache export that ran with push=false) - Remove redundant cache-to from prod steps (CI steps already export) - Simplify prod push: to true since step only runs on tags now Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
API Changes no api changes detected |
|
This PR optimizes the Files Changed Analysis
Architecture & Impact Assessment
graph TD |
✅ Security Check PassedNo security issues found – changes LGTM. ✅ Performance Check PassedNo performance issues found – changes LGTM. ✅ Security Check PassedNo security issues found – changes LGTM. \n\n \n\n✅ Performance Check PassedNo performance issues found – changes LGTM. \n\nQuality Issues (2)
Powered by Visor from Probelabs Last updated: 2026-04-16T20:23:47.605Z | Triggered by: pr_updated | Commit: 3953c51 💡 TIP: You can chat with Visor using |
…5fd2348abc2f377e69ec6ec227b/TT-16890
…ec227b/TT-16890' into perf/goreleaser-optimization
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🚨 Jira Linter FailedCommit: The Jira linter failed to validate your PR. Please check the error details below: 🔍 Click to view error detailsNext Steps
This comment will be automatically deleted once the linter passes. |
|
Closing: test PR, served its purpose. Optimizations captured in gromit#453. |
Summary
Built on top of #8029 to test goreleaser performance optimizations before rolling them out via gromit.
Commit 1: skip prod Docker steps, larger runner
vars.BUILD_RUNNER || vars.DEFAULT_RUNNER— setBUILD_RUNNER=warp-8x-x64in repo variables to use 8 vCPUs for goreleaser (currently 4)cache-to: prod steps no longer export GHA cache (CI steps already do)Commit 2: skip fips/std CI Docker pushes on PRs, amd64-only for ee
Expected savings
CI/ECR ee image still builds on every PR (amd64-only) — fips and std CI images are skipped on PRs entirely. All images build fully on branch pushes and tag pushes.
Test plan
Gromit template PR: TykTechnologies/gromit#453
🤖 Generated with Claude Code