Skip to content

Commit 8397cff

Browse files
author
Uwe Schwaeke
committed
fix(cli): baseline known failures; fix shared-pool attribution and tiny/IPv6 allocation
Review findings (comprehensive review of the open senolcolak PRs): - MEDIUM: nightly --strict was red on arrival because two known-failing cases are structurally unpassable (stub console 501; OSC 7.0.0 backup-show bug). - MEDIUM: the planned '>0 new known-failing blocks' guard did not exist, so a regression on any of the ~26 self-healing probes passed both gates. Add a checked-in baseline (test/cli/baseline/known_failures.txt); coverage.sh and run.sh --strict now fail on any known-failing not in it and warn on stale entries. Live: --fast --strict 244/242 pass, full --strict 251/249 pass, 2 baseline known-failing, exit 0; an empty baseline fails with both violations. - MEDIUM: List/GetSubnetPool rendered the caller's project as tenant_id for shared pools; both now select and render the row's owning project. - MEDIUM: allocateIP refused /30, /29 and all IPv6 pools as 'untenable'. Upstream Neutron allocates from them and fails only on exhaustion; the allocator now mirrors generate_pools() and never panics. Tests rewritten to assert allocation and a 201 from a tiny and an IPv6 pool. - Numbering: documents (does not change) the SPEC-028 / migration-074 collision with #108/#109 and the missing spec.md/tasks.md. Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>
1 parent 5708584 commit 8397cff

13 files changed

Lines changed: 550 additions & 122 deletions

File tree

‎docs/specs/028-cli-conformance-test-environment/plan.md‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,13 @@ developer reproduces CI exactly.
211211
**TDD note (Constitution Art. III)**: for the harness itself the "red" step is running each new case
212212
against a stub-mode server and confirming it exercises the endpoint (manifest entry flips to
213213
`tested`). Product defects the cases uncover are filed and either fixed or recorded as
214-
`known-failing` entries in the manifest — never silently tolerated by the gate (a `known-failing`
215-
count is reported and trended, and blocks release at >0 new).
214+
`known-failing` in the suite. Every known-failing case must also appear in the checked-in baseline
215+
`test/cli/baseline/known_failures.txt` with the reason it cannot pass against the pinned environment
216+
(stub-mode console; the OSC 7.0.0 backup-by-name client bug). `coverage.sh` and `run.sh --strict`
217+
fail on any known-failing case missing from that ledger, so a regression cannot hide as tracked
218+
debt; the "known-failing count" is reported and trended instead. A ledger entry that starts passing
219+
is a stale-baseline warning (never a failure). **Maintenance:** when a genuine divergence is fixed,
220+
remove its baseline entry — and if the suite probe self-heals, convert it to a plain assertion.
216221

217222
### Phase 2 — CI integration
218223

@@ -261,7 +266,7 @@ count is reported and trended, and blocks release at >0 new).
261266
|---|---|
262267
| CLI invocations are slow (~1-2s each; full matrix could be 600+ calls) | Tier split: curated PR subset, full matrix nightly; per-service parallel suites |
263268
| New CLI release changes output/behavior | Pinned `constraints.txt`; deliberate upgrade PRs |
264-
| Cases uncover real product bugs (likely — Cinder metadata/transfers already known weak) | Manifest `known-failing` state is explicit, counted, trended, and must shrink — not a silent 85% floor |
269+
| Cases uncover real product bugs (likely — Cinder metadata/transfers already known weak) | Every `known-failing` case is listed in the checked-in baseline with a reason; both gates fail on a new one, a stale entry only warns, and the count is visible — not a silent 85% floor |
265270
| Alpine runtime image differs from developers' environments | Same image already used in prod compose; local `make test-cli` uses the identical stack |
266271
| bash harness complexity grows | `report.sh` + strict `common.sh` from day one; revisit a Go/python runner only if suites exceed bash's comfort (~Tier C growth) |
267272

@@ -285,5 +290,15 @@ count is reported and trended, and blocks release at >0 new).
285290
because the issue's wording ("working binary") points at the artifact.
286291
3. **PR-time scope** — default: Tier A+B + 2-3 Tier C workflows (<10 min). Alternative: everything
287292
nightly-only — rejected; PRs should catch CLI breakage before merge.
288-
4. **Known-failing policy** — default: explicit manifest state with a must-shrink trend, no pass-rate
289-
floor. Alternative: an 85%-style threshold — rejected, it is how the Cinder debt went invisible.
293+
4. **Known-failing policy** — default: `known-failing` cases are explicit in the suite and must be
294+
listed in `test/cli/baseline/known_failures.txt` with a reason; new ones fail the gate, stale ones
295+
warn, no pass-rate floor. Alternative: an 85%-style threshold — rejected, it is how the Cinder
296+
debt went invisible.
297+
298+
## 9. Merge dependencies
299+
300+
- This PR claims **SPEC-028** and **migrations 074–078**. Open PRs #108/#109 also claim
301+
SPEC-028/029 and migration 074; whichever merges second must renumber its spec directory and
302+
migrations per the specs registry rule (never silently share numbers).
303+
- This specification is **plan.md-only** today (no `spec.md`/`tasks.md`). It needs those files or a
304+
documented plan-first carve-out before the registry can treat it as complete.

