Skip to content

Commit 226f40e

Browse files
committed
merge: reconcile resource admission with current audit baseline
2 parents 1a6ded2 + 41c792d commit 226f40e

175 files changed

Lines changed: 14548 additions & 473 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/PULL_REQUEST_TEMPLATE.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
<!-- Describe your PR here; e.g. Fixes #issueNo -->
22

3+
## Problem and change
4+
5+
<!-- Explain the trigger and resulting behavior, material choices, compatibility
6+
and limitations. Link issues and any required unmerged PRs. Keep small
7+
changes brief. Use Fixes only when the issue is fully resolved. -->
8+
9+
## IssueSpec
10+
11+
<!-- Choose full or lightweight. Keep the metadata below as plain lines.
12+
See issue-spec/project/workflow.md for examples and maintainer classification.
13+
For lightweight, remove Proposal/Design/Implement/Specs/Tasks.
14+
For full, replace every reference and ID with the actual selected artifacts. -->
15+
IssueSpec-Mode: full | lightweight
16+
IssueSpec-Reason: describe the scope and why this mode applies
17+
IssueSpec-Proposal: #NUMBER
18+
IssueSpec-Design: #NUMBER
19+
IssueSpec-Implement: #NUMBER
20+
IssueSpec-Specs: SPEC-ID
21+
IssueSpec-Tasks: TASK-ID
22+
IssueSpec-Validation: describe checks, results and important checks not run
23+
324
<!--
425
Thank you for proposing a pull request. This template will guide you through the essential steps necessary for a pull request.
526
-->

‎.github/scripts/issue-spec-policy-test.mjs‎

Lines changed: 412 additions & 0 deletions
Large diffs are not rendered by default.

‎.github/scripts/issue-spec-policy.cjs‎

Lines changed: 335 additions & 0 deletions
Large diffs are not rendered by default.

‎.github/scripts/test-ci-workflows.mjs‎

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
// limitations under the License.
1515

1616
import assert from 'node:assert/strict';
17-
import { mkdtempSync, readFileSync, readdirSync, rmSync } from 'node:fs';
17+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
18+
import { createServer } from 'node:http';
1819
import { createRequire } from 'node:module';
1920
import { dirname, resolve } from 'node:path';
2021
import { fileURLToPath } from 'node:url';
2122
import vm from 'node:vm';
2223
import test from 'node:test';
23-
import { execFileSync } from 'node:child_process';
24+
import { execFile, execFileSync } from 'node:child_process';
25+
import { promisify } from 'node:util';
2426

