Commit graph

123 commits

Author SHA1 Message Date
Aaron Prindle
9d83f71cde fix validation_test.go to use path normalization 2025-10-16 17:40:19 +00:00
Kubernetes Prow Robot
db63a581ca
Merge pull request #134366 from tallclair/feature-gates-test
Set multiple feature gates simultaneously in test
2025-10-13 13:11:33 -07:00
Tim Allclair
4986abe0b8 Automated refactoring to use SetFeatureGatesDuringTest 2025-10-01 21:10:53 -07:00
Tim Hockin
229c6b13ca Validate ReplicationController.metadata.name
This relies on `+k8s:subfield` and validation cohorts.  The
`k8s:optional` ensures that we don't run the name validation if name is
empty, because core apimachinery will already flag it as Required().

This demonstrates some of the DV value - docs and clients are now (in
theory) able to see what RC's name format is.

Co-Authored-by: Yongrui Lin <yongrlin@outlook.com>
2025-10-01 19:45:37 +00:00
Tim Hockin
7b93851395 Fix ReplicationControl double validation 2025-10-01 18:37:13 +00:00
yongruilin
96349a4608 chore: Move declarative validation featuregates to staging apiserver 2025-09-26 22:30:16 +00:00
yongruilin
2d7dd9164f Refactor: Centralize declarative validation and migration logic
The boilerplate for running declarative validation was duplicated across multiple resource strategies. This included feature gate checks, metric identifier generation, error comparison, and conditional merging logic, which made the code verbose and difficult to maintain.

This commit introduces a new helper function, `rest.ValidateDeclarativelyWithMigrationChecks`, to encapsulate this common logic. All relevant strategies have been refactored to use this new function, resulting in cleaner and more concise code.
2025-09-26 17:22:46 +00:00
Lalit Chauhan
92dcd02459 Add helpers for declarative validation tests
Introduces new testing helpers to simplify testing of declarative validation rules. The new `VerifyValidationEquivalence` and `VerifyUpdateValidationEquivalence` functions reduce boilerplate by encapsulating the logic for:

- Toggling the `DeclarativeValidation` and `DeclarativeValidationTakeover` feature gates.
- Comparing the validation output from the imperative and declarative paths.

The declarative validation tests for CertificateSigningRequest and ReplicationController are updated to use these new, simpler helpers.
2025-09-16 16:57:21 +00:00
Lalit Chauhan
1a5e77135b Add fine grained metrics to narrow down DV mismatches and panics 2025-09-16 00:36:14 +00:00
Davanum Srinivas
ebc1ccc491
Bump k8s.io/kube-openapi to latest SHA (f3f2b991d03b)
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-07-14 07:24:48 -04:00
Joe Betz
7dc8660d03 Update testing to fully track subresources 2025-05-23 21:47:08 -04:00
Joe Betz
105391403f Enable scale subresource in generated validations 2025-05-23 21:47:08 -04:00
Joe Betz
a3eddf7d85 Add declarative validation testing for replicationcontroller/scale 2025-05-23 21:47:07 -04:00
Joe Betz
356f395f0d Enable declarative validation for replicationcontroller/scale 2025-05-23 21:47:07 -04:00
Joe Betz
48e1079cf0 Add subresource mapping support to ValidateDeclaratively and introduce configs
# Conflicts:
#	staging/src/k8s.io/apiserver/pkg/registry/rest/validate_test.go
2025-05-23 21:47:07 -04:00
Joe Betz
5a98d4dbb4 Limit declarative validation to spec until subresource support is added 2025-03-14 11:58:19 -04:00
Joe Betz
f7296b31f0 Add declarative test cases for RC.Spec.MinReadySeconds 2025-03-13 21:26:17 -04:00
Joe Betz
20b69a54bf Add declarative test cases for RC.Spec.Replicas 2025-03-13 21:24:50 -04:00
Tim Hockin
7315d0a687
Change internal-version RC.Spec.Replicas to a ptr
This is needed to make declaratve validation clean.  Past me thought
this was clever (pointer versioned, non-pointer internal) but it is just
confusing.
2025-03-13 08:47:19 -07:00
Joe Betz
b5bc283808 ReplicationController: Add declarative validation test suite
Introduce a test suite that ensures declarative test cases
are fully tested and that validation errors are compared
with handwritten validation to ensure consistency.

