Commit Graph

3969 Commits

Author SHA1 Message Date
Ayato Tokubi
902c2e0c15 Fix lint errors in dynamicresources_test.go
Signed-off-by: Ayato Tokubi <atokubi@redhat.com>
2025-11-05 10:44:50 +00:00
Ayato Tokubi
c5b1493925 Add test case for claim creation failure in DRAExtendedResources
Extend the `setup` function to support API reactors, allowing custom reactions in tests.

Signed-off-by: Ayato Tokubi <atokubi@redhat.com>
2025-11-05 09:55:28 +00:00
Ayato Tokubi
ea7561b243 Implement scheduler_resourceclaim_creates_total metrics for DRAExtendedResources 2025-11-05 09:53:33 +00:00
fj-naji
c438f8a983 scheduler: Add BindingTimeout args to DynamicResources plugin
Add a new `bindingTimeout` field to DynamicResources plugin args and wire it
into PreBind.

Changes:
- API: add `bindingTimeout` to DynamicResourcesArgs (staging + internal types).
- Defaults: default to 600 seconds when BOTH DRADeviceBindingConditions and
  DRAResourceClaimDeviceStatus are enabled.
- Validation: require >= 1s; forbid when either feature gate is disabled.
- Plugin: plumbs args into `pl.bindingTimeout` and uses it in
  `wait.PollUntilContextTimeout` for binding-condition wait logic.
- Plugin: remove legacy `BindingTimeoutDefaultSeconds`.

Tests:
- Add/adjust unit tests for validation and PreBind timeout path.
- Ensure <1s and negative values are rejected; forbids when gates disabled.
2025-11-04 17:15:19 +00:00
Kubernetes Prow Robot
f09cd625bc Merge pull request #135007 from ania-borowiec/nnn_code_update
KEP-5278 Bring back clearing NominatedNodeName after scheduling or binding failure
2025-11-04 07:14:24 -08:00
Ania Borowiec
a92b987b3d comments 2025-11-04 12:55:16 +00:00
Ania Borowiec
9640da5452 Verify if pod has ongoing async preemption before evicting pods 2025-11-04 11:57:34 +00:00
Ania Borowiec
81448febcf KEP-5278 Clear NominatedNodeName upon scheduling failure 2025-11-04 09:43:51 +00:00
Kubernetes Prow Robot
462c869354 Merge pull request #134326 from sairameshv/global_cache_dra
Add global cache to map between the deviceclass and the extended resource
2025-11-03 10:40:06 -08:00
yliao
3eab698884 fixed unit test and integration test failures
Fix minor nits

Signed-off-by: Sai Ramesh Vanka <svanka@redhat.com>
2025-11-03 20:07:01 +05:30
Kubernetes Prow Robot
4e5220939e Merge pull request #134927 from macsko/dont_delete_pods_with_deletiontimestamp
Don't preempt pods with DeletionTimestamp set
2025-11-03 06:02:14 -08:00
Patrick Ohly
12a0c8ce17 DRA extended resource: chain event handlers
The cache and scheduler event handlers cannot be registered separately in the
informer, that leads to a race (scheduler might schedule based on event before
cache is updated). Chaining event handlers (cache first, then scheduler) avoids
this.

This also ensures that the cache is up-to-date before the scheduler
starts (HasSynced of the handler registration for the cache is checked).

Other changes:
- renamed package to avoid clash with other "cache" packages
- clarified nil handling
- feature gate check before instantiating the cache
- per-test logging
- utilruntime.HandleErrorWithLogger
- simpler cache.DeletedFinalStateUnknown

Signed-off-by: Sai Ramesh Vanka <svanka@redhat.com>
2025-11-03 12:31:17 +05:30
Sai Ramesh Vanka
d8c66ffb63 Add a global cache to support DRA's extended resource to the device
class mapping

- Add a new interface "DeviceClassResolver" in the scheduler framework
- Add a global cache of mapping between the extended resource and the
  device class
- Cache can be leveraged by the k8s api-server, controller-manager along with the scheduler
- This change helps in delegating the requests to the dynamicresource
  plugin based on the mapping during the node update events and thus
avoiding an extra scheduling cycle