2527
const root = resolve(dirname(fileURLToPath(import.meta.url)), '../..');
2628
const bundle = resolve(root, 'actions/paths-filter/dist/index.js');
@@ -204,3 +206,81 @@ test('aggregate jobs still report failures but do not keep cancelled PR runs ali
204206
assert.ok(!condition.includes('always()'), workflow);
205207
}
206208
});
209+
210+
test('ingress validates the Maven wrapper before its first Maven invocation', () => {
211+
const steps = workflows.get('integrated-test-k8s-ingress.yml').jobs.build.steps;
212+
const preflight = steps.findIndex(step => step.name === 'Ensure Maven wrapper JAR');
213+
const firstMaven = steps.findIndex(step => /\.\/mvnw\b/.test(step.run ?? ''));
214+
assert.ok(preflight >= 0 && firstMaven > preflight);
215+
assert.equal(steps[preflight].shell, 'bash');
216+
});
217+
218+
test('ingress Maven wrapper preflight handles cached, downloaded and failed artifacts', { timeout: 45000 }, async t => {
219+
const preflight = workflows.get('integrated-test-k8s-ingress.yml').jobs.build.steps
220+
.find(step => step.name === 'Ensure Maven wrapper JAR');
221+
assert.ok(preflight, 'The ingress job must validate the wrapper before running Maven');
222+
const temporary = mkdtempSync(resolve(root, '.github/scripts/.wrapper-test-'));
223+
t.after(() => rmSync(temporary, { recursive: true, force: true }));
224+
225+
// Only the archive/launcher-entry contract is under test; no Maven download is needed.
226+
const classes = resolve(temporary, 'classes');
227+
const launcher = 'org/apache/maven/wrapper/MavenWrapperMain.class';
228+
mkdirSync(dirname(resolve(classes, launcher)), { recursive: true });
229+
writeFileSync(resolve(classes, launcher), 'launcher entry fixture');
230+
const validJar = resolve(temporary, 'valid.jar');
231+
const otherJar = resolve(temporary, 'other.jar');
232+
execFileSync('jar', ['cf', validJar, '-C', classes, '.']);
233+
writeFileSync(resolve(classes, 'Other.class'), 'unrelated entry fixture');
234+
execFileSync('jar', ['cf', otherJar, '-C', classes, 'Other.class']);
235+
const valid = readFileSync(validJar);
236+
const corrupt = Buffer.from('incomplete cached download');
237+
const fixtures = [
238+
{ name: 'valid cache avoids downloading', initial: valid, requests: 0, succeeds: true },
239+
{ name: 'missing wrapper is downloaded', requests: 1, succeeds: true },
240+
{ name: 'corrupt cache is replaced', initial: corrupt, requests: 1, succeeds: true },
241+
{ name: 'two transient 503s are retried', failures: 2, requests: 3, succeeds: true },
242+
{ name: 'invalid download preserves the old file', initial: corrupt, payload: Buffer.from('not a jar'), requests: 1 },
243+
{ name: 'archive without launcher is rejected', payload: readFileSync(otherJar), requests: 1 },
244+
{ name: 'persistent 503s stop after bounded retries', failures: 6, initial: corrupt, requests: 6 },
245+
{ name: 'missing wrapper URL fails without a request', missingUrl: true, requests: 0 },
246+
];
247+
const run = promisify(execFile);
248+
for (const [index, fixture] of fixtures.entries()) {
249+
await t.test(fixture.name, async subtest => {
250+
const working = resolve(temporary, `case-${index}`);
251+
const wrapper = resolve(working, '.mvn/wrapper');
252+
const target = resolve(wrapper, 'maven-wrapper.jar');
253+
mkdirSync(wrapper, { recursive: true });
254+
if (fixture.initial) writeFileSync(target, fixture.initial);
255+
let requests = 0;
256+
const server = createServer((_request, response) => {
257+
requests += 1;
258+
response.writeHead(requests <= (fixture.failures ?? 0) ? 503 : 200);
259+
response.end(requests <= (fixture.failures ?? 0) ? 'unavailable' : fixture.payload ?? valid);
260+
});
261+
await new Promise((resolve, reject) => {
262+
server.once('error', reject);
263+
server.listen(0, '127.0.0.1', resolve);
264+
});
265+
subtest.after(() => new Promise((resolve, reject) => server.close(error => error ? reject(error) : resolve())));
266+
writeFileSync(resolve(wrapper, 'maven-wrapper.properties'), fixture.missingUrl
267+
? 'distributionUrl=unused\n'
268+
: `wrapperUrl=http://127.0.0.1:${server.address().port}/wrapper.jar\n`);
269+
const execution = run('bash', ['--noprofile', '--norc', '-e', '-o', 'pipefail', '-c', preflight.run], {
270+
cwd: working,
271+
env: { ...process.env, NO_PROXY: '127.0.0.1', no_proxy: '127.0.0.1' },
272+
timeout: 20000,
273+
});
274+
if (fixture.succeeds) {
275+
await execution;
276+
assert.deepEqual(readFileSync(target), valid);
277+
} else {
278+
await assert.rejects(execution, error => Number.isInteger(error.code) && error.code !== 0);
279+
if (fixture.initial) assert.deepEqual(readFileSync(target), fixture.initial);
280+
else assert.equal(existsSync(target), false);
281+
}
282+
assert.equal(requests, fixture.requests);
283+
assert.ok(readdirSync(wrapper).every(name => !name.startsWith('maven-wrapper.jar.')), 'Temporary downloads must be removed');
284+
});
285+
}
286+
});

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
- name: Test workflow scope and example image selection
6262
run: |
6363
node --test .github/scripts/test-ci-workflows.mjs
64+
node --test .github/scripts/issue-spec-policy-test.mjs
6465
python3 -B .github/scripts/test-resolve-example-projects.py
6566
python3 -B .github/scripts/test-actions-timings.py
6667
python3 -B .github/scripts/test-restore-shenyu-local-repo.py

