Commit Graph

134908 Commits

Author SHA1 Message Date
yongruilin
04d632dd05 fix: Adjust validation for pool names to ensure proper coverage in device requests 2025-10-01 18:35:23 +00:00
Kubernetes Prow Robot
93e18b57f3 Merge pull request #134352 from AwesomePatrol/move-metrics-to-get-list
Move metrics calculations to getList
2025-10-01 11:29:04 -07:00
Kubernetes Prow Robot
fdb04f9c3b Merge pull request #134340 from pohly/dra-resourceslice-cleanup
DRA: ResourceSlice tracker cleanup
2025-10-01 11:28:57 -07:00
Kubernetes Prow Robot
034079b26e Merge pull request #134355 from liggitt/fix-rv-call
Fix passing runtime.Object to HaveValidResourceVersion check
2025-10-01 10:12:17 -07:00
Patrick Ohly
c36c927d18 DRA ResourceSlice: nicer log output
UniqueString rendered as {} in JSON/YAML, which isn't useful... Providing a
MarshalJSON which dumps the string is better.

This enables full object dumps in the ResourceSlice tracker. While at it:
- Consistently log the object content at level 6.
- Use past tense in log messages (recommended style).
- Rename "patch" -> "rule".
2025-10-01 16:40:19 +02:00
Kubernetes Prow Robot
ef95e1fd7e Merge pull request #134318 from xigang/disruption
disruption: remove unused pdb parameter from getExpectedScale method
2025-10-01 07:38:27 -07:00
Kubernetes Prow Robot
41660cec2e Merge pull request #134139 from aojea/better_error_httpstream_handshae
improve httpstream handshake error logging
2025-10-01 07:38:20 -07:00
Jordan Liggitt
af9facf7ba Fix passing runtime.Object to HaveValidResourceVersion check 2025-10-01 10:00:54 -04:00
Hank Freund
af9b314fb4 Propagate backoff duration for crashloop backoff.
Fix lint issues.

Address review comments.

- Modify BackoffError to hold an absolute timestamp instead of duration
- Update pod sync loop to calculate the proper enqueue time based off
  this timestamp

Fix merge conflict error.

