mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 18:54:06 +00:00
dra api: fix status updates
Changing object meta is not supposed to be possible via status updates. For example, it circumvents RBAC permission checks.
This commit is contained in:
parent
55d1518126
commit
27df75c577
@ -20,6 +20,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
@ -125,6 +126,7 @@ func (podSchedulingStatusStrategy) PrepareForUpdate(ctx context.Context, obj, ol
|
||||
newScheduling := obj.(*resource.PodSchedulingContext)
|
||||
oldScheduling := old.(*resource.PodSchedulingContext)
|
||||
newScheduling.Spec = oldScheduling.Spec
|
||||
metav1.ResetObjectMetaForStatus(&newScheduling.ObjectMeta, &oldScheduling.ObjectMeta)
|
||||
}
|
||||
|
||||
func (podSchedulingStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
@ -125,6 +126,7 @@ func (resourceclaimStatusStrategy) PrepareForUpdate(ctx context.Context, obj, ol
|
||||
newClaim := obj.(*resource.ResourceClaim)
|
||||
oldClaim := old.(*resource.ResourceClaim)
|
||||
newClaim.Spec = oldClaim.Spec
|
||||
metav1.ResetObjectMetaForStatus(&newClaim.ObjectMeta, &oldClaim.ObjectMeta)
|
||||
}
|
||||
|
||||
func (resourceclaimStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||
|
Loading…
Reference in New Issue
Block a user