‎.github/workflows/integrated-test-k8s-ingress.yml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,31 @@ jobs:
102102
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.24.14/bin/linux/amd64/kubectl && sudo install kubectl /usr/local/bin/kubectl
103103
kind create cluster --image=kindest/node:v1.21.1 --config=./shenyu-integrated-test/${{ matrix.case }}/deploy/kind-config.yaml
104104
105+
- name: Ensure Maven wrapper JAR
106+
shell: bash
107+
run: |
108+
wrapper_jar=.mvn/wrapper/maven-wrapper.jar
109+
wrapper_main=org/apache/maven/wrapper/MavenWrapperMain.class
110+
if [[ -r "$wrapper_jar" ]] && jar tf "$wrapper_jar" | grep -Fx "$wrapper_main" > /dev/null; then
111+
exit 0
112+
fi
113+
114+
wrapper_url="$(awk -F= '$1 == "wrapperUrl" { print substr($0, index($0, "=") + 1); exit }' .mvn/wrapper/maven-wrapper.properties)"
115+
if [[ -z "$wrapper_url" ]]; then
116+
echo "Could not find wrapperUrl in .mvn/wrapper/maven-wrapper.properties."
117+
exit 1
118+
fi
119+
120+
wrapper_tmp="$(mktemp .mvn/wrapper/maven-wrapper.jar.XXXXXX)"
121+
trap 'rm -f "$wrapper_tmp"' EXIT
122+
curl --fail --location --retry 5 --retry-all-errors --retry-delay 2 \
123+
--output "$wrapper_tmp" "$wrapper_url"
124+
if ! jar tf "$wrapper_tmp" | grep -Fx "$wrapper_main" > /dev/null; then
125+
echo "Downloaded Maven wrapper JAR does not contain $wrapper_main."
126+
exit 1
127+
fi
128+
mv "$wrapper_tmp" "$wrapper_jar"
129+
105130
- name: Build with Maven
106131
shell: bash
107132
run: |
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
name: IssueSpec Policy
17+
18+
# Only trusted default-branch code runs here. Candidate code is tested by ci.yml.
19+
on:
20+
pull_request_target:
21+
branches: [master]
22+
types: [opened, edited, synchronize, reopened, ready_for_review, labeled, unlabeled]
23+
issues:
24+
types: [edited, deleted, closed, reopened]
25+
issue_comment:
26+
types: [created, edited, deleted]
27+
workflow_dispatch:
28+
inputs:
29+
pull_request:
30+
description: Pull request number to re-evaluate
31+
required: true
32+
type: string
33+
34+
permissions: {}
35+
36+
jobs:
37+
discover:
38+
if: github.repository == 'apache/shenyu'
39+
runs-on: ubuntu-latest
40+
timeout-minutes: 5
41+
permissions:
42+
contents: read
43+
pull-requests: read
44+
outputs:
45+
pull_requests: ${{ steps.targets.outputs.pull_requests }}
46+
has_targets: ${{ steps.targets.outputs.has_targets }}
47+
steps:
48+
- uses: actions/checkout@v4
49+
with:
50+
ref: ${{ github.event.repository.default_branch }}
51+
persist-credentials: false
52+
- uses: actions/github-script@v7
53+
id: targets
54+
with:
55+
script: |
56+
const {discover} = require('./.github/scripts/issue-spec-policy.cjs');
57+
await discover({github, context, core});
58+
policy:
59+
needs: discover
60+
if: needs.discover.outputs.has_targets == 'true'
61+
runs-on: ubuntu-latest
62+
timeout-minutes: 20
63+
permissions:
64+
contents: read
65+
issues: read
66+
pull-requests: read
67+
checks: write
68+
strategy:
69+
fail-fast: false
70+
max-parallel: 4
71+
matrix:
72+
pull_request: ${{ fromJSON(needs.discover.outputs.pull_requests) }}
73+
concurrency:
74+
group: issue-spec-policy-${{ matrix.pull_request }}
75+
cancel-in-progress: false
76+
env:
77+
PULL_REQUEST_NUMBER: ${{ matrix.pull_request }}
78+
steps:
79+
- uses: actions/checkout@v4
80+
with:
81+
ref: ${{ github.event.repository.default_branch }}
82+
persist-credentials: false
83+
- uses: actions/github-script@v7
84+
id: prepare
85+
with:
86+
script: |
87+
const {prepare} = require('./.github/scripts/issue-spec-policy.cjs');
88+
await prepare({github, context, core, directory: process.env.RUNNER_TEMP,
89+
number: Number(process.env.PULL_REQUEST_NUMBER)});
90+
- uses: actions/setup-go@v5
91+
if: steps.prepare.outputs.needs_cli == 'true'
92+
with:
93+
go-version: '1.25.0'
94+
cache: false
95+
- name: Build the pinned IssueSpec CLI
96+
if: steps.prepare.outputs.needs_cli == 'true'
97+
env:
98+
ISSUE_SPEC_REVISION: ${{ steps.prepare.outputs.tool_revision }}
99+
GOBIN: ${{ runner.temp }}/issue-spec-bin
100+
run: go install "github.com/higress-group/issue-spec/cmd/issue-spec@${ISSUE_SPEC_REVISION}"
101+
- name: Publish advisory policy result
102+
if: always() && steps.prepare.outputs.prepared == 'true'
103+
uses: actions/github-script@v7
104+
env:
105+
GH_TOKEN: ${{ github.token }}
106+
with:
107+
script: |
108+
const {finish} = require('./.github/scripts/issue-spec-policy.cjs');
109+
await finish({github, context, core, directory: process.env.RUNNER_TEMP,
110+
number: Number(process.env.PULL_REQUEST_NUMBER),
111+
binary: process.env.RUNNER_TEMP + '/issue-spec-bin/issue-spec'});

