Commit Graph

132825 Commits

Author SHA1 Message Date
Tim Hockin
b922fd9db4 Make ErrorMatcher more strict about multi-match
As discussed in a proposed PR, multi-match makes sense when origin is
specified and matched, but otherwise it feels "loose" to multi-match.
And in fact it was hiding bugs in declarative validation tests and real
bugs (in subsequent commits) in implementation.

Now we allow multi-match if and only if:
  1) ErrorMatcher.ByOrigin() was specified
  2) The origin string is not empty
  3) The multiple "got" errors are not exactly identical

This last part is key -- if some change to DV codegens logic which
(errantly) calls the same function twice, we want to know about it.
2025-10-01 06:26:26 +00:00
yongruilin
a51fb72c7f Simplify tests wrt ratcheting
Co-Authored-by: Tim Hockin <thockin@google.com>
2025-10-01 06:24:40 +00:00
Tim Hockin
054ab36c91 Fix field path for embedded fields in root types
Given the following:

```
type Struct type {
    TypeMeta int

    // +k8s:validateFalse="embedded"
    OtherStruct
}
```

What should the field-path be for the error?

or:

```
type Struct type {
    TypeMeta int

    OtherStruct // embedded
}

// +k8s:validateFalse="otherstruct"
type OtherStruct {
  I int
}
```

Conclusion: If we find an embedded field, we look for a nil fldPath, and
if so we set it to the type name.  Embedded values in root types (e.g.
above `spec`) should not be a things we actually do.

Implementation: Add `safe.Value(*T, func() *T)`
2025-10-01 06:22:06 +00:00
Kubernetes Prow Robot
c0af084da0 Merge pull request #134308 from chizhang21/cordon_state_enhance
fix(cordonhelper): Avoid mutating local node before API call
2025-09-30 22:56:16 -07:00
Kubernetes Prow Robot
81d7612a53 Merge pull request #134330 from michaelasp/rvCmp
Add resource version comparison function in client-go along with conformance
2025-09-30 20:58:16 -07:00
Michael Aspinwall
9757d8d8ef Document 0 as a special case in RV comparison 2025-10-01 03:09:26 +00:00
Kubernetes Prow Robot
81059575f6 Merge pull request #134208 from n2h9/126379-replace-non-WithContext-functions-to-use-WithContext-functions-instead-of-duplicates
[126379] [client-go] chore: use WithContext functions inside old functions to remove code duplication
2025-09-30 19:32:16 -07:00
Michael Aspinwall
84f85712be feat: Add matcher and conformance tests ensuring that RV is uint128 2025-10-01 00:01:50 +00:00
Kubernetes Prow Robot
6a687c5ddc Merge pull request #133339 from aojea/vap_servicecidr
ServiceCIDR ValidationAdmissionPolicy for implementing previous behavior
2025-09-30 16:20:15 -07:00
Kubernetes Prow Robot
8f372d2ac0 Merge pull request #133972 from pohly/build-data-race-detection-image
build: automatically choose a suitable base image
2025-09-30 12:32:16 -07:00
cz21
c524a5fba2 fix(cordonhelper): Avoid mutating local node before API call
Signed-off-by: cz21 <cz21ok@gmail.com>
2025-10-01 01:53:07 +08:00
Michael Aspinwall
7c24e62d7c Add additional types for resource version comparison testing 2025-09-30 17:16:07 +00:00
Kubernetes Prow Robot
cffecaac55 Merge pull request #134319 from neolit123/1.35-refactor-fetch-init-config-flags
kubeadm: rework the FetchInitConfigurationFromCluster node flags
2025-09-30 09:14:32 -07:00
Kubernetes Prow Robot
2b828fac59 Merge pull request #134297 from ialidzhikov/cleanup/kcm-ks-configmap-leader-election-rbac
Remove configmaps related rules from the kube-controller-manager and kube-scheduler leader election roles
2025-09-30 09:14:25 -07:00
Kubernetes Prow Robot
0f660b5eb4 Merge pull request #133765 from cfryanr/feature-readable-audit-event
restore public func `AuditEventFrom` which was deleted by #129472
2025-09-30 09:14:17 -07:00
Kubernetes Prow Robot
4a1558c545 Merge pull request #133967 from pohly/dra-allocator-selection
DRA: allocator selection
2025-09-30 08:24:18 -07:00
Patrick Ohly
68205ff40c DRA scheduler_perf: run with specific allocator implementations
For some packages (in particular the code DRA), all allocator implementations
can handle the testcases. Some other packages are for less stable features and
work with fewer implementations. Now all unit tests are run with all suitable
implementations, to increase code coverage.

