Skip to content

Commit

Permalink
webhook: remove some annotation verify (#1921)
Browse files Browse the repository at this point in the history
Signed-off-by: acejilam <acejilam@gmail.com>
  • Loading branch information
ls-2018 authored Feb 25, 2024
1 parent 19de595 commit 97f7a7b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions pkg/webhook/pod/validating/verify_annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"k8s.io/apimachinery/pkg/util/validation/field"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"

"github.com/koordinator-sh/koordinator/apis/extension"
"github.com/koordinator-sh/koordinator/pkg/util/reservation"
)

Expand Down Expand Up @@ -59,7 +58,6 @@ func (h *PodValidatingHandler) clusterReservationValidatingPod(ctx context.Conte
}

var forbidAnnotations = []string{
extension.AnnotationReservationAllocated,
reservation.AnnotationReservePod,
}

Expand All @@ -71,7 +69,7 @@ func forbidSpecialAnnotations(pod *corev1.Pod) field.ErrorList {

for _, annotation := range forbidAnnotations {
if _, ok := pod.Annotations[annotation]; ok {
errorList = append(errorList, field.Forbidden(field.NewPath("annotations", extension.AnnotationReservationAllocated), "cannot set in annotations"))
errorList = append(errorList, field.Forbidden(field.NewPath("annotations", annotation), "cannot set in annotations"))
}
}
return errorList
Expand Down
6 changes: 3 additions & 3 deletions pkg/webhook/pod/validating/verify_annotations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"

configv1alpha1 "github.com/koordinator-sh/koordinator/apis/config/v1alpha1"
"github.com/koordinator-sh/koordinator/apis/extension"
"github.com/koordinator-sh/koordinator/pkg/util"
"github.com/koordinator-sh/koordinator/pkg/util/reservation"
)

func init() {
Expand All @@ -54,13 +54,13 @@ func TestClusterReservationValidatingPod(t *testing.T) {
newPod: &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
extension.AnnotationReservationAllocated: "",
reservation.AnnotationReservePod: "",
},
},
},
wantErr: true,
wantAllowed: false,
wantReason: `annotations.scheduling.koordinator.sh/reservation-allocated: Forbidden: cannot set in annotations`,
wantReason: `annotations.scheduling.koordinator.sh/reserve-pod: Forbidden: cannot set in annotations`,
},
}

Expand Down

0 comments on commit 97f7a7b

Please sign in to comment.