Signed-off-by: Sai Ramesh Vanka <svanka@redhat.com>
2025-11-03 12:31:16 +05:30
Kubernetes Prow Robot
a13ad97048 Merge pull request #134949 from natasha41575/ippr-ga
Promote InPlacePodVerticalScaling to GA
2025-10-30 20:06:01 -07:00
Natasha Sarkar
1d9c646892 fix unit tests for ippr ga 2025-10-30 17:28:42 +00:00
Kubernetes Prow Robot
9e284866c3 Merge pull request #134740 from hoskeri/untolerated-taint-generic
Do not log untolerated taint in pod status updates.
2025-10-30 02:22:03 -07:00
Kubernetes Prow Robot
808d320de1 Merge pull request #134956 from yliaog/blockowner
removed BlockOwnerDeletion
2025-10-30 01:26:11 -07:00
yliao
4f647b3f3d removed BlockOwnerDeletion 2025-10-29 22:41:10 +00:00
Kubernetes Prow Robot
412bfec7a1 Merge pull request #134157 from macsko/forget_pod_immediately_when_it_is_deleted
Forget pod from scheduler's cache immediately when it's deleted
2025-10-29 10:14:10 -07:00
Maciej Skoczeń
b29fdd1551 Forget pod from scheduler's cache immediately when it's deleted or has DeletionTimestamp set 2025-10-29 10:00:38 +00:00
Maciej Skoczeń
1502996787 Refactor scheduler event handlers for pods to handle binding event in one place 2025-10-29 09:59:35 +00:00
Maciej Skoczeń
a42581c7d3 Don't preempt pods with DeletionTimestamp set 2025-10-29 09:05:24 +00:00
Abhijit Hoskeri
08b1b1d5a4 Do not log untolerated taint in pod status updates.
The taint toleration plugin records taint keys and values
from non-matching nodes. Taint keys and values may be
sensitive information in some environments.

Use a generic message, and show the info in logs instead.
2025-10-28 10:56:27 -07:00
Kubernetes Prow Robot
d5efbf2ebf Merge pull request #134452 from pohly/dra-ga-feature-gate
DRA: lock to default-on
2025-10-28 07:49:36 -07:00
Kubernetes Prow Robot
f0ed028e75 Merge pull request #133784 from bart0sh/PR197-DRA-process-devices-when-allocatable-is-0
Treat extended resources as inactive when allocatable is 0
2025-10-28 03:29:36 -07:00
Ed Bartosh
1cb45e2a27 DRA: fix scheduling of pods with extended resources
Previously, the scheduler assumed an extended resource was maintained
by a device plugin if its name was present in the node's Allocatable
map, even if its value was zero. This blocked scheduling when a device
plugin was disconnected or uninstalled, because Kubelet still reported
the resource with Allocatable=0.

This change adds a check for the actual allocatable value in addition
to a key presence check, allowing nodes with uninstalled device
plugins to be considered for scheduling.
2025-10-27 16:24:29 +02:00
Patrick Ohly
8b6f98b06e DRA: lock to default-on
The core functionality was enabled by default in 1.34 without any issues that
would have suggested turning it off, so now we can lock it to on-by-default.

