From 67f0d980340eaff141f2e48831223edf9c9b8339 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Fri, 20 Feb 2026 12:35:40 +0100 Subject: [PATCH] DRA device taints: automatically bump TimeAdded when changing effect In practice, TimeAdded is managed by the API server. When admins used DeviceTaintRule to simulate eviction, then change the effect to really evict, it is useful to calculate tolerations based on the time when that second update happened. Therefore the TimeAdded field gets bumped automatically when changing the effect. Kubernetes-commit: f28dc4139208e64fe2882cd44d548c25020f2e3a --- applyconfigurations/resource/v1/devicetaint.go | 11 ++++++++++- applyconfigurations/resource/v1alpha3/devicetaint.go | 11 ++++++++++- applyconfigurations/resource/v1beta1/devicetaint.go | 11 ++++++++++- applyconfigurations/resource/v1beta2/devicetaint.go | 11 ++++++++++- 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/applyconfigurations/resource/v1/devicetaint.go b/applyconfigurations/resource/v1/devicetaint.go index db98da8b8..c65c88e05 100644 --- a/applyconfigurations/resource/v1/devicetaint.go +++ b/applyconfigurations/resource/v1/devicetaint.go @@ -43,8 +43,17 @@ type DeviceTaintApplyConfiguration struct { // nodes is not valid here. More effects may get added in the future. // Consumers must treat unknown effects like None. Effect *resourcev1.DeviceTaintEffect `json:"effect,omitempty"` - // TimeAdded represents the time at which the taint was added. + // TimeAdded represents the time at which the taint was added or + // (only in a DeviceTaintRule) the effect was modified. // Added automatically during create or update if not set. + // + // In addition, in a DeviceTaintRule a value provided during + // an update gets replaced with the current time if the provided + // value is the same as the old one and the new effect is different. + // Changing the key and/or value while keeping the effect unchanged + // is possible and does not update the time stamp because the eviction + // which uses it is either already started (NoExecute) or + // not started yet (NoEffect, NoSchedule). TimeAdded *metav1.Time `json:"timeAdded,omitempty"` } diff --git a/applyconfigurations/resource/v1alpha3/devicetaint.go b/applyconfigurations/resource/v1alpha3/devicetaint.go index d9c2c6f48..719168dbe 100644 --- a/applyconfigurations/resource/v1alpha3/devicetaint.go +++ b/applyconfigurations/resource/v1alpha3/devicetaint.go @@ -43,8 +43,17 @@ type DeviceTaintApplyConfiguration struct { // nodes is not valid here. More effects may get added in the future. // Consumers must treat unknown effects like None. Effect *resourcev1alpha3.DeviceTaintEffect `json:"effect,omitempty"` - // TimeAdded represents the time at which the taint was added. + // TimeAdded represents the time at which the taint was added or + // (only in a DeviceTaintRule) the effect was modified. // Added automatically during create or update if not set. + // + // In addition, in a DeviceTaintRule a value provided during + // an update gets replaced with the current time if the provided + // value is the same as the old one and the new effect is different. + // Changing the key and/or value while keeping the effect unchanged + // is possible and does not update the time stamp because the eviction + // which uses it is either already started (NoExecute) or + // not started yet (NoEffect, NoSchedule). TimeAdded *v1.Time `json:"timeAdded,omitempty"` } diff --git a/applyconfigurations/resource/v1beta1/devicetaint.go b/applyconfigurations/resource/v1beta1/devicetaint.go index 55c7d58a6..32b37402c 100644 --- a/applyconfigurations/resource/v1beta1/devicetaint.go +++ b/applyconfigurations/resource/v1beta1/devicetaint.go @@ -43,8 +43,17 @@ type DeviceTaintApplyConfiguration struct { // nodes is not valid here. More effects may get added in the future. // Consumers must treat unknown effects like None. Effect *resourcev1beta1.DeviceTaintEffect `json:"effect,omitempty"` - // TimeAdded represents the time at which the taint was added. + // TimeAdded represents the time at which the taint was added or + // (only in a DeviceTaintRule) the effect was modified. // Added automatically during create or update if not set. + // + // In addition, in a DeviceTaintRule a value provided during + // an update gets replaced with the current time if the provided + // value is the same as the old one and the new effect is different. + // Changing the key and/or value while keeping the effect unchanged + // is possible and does not update the time stamp because the eviction + // which uses it is either already started (NoExecute) or + // not started yet (NoEffect, NoSchedule). TimeAdded *v1.Time `json:"timeAdded,omitempty"` } diff --git a/applyconfigurations/resource/v1beta2/devicetaint.go b/applyconfigurations/resource/v1beta2/devicetaint.go index 8049f52cc..91abce3bb 100644 --- a/applyconfigurations/resource/v1beta2/devicetaint.go +++ b/applyconfigurations/resource/v1beta2/devicetaint.go @@ -43,8 +43,17 @@ type DeviceTaintApplyConfiguration struct { // nodes is not valid here. More effects may get added in the future. // Consumers must treat unknown effects like None. Effect *resourcev1beta2.DeviceTaintEffect `json:"effect,omitempty"` - // TimeAdded represents the time at which the taint was added. + // TimeAdded represents the time at which the taint was added or + // (only in a DeviceTaintRule) the effect was modified. // Added automatically during create or update if not set. + // + // In addition, in a DeviceTaintRule a value provided during + // an update gets replaced with the current time if the provided + // value is the same as the old one and the new effect is different. + // Changing the key and/or value while keeping the effect unchanged + // is possible and does not update the time stamp because the eviction + // which uses it is either already started (NoExecute) or + // not started yet (NoEffect, NoSchedule). TimeAdded *v1.Time `json:"timeAdded,omitempty"` }