You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "efegokdemir (via GitHub)" <gi...@apache.org> on 2026/09/23 11:16:43 UTC
[PR] Fix fractional upstream timeout translation [apisix-ingress-controller]
efegokdemir opened a new pull request, #2894:
URL: https://github.com/apache/apisix-ingress-controller/pull/2894
### Type of change:
- [x] Bugfix
- [x] CI/CD or Tests
### What this PR does / why we need it:
Fixes #2879.
Timeout values are represented as durations in the Kubernetes resources but were truncated to integers before being sent to ADC. A 500ms timeout became 0 and was rejected by APISIX, blocking synchronization. The ADC timeout model now preserves fractional seconds, while zero-valued policy fields continue to use the documented 60-second default.
### Changes
- Represent ADC timeout seconds as `float64`.
- Preserve fractional seconds in ApisixUpstream, ApisixRoute, BackendTrafficPolicy and ingress translation.
- Add regression coverage for fractional values and zero-policy defaults.
### Pre-submission checklist:
- [x] Explained the problem and solution.
- [x] Added corresponding test cases.
- [x] Backward-compatible wire representation: JSON remains numeric seconds, now retaining decimals.
### Testing
- `go test ./internal/adc/translator -run Test... -count=1` — PASS; fails before the fix and passes after it.
- `go test ./internal/adc/translator -count=1` — PASS.
- `go vet ./internal/adc/translator` — PASS.
- `go test ./api/... ./internal/... ./pkg/...` — PASS.
- `gofmt` and `git diff --check` — PASS.
- `golangci-lint run ./internal/adc/translator/...` — reports existing unrelated `goconst`/`prealloc` findings outside this change.
- `go test ./...` was not completed because it began expanding into heavyweight e2e/AWS dependency downloads; the relevant API, internal and package suites passed.
No overlapping open PR was found for #2879 or sub-second timeout translation. AI assistance was used to inspect the issue, draft the focused implementation and tests, and prepare this description; the submitting human is responsible for reviewing the changed lines and validation results.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix fractional upstream timeout translation [apisix-ingress-controller]
Posted by "AlinsRan (via GitHub)" <gi...@apache.org>.
AlinsRan commented on PR #2894:
URL: https://github.com/apache/apisix-ingress-controller/pull/2894#issuecomment-6333715346
Please add non-negative timeout validation for ApisixRoute. `buildTimeout` currently uses `cmp.Or`, which only replaces zero: `-500ms` previously became the 60-second fallback after integer truncation, but this change sends `-0.5` to ADC. APISIX rejects non-positive timeout values. ApisixUpstream already checks for negative durations in its translator; ApisixRoute does not.
CEL can reject these inputs at CRD admission. I verified the following field-level marker on `UpstreamTimeout.Connect`, `Read`, and `Send`:
```go
// +kubebuilder:validation:XValidation:rule="duration(self) >= duration('0s')",message="timeout must not be negative"
```
Using `>=` preserves the existing behavior where zero selects the default timeout. The shared type propagates the rule into the ApisixRoute and ApisixUpstream CRDs, including the upstream port-level settings.
Validation against PR head `c37d5ac064cd644f488dfdf6654c6cad7bc07e29`:
- Regenerated the CRDs with the repository's controller-gen v0.17.2.
- The generated CRDs passed Kubernetes `ValidateCustomResourceDefinition` validation.
- OpenAPI and CEL validation tests passed for all three timeout fields on ApisixRoute and ApisixUpstream: `-500ms` and `-1s` are rejected; `0s`, `0`, `1ms`, `500ms`, `1.5s`, and `1m30s` are accepted; malformed and empty strings are rejected; omitted fields are accepted.
- Example error: `spec.http[0].timeout.connect: Invalid value: "-500ms": timeout must not be negative`.
These tests used the Kubernetes validation libraries from the project dependencies, not a live API server. Please commit the regenerated CRDs and regression tests with the rule. A translator-side negative-value check would also cover existing objects and installations whose CRDs have not yet been upgraded.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix fractional upstream timeout translation [apisix-ingress-controller]
Posted by "efegokdemir (via GitHub)" <gi...@apache.org>.
efegokdemir commented on PR #2894:
URL: https://github.com/apache/apisix-ingress-controller/pull/2894#issuecomment-6136371028
Changed the expected timeout values to floats to match the decoded timeout type. Translator/API tests, race tests, the ingress package compile check, vet and golangci-lint pass. Kubernetes E2E was not run.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix fractional upstream timeout translation [apisix-ingress-controller]
Posted by "AlinsRan (via GitHub)" <gi...@apache.org>.
AlinsRan commented on PR #2894:
URL: https://github.com/apache/apisix-ingress-controller/pull/2894#issuecomment-6074910711
Please check the CI.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org