‎AGENTS.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ make build-all-image VERSION="$SHENYU_VERSION"
4848
- **Surgical changes.** Follow surrounding style, remove code made unused by your change and leave unrelated cleanup out. Preserve public SPI, plugin names, configuration defaults and supported legacy behavior unless the task changes them. Trace affected plugin/selector/rule contracts through shared DTOs, Admin persistence/validation/events, sync, gateway consumers and starters; coordinate necessary changes and tests. Check maintained SQL dialects and upgrade paths when persistence or seed metadata changes.
4949
- **Goal-driven execution.** Define observable success; prefer a reproducing regression test for bugs and preserve externally observable behavior in refactors. Start with Maven-wrapper checks of affected modules/dependencies, then broaden according to risk and repository/CI requirements. Distinguish behavior tests from compilation or `-DskipTests` builds. For reactive changes, check affected subscription, completion/error/cancellation/backpressure and buffer/resource lifetimes. Verify cancellation follows resource ownership, including the original upstream call where applicable; headers, body completion and WebSocket session termination are distinct boundaries. Use factual/link/configuration checks for documentation changes. Report checks, results and material checks not run; existing Checkstyle, RAT/license and contribution requirements still apply.
5050

51+
## IssueSpec and pull requests
52+
53+
- Follow [the IssueSpec policy](issue-spec/project/workflow.md). New capabilities and changes to public SPI, configuration semantics, authorization or Admin-to-gateway contracts need a Proposal, Design, confirmed SPECs and implementation TASKs. Read the complete current Design and applicable decisions before implementing. Use the lightweight path for documentation, tests and behavior-preserving fixes; production fixes need the documented maintainer classification.
54+
- Read `issue-spec/config.yaml` and the guidance for the current phase. Keep durable behavior contracts in `issue-spec/specs/<capability>/spec.md` with their implementation. Record genuine unresolved decisions as blocking QUESTIONs; do not invent approval steps, require multiple agents or create PROCESSes for ordinary sequential work.
55+
- Use the checked-in PR template. Write a concrete title and lead the description with the problem and resulting behavior. Explain material choices, compatibility and remaining limitations; identify unmerged dependencies. Use `Fixes #...` only for issues fully resolved, and `Related to #...` for partial work. Keep one coherent change per PR, including the necessary cross-module changes.
56+
- Fill the IssueSpec metadata and verification description truthfully. Report commands, executed tests, results and important unrun checks; compilation and `-DskipTests` are not test execution. Keep the title, description and evidence aligned with the final diff. The advisory policy check validates planning metadata, not correctness, review approval or merge readiness.
57+
5158
## Architecture
5259