Address review comments.
2025-10-01 13:34:10 +00:00
Dan Winship
5ae2372f1b Remove a "helper" function that doesn't really help much
While createServiceReportErr could be fixed to use
framework.ExpectNoErrorWithOffset (and, uh, to log "error creating
Service" rather than "error deleting Service"), it's too trivial to
really be all that useful.
2025-10-01 09:24:02 -04:00
Kubernetes Prow Robot
6bb0bd55a3 Merge pull request #134295 from omerap12/hpa-desiredReplicasCount-metric
Add desired_replicas gauge metric to HPA controller
2025-10-01 05:16:17 -07:00
Aleksander Mistewicz
0cb916d4dc Move metrics calculations to getList
Signed-off-by: Aleksander Mistewicz <amistewicz@google.com>
2025-10-01 13:59:26 +02:00
Kubernetes Prow Robot
bded66365e Merge pull request #134258 from mayank-agrwl/apiserver-lease-gc
Make APIServerLeaseGC controller context-aware
2025-10-01 03:34:17 -07:00
Antonio Ojea
fc19fcfb73 improve httpstream handshake error logging
Some tests are flaking in this function, having a better logged
error will help to understand the cause.

Also modify the Handshake function to always write an http error,
otherwise we have inconsistencies in the codebase that is using the
function and since we are already passing the http writer it makes sense
to not just return an error and delegate the response to the caller.
2025-10-01 09:17:00 +00:00
Kubernetes Prow Robot
1a54b78999 Merge pull request #134259 from mayank-agrwl/legacy-token-tracking-controller
Make legacytokentracking controller context aware
2025-10-01 02:04:18 -07:00
Tim Hockin
89b975c6d3 Add comments 2025-10-01 06:42:41 +00:00
Tim Hockin
199c9ac77a Remove ExpectInvalid()
All use cases are converted.

Co-Authored-by: Yongrui Lin <yongrlin@outlook.com>
2025-10-01 06:42:41 +00:00
Tim Hockin
8b08c8e59c Remove ExpectRegexpsByPath()
All use cases are converted.

Co-Authored-by: Yongrui Lin <yongrlin@outlook.com>
2025-10-01 06:42:39 +00:00
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
Patrick Ohly
02a51e3712 DRA ResourceSlice tracker: explain test a bit better, fix -run
Instead of creating a new test case, the permutation is passed down. This
enables adding the event numbers to the log output, which is useful to
understand better which output belongs to which input:

    === RUN   TestListPatchedResourceSlices/update-patch/2_3_0_1
    tracker.go:396: I0929 14:28:40.032318] event #1: ResourceSlice add slice="s1"
    tracker.go:581: I0929 14:28:40.032404] event #1: syncing ResourceSlice resourceslice="s1"
    tracker.go:659: I0929 14:28:40.032446] event #1: ResourceSlice synced resourceslice="s1" change="add"
    tracker.go:396: I0929 14:28:40.032502] event #2: ResourceSlice add slice="s2"
    tracker.go:581: I0929 14:28:40.032536] event #2: syncing ResourceSlice resourceslice="s2"
    tracker.go:659: I0929 14:28:40.032568] event #2: ResourceSlice synced resourceslice="s2" change="add"
    tracker.go:463: I0929 14:28:40.032609] event #0/#0: DeviceTaintRule add patch="rule"
    tracker.go:581: I0929 14:28:40.032639] event #0/#0: syncing ResourceSlice resourceslice="s1"
    tracker.go:703: I0929 14:28:40.032675] event #0/#0: processing DeviceTaintRule resourceslice="s1" deviceTaintRule="rule"
    tracker.go:807: I0929 14:28:40.032712] event #0/#0: applying matching DeviceTaintRule resourceslice="s1" deviceTaintRule="rule" device="driver1.example.com/pool-1/device-1"
    tracker.go:868: I0929 14:28:40.032780] event #0/#0: Assigned new taint ID, no matching taint resourceslice="s1" deviceTaintRule="rule" device="driver1.example.com/pool-1/device-1" taintID=0 taint="example.com/taint=tainted:NoExecute"
    tracker.go:654: I0929 14:28:40.033023] event #0/#0: ResourceSlice synced resourceslice="s1" change="update" diff=<
        	@@ -23,7 +23,32 @@
        	     "BindingConditions": null,
        	     "BindingFailureConditions": null,
        	     "AllowMultipleAllocations": null,
        	-    "Taints": null
        	+    "Taints": [
        	+     {
        	+      "Rule": {
        	+       "metadata": {
        	+        "name": "rule"
        	+       },
        	+       "spec": {
        	+        "deviceSelector": {
        	+         "pool": "pool-1"
        	+        },
        	+        "taint": {
        	+         "key": "example.com/taint",
        	+         "value": "tainted",
        	+         "effect": "NoExecute",
        	+         "timeAdded": "2006-01-02T15:04:05Z"
        	+        }
        	+       },
        	+       "status": {}
        	+      },
        	+      "ID": 1,
        	+      "key": "example.com/taint",
        	+      "value": "tainted",
        	+      "effect": "NoExecute",
        	+      "timeAdded": "2006-01-02T15:04:05Z"
        	+     }
        	+    ]
        	    }
        	   ],
        	   "Taints": null,
         >
    tracker.go:482: I0929 14:28:40.033224] event #0/#1: DeviceTaintRule update patch="rule" diff=<
        	@@ -4,7 +4,7 @@
        	  },
        	  "spec": {
        	   "deviceSelector": {
        	-   "pool": "pool-1"
        	+   "pool": "pool-2"
        	   },
        	   "taint": {
        	    "key": "example.com/taint",
         >
    tracker.go:581: I0929 14:28:40.033285] event #0/#1: syncing ResourceSlice resourceslice="s1"
    tracker.go:703: I0929 14:28:40.033319] event #0/#1: processing DeviceTaintRule resourceslice="s1" deviceTaintRule="rule"
    tracker.go:654: I0929 14:28:40.033478] event #0/#1: ResourceSlice synced resourceslice="s1" change="update" diff=<
        	@@ -23,32 +23,7 @@
        	     "BindingConditions": null,
        	     "BindingFailureConditions": null,
        	     "AllowMultipleAllocations": null,
        	-    "Taints": [
        	-     {
        	-      "Rule": {
        	-       "metadata": {
        	-        "name": "rule"
        	-       },
        	-       "spec": {
        	-        "deviceSelector": {
        	-         "pool": "pool-1"
        	-        },
        	-        "taint": {
        	-         "key": "example.com/taint",
        	-         "value": "tainted",
        	-         "effect": "NoExecute",
        	-         "timeAdded": "2006-01-02T15:04:05Z"
        	-        }
        	-       },
        	-       "status": {}
        	-      },
        	-      "ID": 1,
        	-      "key": "example.com/taint",
        	-      "value": "tainted",
        	-      "effect": "NoExecute",
        	-      "timeAdded": "2006-01-02T15:04:05Z"
        	-     }
        	-    ]
        	+    "Taints": null
        	    }
        	   ],
        	   "Taints": null,
         >
    tracker.go:581: I0929 14:28:40.033601] event #0/#1: syncing ResourceSlice resourceslice="s2"
    tracker.go:703: I0929 14:28:40.033633] event #0/#1: processing DeviceTaintRule resourceslice="s2" deviceTaintRule="rule"
    ...

