Commit graph

482 commits

Author SHA1 Message Date
Patrick Ohly
1acfb8e8fc DRA: add DeviceTaintRule to v1 API 2026-07-06 20:15:27 +02:00
Yongrui Lin
4dabaebe45 api/testing: auto-discover declarative-validation GVKs in fuzz test
TestVersionedValidationByFuzzing swept a hand-maintained list of
group/versions that had a typo (network.k8s.io) and omitted several
groups (apps, policy, rbac, flowcontrol, scheduling). Replace it with a
sweep of the scheme for served GVKs that have declarative validation,
so new group/versions are covered automatically.

Skip extensions/v1beta1 centrally in VerifyVersionedValidationEquivalence
instead of via the per-call WithSkipGroupVersions option: it opts out of
declarative validation but shares an internal type with versions that do
not. Any other version missing declarative validation now fails the sweep
rather than being silently skipped.
2026-07-01 17:07:29 +00:00
Yongrui Lin
ae16b61ccf Stop setting locked GA DeclarativeValidation gate in DV tests
The gate is GA and locked to true, so explicitly setting it in the
equivalence test harness only emits a 'setting GA feature gate' warning
without changing behavior. Rely on its locked default instead.
2026-06-26 21:17:13 +00:00
Lalit Chauhan
ae2801a7bf Change DV test util accordingly 2026-06-24 16:29:48 +00:00
kubernetes-prow[bot]
dda2e89631
Merge pull request #139568 from lalitc375/configure-dv-part1a
Setup ObjectMeta test suite and wire it for AdmissionRegistration API group
2026-06-22 20:25:52 +00:00
Aman Shrivastava
3b485f67e8 Skip extensions/v1beta1 in autoscaling Scale validation equivalence tests 2026-06-16 16:03:49 +05:30
Lalit Chauhan
8dc4ad1d5c Add valid test cases to ObjectMeta DV test suite
Address review feedback on PR #139568:

- Group all test cases by the ObjectMeta field they cover (the stray
  "finalizers: name too long" case previously sat at the bottom).
- Mirror the field grouping in the update suite. The update suite keeps
  only the baseline valid case; field-level boundaries are covered by
  the create suite and re-checking them on update adds no signal.
- Fix three errorlint warnings flagged by pull-kubernetes-linter-hints:
  switch fmt.Errorf("...: %v", err) to %w in the metadata-accessor
  failure paths of rest.ValidateCreate and validateCommonFields.
- Reword the extensions/v1beta1 skip comment in
  TestVersionedValidationByFuzzing: drop the stray trailing semicolon
  and explain that the group is unserved and does not carry DV.
2026-06-15 14:59:25 -07:00
Lalit Chauhan
755ccb3dae Add objectMeta validation in the path of DV testing 2026-06-15 21:22:30 +00:00
Yongrui Lin
e4cc8f8e9d testing: skip unserved extensions/v1beta1 in validation equivalence sweep
Add WithSkipGroupVersions and apply it to the NetworkPolicy and Scale tests,
whose internal types also register under the now-unvalidated extensions/v1beta1.
2026-06-11 06:35:35 +00:00
dom4ha
88948acc38 Remove v1alpha2 API definitions
Update client-go lister and informer imports to v1alpha3
2026-05-22 12:50:19 +00:00
Yongrui Lin
44f6df54da Drop legacy hand-written validation subtest from pkg/api/testing
With DV always enforced, the "hand written validation" subtest (which
set DeclarativeValidation=off and emulated 1.35) now exercises the
same code path as "Beta disabled". Remove it along with the
MinEmulationVersion option, the WithMinEmulationVersion helper,
deDuplicateErrors, and the now-tautological imperative-vs-declarative
equivalence checks.
2026-05-20 18:54:07 +00:00
Yongrui Lin
16a17be014 pkg/api/testing: add VerifyUpdateValidationEquivalenceFunc
Variant of VerifyUpdateValidationEquivalence that accepts a validate
closure instead of a RESTUpdateStrategy, for callers that produce
handwritten and declarative validation errors directly.
2026-05-13 20:07:12 +00:00
Jordan Liggitt
ef2e578f14
switch tag Get("json") to Lookup("json") 2026-05-13 11:24:07 -04:00
Yongrui Lin
3577cbda2f pkg/api/testing: record observed rules during DV equivalence tests
VerifyValidationEquivalence's all-rules-enforced subtest now extracts
the GVK from the request context and forwards each error to
coverage.RecordObservedRules so AssertDeclarativeCoverage (in the
generated TestMain) can confirm every declared rule fired.
2026-05-09 18:59:16 +00:00
Lalit Chauhan
a1a5b10127 Address comments 2026-05-02 00:09:59 +00:00
Lalit Chauhan
68ad19102c Fix testing utils 2026-05-02 00:09:59 +00:00
Joe Betz
1fafa91da4
Consolidate DeclarativeValidationStrategy interface 2026-04-27 19:26:25 -04:00
Joe Betz
30c76c1879
Make declarative validation part of strategies 2026-04-24 12:00:41 -04:00
Antoni Zawodny
59c9f75133 Add Workload-Aware Preemption fields to Workload and PodGroup APIs
Co-authored-by: Omar Sayed <omarsayed@google.com>
2026-03-24 09:03:50 +01:00
Nour
29601b8628
Add ResourcePoolStatusRequest API types and generated code
Introduce the ResourcePoolStatusRequest resource type in the
resource.k8s.io/v1alpha3 API group, gated behind the
DRAResourcePoolStatus feature gate. This includes external and internal
type definitions, protobuf/OpenAPI generated code, client-go typed
clients, informers, listers, apply configurations, deepcopy, defaults,
conversion, fuzzer, declarative validation tags, and API discovery
metadata.
2026-03-19 16:49:56 +02:00
Antoni Zawodny
d879ee4761 Remove v1alpha1 scheduling API from the API defaulting test 2026-03-14 08:46:57 +01:00
Patrick Ohly
566dc7f3f3 DRA device taints: graduate to beta
The fields become beta, enabled by default. DeviceTaintRule gets
added to the v1beta2 API, but support for it must remain off by default
because that API group is also off by default.