Co-authored-by: Tim Hockin <thockin@google.com>
Co-authored-by: Aaron Prindle <aprindle@google.com>
Co-authored-by: Yongrui Lin <yongrlin@google.com>
2025-03-12 19:53:44 -04:00
Joe Betz
5a5ed81e1f ReplicationController: Enable declarative validation
After declarative validation is enabled in the ReplicationController
strategy in this way, the generated declarative validation code
in pkg/apis/core/v1/zz.generated.validations.go will be run
when the strategy validates ReplicationController.

Co-authored-by: Tim Hockin <thockin@google.com>
Co-authored-by: Aaron Prindle <aprindle@google.com>
Co-authored-by: Yongrui Lin <yongrlin@google.com>
Co-authored-by: David Eads <deads@redhat.com>
2025-03-12 19:51:31 -04:00
Maciej Szulik
1fa995224a
Update scale sub-resource to return the same error everywhere
Signed-off-by: Maciej Szulik <soltysh@gmail.com>
2025-01-28 15:42:08 +01:00
Patrick Ohly
8a908e0c0b remove import doc comments
The "// import <path>" comment has been superseded by Go modules.
We don't have to remove them, but doing so has some advantages:

- They are used inconsistently, which is confusing.
- We can then also remove the (currently broken) hack/update-vanity-imports.sh.
- Last but not least, it would be a first step towards avoiding the k8s.io domain.

This commit was generated with
   sed -i -e 's;^package \(.*\) // import.*;package \1;' $(git grep -l '^package.*// import' | grep -v 'vendor/')

Everything was included, except for
   package labels // import k8s.io/kubernetes/pkg/util/labels