Disabling event checking only worked when actually running all sub-tests. When
selectively running only one permutation with -run, the boolean variable was
wrong:

    $ go test -run='.*/^update-patch$' ./staging/src/k8s.io/dynamic-resource-allocation/resourceslice/tracker/
    ok  	k8s.io/dynamic-resource-allocation/resourceslice/tracker

    $ go test -run='.*/^update-patch$/3_2_0_1' ./staging/src/k8s.io/dynamic-resource-allocation/resourceslice/tracker/
    --- FAIL: TestListPatchedResourceSlices (0.01s)
        --- FAIL: TestListPatchedResourceSlices/update-patch (0.00s)
            --- FAIL: TestListPatchedResourceSlices/update-patch/3_2_0_1 (0.00s)

                tracker_test.go:762:
                     	Error Trace:	/nvme/gopath/src/k8s.io/kubernetes/staging/src/k8s.io/dynamic-resource-allocation/resourceslice/tracker/tracker_test.go:762
                     	            				/nvme/gopath/src/k8s.io/kubernetes/staging/src/k8s.io/dynamic-resource-allocation/resourceslice/tracker/tracker_test.go:856
                    	Error:      	Not equal:
                    	            	expected: []tracker.handlerEvent{tracker.handlerEvent{event:"add", oldObj:(*api.ResourceSlice)(nil), newObj:(*api.ResourceSlice)(0xc000301d40)}, tracker.handlerEvent{event:"add", oldObj:(*api.ResourceSlice)(nil), newObj:(*api.ResourceSlice)(0xc000346000)}}
                    	            	actual  : []tracker.handlerEvent{tracker.handlerEvent{event:"add", oldObj:(*api.ResourceSlice)(nil), newObj:(*api.ResourceSlice)(0xc0001f9ba0)}, tracker.handlerEvent{event:"add", oldObj:(*api.ResourceSlice)(nil), newObj:(*api.ResourceSlice)(0xc000301d40)}, tracker.handlerEvent{event:"update", oldObj:(*api.ResourceSlice)(0xc000301d40), newObj:(*api.ResourceSlice)(0xc0003dba00)}, tracker.handlerEvent{event:"update", oldObj:(*api.ResourceSlice)(0xc0003dba00), newObj:(*api.ResourceSlice)(0xc000301d40)}, tracker.handlerEvent{event:"update", oldObj:(*api.ResourceSlice)(0xc0001f9ba0), newObj:(*api.ResourceSlice)(0xc0003dbba0)}}

Now permutations are detected automatically based on the indices.

While at it, documentation gets moved around a bit to make reading test cases
easier without going to the implementation.
2025-09-30 20:44:54 +02: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
Humble Devassy Chirammal
723d1555a7 test: update CSI sidecar images to latest versions
Update CSI sidecar container images in test manifests:
- livenessprobe: v2.15.0 → v2.17.0
- csi-attacher: v4.8.0 → v4.10.0
- csi-provisioner: v5.1.0 → v5.3.0
- csi-resizer: v1.13.1 → v1.14.0

Signed-off-by: Humble Devassy Chirammal <humble.devassy@gmail.com>
2025-09-30 18:50:08 +05:30
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
Mayank Agrawal
b0460eedba Make legacytokentracking controller context aware 2025-09-29 21:41:47 -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
Heba Elayoty
fe681cfd8f update comments
Signed-off-by: Heba Elayoty <heelayot@microsoft.com>
2025-09-29 21:31:11 +00:00
Heba Elayoty
83163d0b4a update comments on beta apis
Signed-off-by: Heba Elayoty <heelayot@microsoft.com>
2025-09-29 14:02:17 -07:00