‎internal/neutron/ports.go‎

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ func (svc *Service) CreatePort(c *gin.Context) {
8585

8686
var fixedIPs []map[string]any
8787
if err == nil {
88-
// Allocate IP from subnet. A pool the allocator must refuse (/29-/30,
89-
// IPv6 with its int64 overflow) is a clean 400 — persisting a port
90-
// with a blank ip_address would be silent bad data (round 9).
88+
// Allocate IP from the subnet. Upstream allocates from /30, /31, /32
89+
// and IPv6 pools normally and only fails on exhaustion; "" therefore
90+
// means a genuinely unusable pool (bad CIDR/no address), never "too
91+
// small". Keep it a clean 400 rather than persisting a port with a
92+
// blank ip_address, which would be silent bad data (round 9).
9193
allocatedIP := allocateIP(cidr)
9294
if allocatedIP == "" {
9395
common.SendError(c, common.NewBadRequestError("subnet's cidr has no usable address for a port"))
@@ -715,39 +717,47 @@ func (svc *Service) UpdatePort(c *gin.Context) {
715717
svc.GetPort(c)
716718
}
717719

718-
// allocateIP allocates an IP from a CIDR range using cryptographically random offset
720+
// allocateIP allocates an IP from a CIDR range using a cryptographically
721+
// random offset. It mirrors upstream Neutron's generate_pools(): /30, /31 and
722+
// /32 (and every IPv6 subnet) are valid pools, network/broadcast are excluded
723+
// where they exist, and only an exhausted/invalid pool yields "" — the
724+
// callers' "no usable address". It must never panic: rand.Int panics on a
725+
// non-positive bound, so every span is guarded.
719726
func allocateIP(cidr string) string {
720727
_, ipNet, err := net.ParseCIDR(cidr)
721728
if err != nil {
722729
return ""
723730
}
724-
725-
// Count usable host addresses (excluding network and broadcast)
726731
ones, bits := ipNet.Mask.Size()
727732
hostBits := bits - ones
728-
if hostBits < 2 {
733+
if hostBits < 0 {
729734
return ""
730735
}
731-
maxOffset := int64(1<<uint(hostBits)) - 2 // exclude network(0) and broadcast
732-
733-
// Too-small pools and the IPv6 overflow both land here: for hostBits ≥ 64
734-
// (every IPv6 subnet) int64(1<<hostBits) overflows to 0, making
735-
// maxOffset negative; /30 and /29 make maxOffset-10 negative or zero.
736-
// rand.Int PANICS on a non-positive bound (surfacing as a 500 via the
737-
// recovery middleware) — refuse those subnets with the empty string the
738-
// callers already treat as "no usable address".
739-
if maxOffset <= 10 {
736+
isV4 := ipNet.IP.To4() != nil
737+
var lo, span int64
738+
switch {
739+
case isV4 && hostBits == 0: // /32: single address
740+
lo, span = 0, 1
741+
case isV4 && ones >= 31: // /31: both addresses usable
742+
lo, span = 0, 2
743+
case isV4: // exclude network and broadcast
744+
lo, span = 1, (int64(1)<<uint(hostBits))-2
745+
case hostBits == 0: // IPv6 /128
746+
lo, span = 0, 1
747+
case hostBits >= 32: // IPv6: bounded random window inside the subnet
748+
lo, span = 1, 1<<32
749+
default: // small IPv6 subnet: first+1 .. last
750+
lo, span = 1, (int64(1)<<uint(hostBits))-1
751+
}
752+
if span <= 0 {
740753
return ""
741754
}
742-
743-
n, err := rand.Int(rand.Reader, big.NewInt(maxOffset-10))
744-
offset := uint(10) // fallback to offset 10 if rand fails
755+
n, err := rand.Int(rand.Reader, big.NewInt(span))
756+
offset := lo
745757
if err == nil {
746-
offset = uint(n.Int64() + 10)
758+
offset += n.Int64()
747759
}
748-
749-
ip := incrementIP(ipNet.IP, offset)
750-
return ip.String()
760+
return incrementIP(ipNet.IP, uint(offset)).String()
751761
}
752762

753763
// Security Groups implementation

‎internal/neutron/router.go‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,10 @@ func (svc *Service) AddRouterInterface(c *gin.Context) {
584584

585585
// A subnet without a gateway (an explicit null clears it, S14) used to
586586
// 500 here: the scan above targeted a plain string and NULL cannot land
587-
// in one. Upstream never refuses — the interface attaches with an
588-
// address from the subnet — so a NULL gateway falls back to the same
589-
// allocator CreatePort uses (SPEC-028).
587+
// in one. Upstream never refuses a usable pool — /30, /31, /32 and IPv6
588+
// subnets all allocate — so a NULL gateway falls back to the same
589+
// allocator CreatePort uses, and only an exhausted/invalid CIDR is a
590+
// clean 400 (SPEC-028).
590591
if gatewayIP == nil {
591592
allocated := allocateIP(cidr)
592593
if allocated == "" {

0 commit comments

Comments
 (0)