because that package is marked as "read-only".
2024-12-02 16:59:34 +01:00
Michael Fraenkel
cd949bafa4
use MakePodSpec consistently (#125805)
cleaning up some tests after MakePod/MakePodSpec were introduced
2024-06-30 10:28:36 -07:00
Michael Fraenkel
a7264f95ff
pod terminationGracePeriodSeconds is always valid (#124461)
* Pod terminationGracePeriodSeconds is always valid

Validation of a pod spec will always use the pod's
TerminationGracePeriodSeconds value.

A set of pod test-helpers have been created to help construct Pods.

* remove unused func

* reduction

* reduce 2

* simplify test

* report invalid grace period

* update SupplementalGroupPolicy tests
2024-06-29 18:09:29 -07:00
carlory
98353f1338 rc registry: add unit test for UpdateStatus 2024-04-16 14:57:01 +08:00
Michelle Au
c4aab1036f Add sig OWNERS to registry packages 2023-10-31 01:20:16 +00:00
Tim Hockin
29c0b73d64
Replace uses of diff.ObjectDiff with cmp.Diff
ObjectDiff is already a shim over cmp.Diff, so no actual output or
behavior changes
2023-04-12 08:46:12 -07:00
Antoine Pelisse
4f3859ce91 managedfields: Move most of fieldmanager package to managefields 2023-03-08 13:44:00 -08:00
Kubernetes Prow Robot
12c71fdf1c
Merge pull request #113542 from ardaguclu/fix-shortname-disperancy
Set singular names for core types to pass to discovery
2023-01-03 09:29:43 -08:00
Tim Hockin
e27cf75094
rc: API warn when name is not DNS label 2022-12-16 13:06:10 -08:00
Arda Güçlü
1abf94bec3 Remove GetSingularName for subresources 2022-11-18 12:21:19 +03:00
Arda Güçlü
672e0b1e01 Use correct singular name format for subresources 2022-11-18 12:21:19 +03:00
Arda Güçlü
578ddde80e Add singular name for the rest of types 2022-11-18 12:21:13 +03:00
Arda Güçlü
0990ba1cc9 Introduce singularNameProvider for core types
This introduces `singularNameProvider`. This provider will be used
by core types to have their singular names are defined in discovery
endpoint. Thanks to that, core resources singular name always have
higher precedence than CRDs shortcuts or singular names.
2022-11-18 12:21:07 +03:00
Wojciech Tyczyński
80060a502c Implement Destroy() method for all registries 2022-04-19 15:59:13 +02:00
Patrick Ohly
edffc700a4 enhance and fix log calls
Some of these changes are cosmetic (repeatedly calling klog.V instead of
reusing the result), others address real issues:

- Logging a message only above a certain verbosity threshold without
  recording that verbosity level (if klog.V().Enabled() { klog.Info... }):
  this matters when using a logging backend which records the verbosity
  level.

- Passing a format string with parameters to a logging function that
  doesn't do string formatting.

All of these locations where found by the enhanced logcheck tool from
https://github.com/kubernetes/klog/pull/297.

In some cases it reports false positives, but those can be suppressed with
source code comments.
2022-03-24 11:13:50 +01:00
Yuvaraj Kakaraparthi
801c39b478 kubectl: API changes to support --subresource in kubectl
Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
Co-authored-by: Nikhita Raghunath <nikitaraghunath@gmail.com>
Co-authored-by: Yuvaraj Kakaraparthi <kakaraparthy@vmware.com>
2022-03-23 11:19:58 +05:30
Jordan Liggitt
f669796dfd Send pod spec warnings when creating or changing workload objects 2021-05-18 10:42:36 -04:00
Jordan Liggitt
8c8a4cf3e4 Add WarningsOnCreate,WarningsOnUpdate 2021-05-18 10:42:36 -04:00
Andrea Nodari
09649e58b5 Check request info when updating managed fields during scale
- Test all versions to make sure each resource version is in the
  mappings
- Fail when request info contains an unrecognized version. We have tests
  that guarantee that all known versions are in the mappings. If we
  get a version in request info that is not there we should fail fast to
  prevent inconsistent behaviour (e.g. for some reason the mappings is
  not up to date).

Ensure all known versions are in mappings
2021-04-21 20:27:02 +02:00
Antoine Pelisse
816e80206c Use ScaleHandler for all scalable resources 2021-04-21 18:41:40 +02:00
Kevin Delgado
a1fac8cbd9 Server-Side Apply: Status Wiping/Reset Fields
Adds and implements ResetFieldsProvder interface in order to ensure that
the fieldmanager no longer owns fields that get reset before the object
is persisted.

Co-authored-by: Kevin Wiesmueller <kwiesmul@redhat.com>
Co-authored-by: Kevin Delgado <kevindelgado@google.com>
2021-03-10 01:02:18 +00:00
Benjamin Elder
56e092e382 hack/update-bazel.sh 2021-02-28 15:17:29 -08:00
Derek Carr
45bd6cb186 Downward API hugepages 2020-11-10 16:09:13 -05:00
Dan Winship
3a110546ed Move SCTP to GA 2020-10-15 08:56:33 -04:00
Zsolt Prontvai
c244e175e2 Fix golint failures in pkg/registry/core/replicationcontroller 2020-10-03 12:56:14 +01:00
Jordan Liggitt
dab2a830da Fix conflicts patching scale subresources 2020-04-21 16:36:24 -04:00
Jordan Liggitt
bb90f0ff94 Install APIs directly for tests 2019-12-13 11:56:29 -05:00
Jordan Liggitt
61774cd717 Plumb context to admission Admit/Validate 2019-08-20 11:11:00 -04:00