Tests which cover disabling the feature must use version emulation.
2025-10-24 20:04:20 +02:00
Kubernetes Prow Robot
ae60c554f8 Merge pull request #134404 from nmn3m/dra-consumable-capacity-autoscaler-contract
Dedicated package for scheduler interaction with DRA structured types
2025-10-24 00:19:33 -07:00
Tim Allclair
debe026b21 Fix unit tests to work with explicit depndencies 2025-10-15 15:04:26 -07: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
Nour
dd8d0e65d4 Dedicated package for scheduler interaction with DRA structured types 2025-10-07 23:14:03 +03:00
Maciej Skoczeń
1137d51b35 Disable SchedulerAsyncAPICalls feature gate due to a known regression 2025-10-03 13:02:02 +00:00
Kubernetes Prow Robot
389507c723 Merge pull request #134294 from ania-borowiec/test_for_rollback
Fix for incorrect activation of preemptor pod waiting for deletion of victim, plus integration test verifying the fix
2025-10-03 03:38:58 -07:00
Ania Borowiec
7c59672213 Fix in code and integration test that verifies that when victim pod is stuck in binding, preemptor pod remains waiting in unschedulable queue until deletion of the victim pod is completed 2025-10-03 09:42:50 +00:00
Kubernetes Prow Robot
f86edc2665 Merge pull request #133929 from huww98/fix-pv-cache-race-v2
scheduler/volumebinding: passive assume cache
2025-10-02 08:42:56 -07:00
Tim Allclair
4986abe0b8 Automated refactoring to use SetFeatureGatesDuringTest 2025-10-01 21:10:53 -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
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
Maciej Skoczeń
d2e6be440c Revert "Merge pull request #133213 from sanposhiho/second-trial-conor"
This reverts commit a2bf45b081, reversing
changes made to 2b2ea27250.
2025-09-24 11:05:16 +00:00
Maciej Skoczeń
4275b8b759 Don't limit the number of goroutines dispatched by the API Dispatcher 2025-09-19 09:36:44 +00:00
hojinchoi
7028ba09db fix: duplicated 'the' in comment 2025-09-18 18:11:44 +09:00
胡玮文
e39ed4a4b4 scheduler/volumebinding: add test for PVAssumeCache 2025-09-13 19:23:03 +08:00
胡玮文
bbee7b9d6b scheduler/volumebinding: rename passive_assume_cache_test.go 2025-09-13 13:16:39 +08:00
胡玮文
4b0eff59c0 scheduler/volumebinding: target AssumeCache UT generic passiveAssumeCache
And removing duplicate tests
2025-09-13 13:15:24 +08:00
Lalit Chauhan
af6b3ed1f5 Add support for k8s-label-key 2025-09-12 16:52:04 +00:00
胡玮文
5a708a7ff0 scheduler/volumebinding: remove Get[API]{PV,PVC}
should be replaced by generic Get[APIObj]
2025-09-13 00:26:46 +08:00
胡玮文
ed19492dc2 scheduler/volumebinding: passive assume cache
Currently volume and dynamic-resource plugin shares an AssumeCache
implementation. However, they features significantly different use case.  DRA
call Assume() on objects returned by APIServer, but volume call Assume() on
objects yet to be sent to the APIServer.

VolumeBinding plugin only makes one update request, while DynamicResource makes
2 requests (add finalizer then update allocation status).  Taking advantage of
this, currently the volume cache is simpler:

1. Reserve: assume PV/PVC will be updated
2. PreBind: really send the update request
3. AssumeCache receives an update from informer and overwrite the assumed state.
   a. if Prebind succeeded, this will surely include the update from step 2.
   b. if PreBind is not finished yet, and this is an irrelevant update, it is safe to
      overwrite the assumed state, because our update in PreBind will surely fail with Conflict.

While for DynamicResource:

1. Reserve: add devices to inFlightAllocations
2. PreBind:
   a. send the 2 update requests
   b. add the returned object into AssumeCache
   c. AssumeCache dispatch events synchronously to update allocatedDevices
   d. remove devices from inFlightAllocations

DynamicResource needs some features from AssumeCache that is not necessary for VolumeBinding:
1. DynamicResource needs strictly ordered update events to update allocatedDevices,
   including those from Assume() and Restore()
2. DynamicResource needs to compare ResourceVersion to prevent the assumed state from being
   overwritten by older version from informer.  While this works, the doc[1] says:
   "you must not compare resource versions for greater-than or less-than relationships".

Given so much difference, it can be beneficial to fork another simpler
AssumeCache for VolumeBinding plugin. Because of no need to send events, the
lite AssumeCache is a passive component. It only record the assumed version
without copying all objects from informer into its local cache. When reading,
we read from both informer and local cache.  So it will always be up-to-date
with informer, no need to wait for event handler.

This resolves a race condition where AssumeCache and scheduler queue both
receive events from informer. When a pod is scheduling due to PV update event,
the PVCache may be not updated yet because it has not processed the relevant
event.

The passive version still listens events from informer, but only for cleaning up
its local cache to save memory.

[1]: https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions
2025-09-13 00:26:45 +08:00
胡玮文
c385a229d4 scheduler/volumebinding: introduce testInformer 2025-09-12 15:11:52 +08:00