The v1beta1 API is left unchanged. No-one should be using it
anymore (deprecated in 1.33, could be removed now if it wasn't for
reading old objects and version emulation).

To achieve consistent validation, declarative validation must be enabled also
for v1alpha3 (was already enabled for other versions). Otherwise,
TestVersionedValidationByFuzzing fails:

    --- FAIL: TestVersionedValidationByFuzzing (0.09s)
        --- FAIL: TestVersionedValidationByFuzzing/resource.k8s.io/v1beta2,_Kind=DeviceTaintRule (0.00s)
            validation_test.go:109: different error count (0 vs. 1)
                resource.k8s.io/v1alpha3: <no errors>
                resource.k8s.io/v1beta2: "spec.taint.effect: Unsupported value: \"幤HxÒQP¹¬永唂ȳ垞ş]嘨鶊\": supported values: \"NoExecute\", \"NoSchedule\", \"None\""
            ...
2026-03-12 18:26:02 +01:00
Kubernetes Prow Robot
8275484dcf
Merge pull request #137297 from atombrella/feature/pkg_forvar_modernize
Remove redundant variable re-assignment in for-loops under pkg
2026-03-05 00:28:20 +05:30
Mads Jensen
f11bb48738 Remove redundant re-assignment in for-loops under pkg
This the forvar rule from modernize. The semantics of the for-loop
changed from Go 1.22 to make this pattern obsolete.
2026-03-02 08:47:43 +01:00
yongruilin
9454a3069b Add WithMinEmulationVersion option to skip hand-written validation sub-test
When a test enables a feature gate introduced after 1.35, the "hand
written validation" sub-test fails because SetFeatureGateEmulationVersionDuringTest
cannot downgrade to 1.35 for features that did not exist at that version.
This adds a WithMinEmulationVersion option so callers can declare the
minimum supported emulation version and skip the sub-test when incompatible.
2026-02-26 21:36:40 +00:00
Your Name
3b5298f0a4 Fix resource claim DV 2026-02-24 18:36:47 +00:00
Your Name
12a6d300c6 Change strategy.go utils to mark handwritten validation errors properly 2026-02-24 18:33:14 +00:00
Lalit Chauhan
b7c4f21d41 promote MutatingAdmissionPolicy to v1: api wiring and validation
- Register v1 MutatingAdmissionPolicy and Binding in apiserver storage.
- Add defaults and validation for v1 types.
- Update storage version hash data.
- Add API testdata.
2026-02-18 17:51:43 +00:00
yongruilin
33dec2246f address feedback: refactor declarative validation migration checks
- Extract HV error filtering into filterHandwrittenErrors for readability.
- Simplify errOutputMatcherByStability initialization in testing helpers.
2026-02-13 00:54:18 +00:00
yongruilin
93b901d177 Enhance validation testing: add support for all declarative rules enforcement 2026-02-13 00:54:18 +00:00
yongruilin
4f56a298cc Enforce zero mismatches in validation equivalence testing 2026-02-13 00:54:18 +00:00
yongruilin
2ef358870a Update validation equivalence testing for lifecycle enforcement
- Test scenarios: Beta Enabled, Beta Disabled, and Legacy (emulated 1.35).
- Remove deprecated Takeover gate references and redundant coverage checks.
- Add TODO to remove legacy emulation in 1.39.
- Update documentation to match the new Validation Lifecycle strategy.
2026-02-13 00:54:18 +00:00
Kubernetes Prow Robot
c8e45a3331
Merge pull request #136620 from yongruilin/master_vg-fix-fuzz
fix DeclarativeValidation fuzzing test panic and refactor subresource handlin
2026-01-30 03:08:04 +05:30
Kubernetes Prow Robot
3760cdc64a
Merge pull request #136482 from aaron-prindle/dv-feature-gate-ga
Graduate DeclarativeValidation feature gate to GA
2026-01-30 03:07:48 +05:30
yongruilin
fbefdc816f refactor subresource handling in versioned validation fuzz tests
Refactor TestVersionedValidationByFuzzing to use a declarative map,
subresourceOnly, for resources that must be validated via a specific
subresource path (like autoscaling/Scale).