5360
ShenYu is split into a **control plane** and a **data plane** that communicate only through data-sync channels — the gateway never reads the database.

‎RELEASE-NOTES.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@
115115
the previous behavior with `shenyu.httpclient.keepAlive=false`.
116116
For a fixed pool, set `shenyu.httpclient.pool.maxConnections` explicitly to
117117
size the connection limit for the deployment; the default follows Reactor Netty.
118+
- Opt-in named upstream connection-pool groups are available through
119+
`shenyu.httpclient.pool-groups`. Groups must use the `FIXED` type, have an
120+
explicit unique name other than `shenyu-proxy`, and configure a positive
121+
`maxConnections` plus an omitted-or-positive `maxPendingAcquires` (at most 16
122+
groups). A divide rule selects one with `poolGroup`; an unknown group returns
123+
HTTP 503 instead of falling back. Definitions are read at startup only, and
124+
deployments without `pool-groups` keep the existing shared pool unchanged.
125+
Group metrics use Reactor Netty Micrometer meters when `metrics: true` and
126+
`micrometer-core` is present; they are not exported by the ShenYu Prometheus
127+
metrics endpoint in this release. See `docs/upstream-pool-groups.md`.
118128
- CORS origin patterns are compiled when the gateway starts. An invalid
119129
`shenyu.cross.allowed-origin.origin-regex` now fails startup with
120130
`PatternSyntaxException`, rather than failing the first matching request.
@@ -217,6 +227,20 @@
217227
aggregate and remains an explicit choice. See `shenyu-registry/README.md` for the
218228
provider table and migration steps. (#7578)
219229

230+
- The admin now validates the `sticky` section of a divide rule handle when a rule is
231+
saved: `onUnavailable` must be exactly `REBIND` or `STRICT`, `maxAgeSeconds` must be
232+
positive, `cookieName` must be a non-blank string (an explicit `null` is not accepted
233+
as a substitute for omitting it), an enabled configuration needs at least one non-blank
234+
`secrets` entry, and a configured deterministic `key` needs a non-blank `name` and,
235+
when `type` is present, `HEADER` or `COOKIE`. JSON structure is checked before Gson can
236+
coerce values, so a non-object `sticky`, a non-integer lifetime, a non-array secret
237+
list or a non-string field is rejected with a `sticky.…` field error. A disabled
238+
(`enabled=false`) sticky section is exempt from value validation, because the gateway
239+
activation checks ignore it and its values cannot affect a request, so an unrelated
240+
field of an already stored rule stays editable; structural type checks still apply.
241+
The gateway runtime stays tolerant for values: a configuration persisted before this
242+
validation still degrades to plain load balancing instead of failing requests. (#8037)
243+
220244
## [v2.7.0]- 2024-12-23
221245

222246
### ✨ New Features

0 commit comments

Comments
 (0)