mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 14:14:39 +00:00
DRA API: check "AdminAccess in use" only once
This is simpler and an opportunity to explain the concept.
This commit is contained in:
@@ -182,21 +182,26 @@ func dropDisabledDRAAdminAccessFields(newClaim, oldClaim *resource.ResourceClaim
|
|||||||
// No need to drop anything.
|
// No need to drop anything.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if draAdminAccessFeatureInUse(oldClaim) {
|
||||||
|
// If anything was set in the past, then fields must not get
|
||||||
|
// dropped on potentially unrelated updates and, for example,
|
||||||
|
// adding a status with AdminAccess=true is allowed. The
|
||||||
|
// scheduler typically doesn't do that (it also checks the
|
||||||
|
// feature gate and refuses to schedule), but the apiserver
|
||||||
|
// would allow it.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for i := range newClaim.Spec.Devices.Requests {
|
for i := range newClaim.Spec.Devices.Requests {
|
||||||
if newClaim.Spec.Devices.Requests[i].AdminAccess != nil && !draAdminAccessFeatureInUse(oldClaim) {
|
|
||||||
newClaim.Spec.Devices.Requests[i].AdminAccess = nil
|
newClaim.Spec.Devices.Requests[i].AdminAccess = nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if newClaim.Status.Allocation == nil {
|
if newClaim.Status.Allocation == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for i := range newClaim.Status.Allocation.Devices.Results {
|
for i := range newClaim.Status.Allocation.Devices.Results {
|
||||||
if newClaim.Status.Allocation.Devices.Results[i].AdminAccess != nil && !draAdminAccessFeatureInUse(oldClaim) {
|
|
||||||
newClaim.Status.Allocation.Devices.Results[i].AdminAccess = nil
|
newClaim.Status.Allocation.Devices.Results[i].AdminAccess = nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func draAdminAccessFeatureInUse(claim *resource.ResourceClaim) bool {
|
func draAdminAccessFeatureInUse(claim *resource.ResourceClaim) bool {
|
||||||
|
@@ -108,12 +108,15 @@ func dropDisabledDRAAdminAccessFields(newClaimTemplate, oldClaimTemplate *resour
|
|||||||
// No need to drop anything.
|
// No need to drop anything.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if draAdminAccessFeatureInUse(oldClaimTemplate) {
|
||||||
|
// If anything was set in the past, then fields must not get
|
||||||
|
// dropped on potentially unrelated updates.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for i := range newClaimTemplate.Spec.Spec.Devices.Requests {
|
for i := range newClaimTemplate.Spec.Spec.Devices.Requests {
|
||||||
if newClaimTemplate.Spec.Spec.Devices.Requests[i].AdminAccess != nil && !draAdminAccessFeatureInUse(oldClaimTemplate) {
|
|
||||||
newClaimTemplate.Spec.Spec.Devices.Requests[i].AdminAccess = nil
|
newClaimTemplate.Spec.Spec.Devices.Requests[i].AdminAccess = nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func draAdminAccessFeatureInUse(claimTemplate *resource.ResourceClaimTemplate) bool {
|
func draAdminAccessFeatureInUse(claimTemplate *resource.ResourceClaimTemplate) bool {
|
||||||
|
Reference in New Issue
Block a user