Benchmarks are fixed to the most mature implementation because they would be
costly to run in more than one. When promoting an allocation implementation we
can do before/after comparisons to detect potential performance regressions.

The downside of this approach is that we need to remember to extend the list
of supported implementations when promoting features, otherwise testing will miss
some new supported implementation.
2025-09-30 18:19:57 +02:00
Patrick Ohly
5832c915ac scheduler_perf: apply feature gates in deterministic, alphabetical order
Without this, the effect of the following feature gate config would be random:

    featureGates:
      AllBeta: false
      SomeBetaFeature: true

That's random because the order of iterating of the map is randomized by Go and
`AllBeta: false` would disable `SomeBetaFeature` if (and only if) applied last.

Now by sorting alphabetically, AllAlpha/Beta come first in practice. It's not a
complete solution, some future feature gate name might come before it.
2025-09-30 16:53:39 +02:00
Patrick Ohly
60eeaa6ebd DRA scheduler: add unit test for allocator selection
This prevents the mistake from 1.34 where the default-on
DRAResourceClaimDeviceStatus feature caused the use of the experimental
allocator implementation. The test fails without a fix for that.
2025-09-30 16:53:38 +02:00
Patrick Ohly
7f57730ba4 DRA scheduler: fix selection of "incubating" allocator implementation
In 1.34, the default feature gate selection picked the "experimental" allocator
implementation when it should have used the "incubating" allocator. No harm
came from that because the experimental allocator has all the necessary if
checks to disable the extra code and no bugs were introduced when implementing
it, but it means that our safety net wasn't there when we expected it to be.

The reason is that the "DRAResourceClaimDeviceStatus" feature gate is on by
default and was only listed as supported by the experimental implementation.
This could be fixed by listing it as supported also by the other
implementation, but that would be a bit odd because there is nothing to support
for it (the reason why this was missed in 1.34!). Instead, the allocator
features are now only indirectly related to feature gates, with a single
boolean controlling the implementation of binding conditions.
2025-09-30 16:53:38 +02:00
Patrick Ohly
b5bcac998d DRA scheduler: clean up feature gate handling
Copying from feature.Features to new fields in the plugin got a bit silly with
the long list of features that we have now. Embedding feature.Features is
simpler.

Two fields in feature.Features weren't named according to the feature gate, now
they are named consistently and the fields are sorted.
2025-09-30 16:53:38 +02:00
Kubernetes Prow Robot
e5c04392c0 Merge pull request #134276 from aaron-prindle/allocation-mode-enum
fix: add +enum tag to resource DeviceAllocationMode
2025-09-30 07:14:34 -07:00
Kubernetes Prow Robot
07a5020bfc Merge pull request #134168 from aditigupta96/refactor-naming-controller
refactor(apiextensions-apiserver): Make NamingConditionController context-aware
2025-09-30 07:14:26 -07:00
Kubernetes Prow Robot
14fb5e6481 Merge pull request #133697 from tallclair/feature-deps
Codify feature gate dependencies
2025-09-30 07:14:18 -07:00
Kubernetes Prow Robot
7353b6a93d Merge pull request #134312 from alaypatel07/gc-resourceclaim-extendedresource
fix resource claims deallocation for extended resource when pod is completed
2025-09-30 01:38:20 -07:00
Michael Aspinwall
37fcfcd29e feat: Add conformance tests for all resources for comparable resource version 2025-09-29 23:32:07 +00:00
Kubernetes Prow Robot
0f8471a6f5 Merge pull request #134237 from aditigupta96/contextual-logging-nonstructural-schema-controller
refactor(apiextensions-apiserver): Make NonStructuralSchema controller context-aware
2025-09-29 16:00:17 -07:00
Kubernetes Prow Robot
e87a447ca2 Merge pull request #134327 from p0lyn0mial/watchlist-e2e-table-improve
test/e2e/apimachinery/watchlist: select only wellknown secrets for table test
2025-09-29 13:46:16 -07:00
Michael Aspinwall
2cef54c145 feat: Add helper function for client-go to compare resource version 2025-09-29 20:41:24 +00:00
Ryan Richard
f5e65af173 add getters for event User and ImpersonatedUser on AuditContext
The ability to get these values was deleted by #129472 which removed
the public function audit.AuditEventFrom. The new getters return copies
of the underlying objects to prevent external mutations of the objects
held by the audit events.
2025-09-29 12:41:59 -07:00
Kubernetes Prow Robot
7f180515d7 Merge pull request #134233 from aaron-prindle/dv-validate-csi-driver-option-support
refactor(DRA validation): Add granular controls to ValidateCSIDriverName for declarative validation migration
2025-09-29 12:20:20 -07:00
Alay Patel
8a03067211 fix resource claims deallocation for extended resource when pod is completed
Signed-off-by: Alay Patel <alayp@nvidia.com>
2025-09-29 15:15:40 -04:00
Kubernetes Prow Robot
1ffdc16b71 Merge pull request #134314 from xigang/node_controller_zone
node_lifecycle_controller: fix ComputeZoneState method comment
2025-09-29 11:30:24 -07:00
Kubernetes Prow Robot
da552ef1d7 Merge pull request #134240 from yongruilin/master_vg_strategy-call
Refactor: Centralize declarative validation logic
2025-09-29 11:30:17 -07:00
Lubomir I. Ivanov
b6afe986c6 kubeadm: rework the FetchInitConfigurationFromCluster node flags
The newControlPlane flag has been historically problematic, since
it implies that the function FetchInitConfigurationFromCluster
cannot handle the cases where a node is worker node but
we still want to fetch its NodeRegistrationOptions conditionally,
in cases such as "upgrade node" for workers.