GVKs not in this map default to root-level validation (""), which is
sufficient for resources that share validation logic between their root
and subresources. This replaces the previous ad-hoc special-casing
with a cleaner, extensible mapping.
2026-01-29 10:30:12 +00:00
yongruilin
64140b8385 fuzz internal objects in versioned validation tests
Fuzzing must be performed on the internal version of objects because
custom fuzzing functions are typically registered for internal types.
This ensures that all fields are properly initialized with random values
before being converted to various API versions for validation.

Move fuzzing logic into VerifyVersionedValidationEquivalence via a new
WithFuzzer option. This also fixes a panic that occurred when attempting
to fuzz types without an internal version (e.g., APIGroupList) by adding
a nil check after internal conversion.
2026-01-29 10:29:55 +00:00
Aaron Prindle
0cab277183 Graduate DeclarativeValidation feature gate to GA
This change graduates the 'DeclarativeValidation' feature gate to GA in v1.36.
The feature gate is now locked to 'true' by default.

Changes:
- Updated 'DeclarativeValidation' feature gate to GA in 'pkg/features/kube_features.go' and 'staging/src/k8s.io/apiserver/pkg/features/kube_features.go'.
- Updated feature gate documentation and versioned lists via 'hack/update-featuregates.sh'.
- Added feature gate emulation versioning to tests that explicitly disable 'DeclarativeValidation' to prevent panics now that the gate is locked to default.
2026-01-29 05:38:20 +00:00
darshansreenivas
0b635116f1 feat(admissionregistration): enable declarative validation wiring and require ValidationActions 2026-01-24 03:46:24 -08:00
Kubernetes Prow Robot
5eb7087ccb
Merge pull request #135761 from darshansreenivas/admissionregistratio_k8s_io_policy_name
feat: wire admissionregistration group for declarative validation and +k8s:required to ValidatingAdmissionPolicyBindingSpec.PolicyName
2026-01-24 10:33:31 +05:30
darshansreenivas
04ea1eabff feat(admissionregistration): wire group for declarative validation and require PolicyName 2026-01-22 11:19:22 -08:00
Kubernetes Prow Robot
f4ed7b3e28
Merge pull request #135951 from droach282/cronjob-schedule-dv
Adding declarative validations to CronJob Schedule field
2026-01-16 17:18:49 +05:30
Dan Roach
5b5cc2d498 Adding declarative validations to CronJob 2026-01-15 14:05:15 -07:00
Lalit Chauhan
c3fecccd3e Make sure errors present in declarative validation test files are DV errors 2026-01-15 17:42:02 +00:00
CLBRITTON2
a6618afc29 Wire discovery v1/v1beta1 for fuzz testing 2026-01-09 11:54:51 -05:00
Lalit Chauhan
55041b832f Bring the changes back which was removed due to accident in #134909 2026-01-09 00:02:41 +00:00
Darshan Murthy
1c24a05ce1
wire network group for declarative validation and +k8s:required to IngressClassParametersReference.Name and IngressClassParametersReference.Kind (#134909) 2026-01-09 03:11:43 +05:30
Lalit Chauhan
4e6aafb9b3 Address feedbacks 2026-01-06 18:38:35 +00:00
Lalit Chauhan
e83723ce2c Add ignoreConversionErrors option to validation testing
This commit adds an 'IgnoreObjectConversionErrors' option to the
validation testing framework in 'k8s.io/apimachinery' and exposes it
via 'pkg/api/testing'.

This is useful for fuzzing tests where we might want to skip object
versions that cannot be converted from the internal version (e.g. due to
missing fields or incompatible types in older versions) but still want
to test validation for the versions that *can* be converted.

The 'autoscaling' group versions are added to 'TestVersionedValidationByFuzzing'
with this option enabled.
2026-01-06 18:23:26 +00:00
darshansreenivas
897adb7b48 DRA: adding tag to node module
move DRA to a update method

fix boilerplate code

apply node normalize code at fuzz logic

adding normalization fix

fix nit
2025-12-04 23:03:21 -08:00
Lalit Chauhan
ee481b97e0 fix sorting logic after after normalizing errors 2025-11-06 06:17:49 +00:00