To fix this issue, replace the flag newControlPlaneNode with
two new flags getNodeRegistration and getAPIEndpoint.

If getNodeRegistration is true, we fetch the NRO, and if
getAPIEndpoint is true, we fetch the API endpoint for
that node.

Additionally, rename skipComponentConfigs to getComponentConfigs
for consistency and flip its value accordingly everywhere.
2025-09-29 19:58:56 +02:00
Kubernetes Prow Robot
8ebc216c59 Merge pull request #134185 from DanBokete/deprecate-caseless-validation
Feat: Adds warnings when ResourceSlice driver names contain uppercase characters
2025-09-29 09:40:18 -07:00
Kubernetes Prow Robot
50cc9905b6 Merge pull request #132059 from jm-franc/configurable-tolerance-e2e-test
Add configurable tolerance e2e test.
2025-09-29 07:40:19 -07:00
Lukasz Szaszkiewicz
212a9c6a60 test/e2e/apimachinery/watchlist: select only wellknown secrets for table test 2025-09-29 13:36:38 +02:00
Kubernetes Prow Robot
5161bf0058 Merge pull request #134268 from joshjms/gce-test-fix-etcd-manifest
gce: Fix etcd manifest
2025-09-28 08:00:16 -07:00
joshjms
6a5d0ef423 gce: fix etcd manifest
Signed-off-by: joshjms <joshjms1607@gmail.com>
2025-09-28 22:06:16 +08:00
xigang
574b09b7de nodelifecycle: fix ComputeZoneState method comment
Signed-off-by: xigang <wangxigang2014@gmail.com>
2025-09-28 10:56:56 +08:00
Kubernetes Prow Robot
ed49decb4a Merge pull request #134309 from hakman/npd-1.34.0
Update NPD to v1.34.0
2025-09-27 19:38:16 -07:00
Ciprian Hacman
2b3f1877be Update NPD to v1.34.0 2025-09-27 19:57:47 +03:00
Dan Bokete
b40b67b9cf Deprecate caseless driver name validation and enforce lowercase warnings
- Deprecate IsDNS1123SubdomainCaseless to avoid caseless validation issues.
- Warn when ResourceSlice driver names contain uppercase characters.
- Clarify driver names must be DNS subdomains and use only lowercase letters.
- Update tests, staging code, and OpenAPI spec to reflect the changes.
2025-09-27 13:23:59 +01:00
yongruilin
96349a4608 chore: Move declarative validation featuregates to staging apiserver 2025-09-26 22:30:16 +00:00
yongruilin
e6e6c6fdfb Remove unused WithTakeover and WithValidationIdentifier 2025-09-26 17:22:48 +00:00
yongruilin
9a7e2291d1 refactor: Remove Validate(Update)Declaratively and improve error handling 2025-09-26 17:22:48 +00:00
Joe Betz
d2ec0308c7 simplify scale subresource testing and document expectations
Co-Authored-by: Yongrui Lin <yongrlin@outlook.com>
2025-09-26 17:22:48 +00:00
yongruilin
713cb97a85 test: Add unit tests for metricIdentifier function 2025-09-26 17:22:48 +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