From 3630af2b47627bafa59938939a0c621c1afe940b Mon Sep 17 00:00:00 2001 From: Isaiah Stapleton Date: Wed, 18 Sep 2024 14:03:48 -0400 Subject: [PATCH] Change response for pod with user in no class to 200 This fixes the issue where the webhook returns a 400 response in the case where the pods user doesn't belong to any class. This caused issues for deployments trying to start up pods but being unable to because of the error response from the webhook. Signed-off-by: Isaiah Stapleton --- container-images/assign-class-label/mutate.py | 2 +- container-images/assign-class-label/tests/test_mutate.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/container-images/assign-class-label/mutate.py b/container-images/assign-class-label/mutate.py index 98054ab..9b67759 100644 --- a/container-images/assign-class-label/mutate.py +++ b/container-images/assign-class-label/mutate.py @@ -131,7 +131,7 @@ def mutate_pod() -> Response: ) ).model_dump() ), - 400, + 200, {'content-type': 'application/json'}, ) diff --git a/container-images/assign-class-label/tests/test_mutate.py b/container-images/assign-class-label/tests/test_mutate.py index 82c5254..6386333 100644 --- a/container-images/assign-class-label/tests/test_mutate.py +++ b/container-images/assign-class-label/tests/test_mutate.py @@ -71,7 +71,7 @@ def test_request_no_metadata(client): }, ) - assert res.status_code == 400 + assert res.status_code == 200 assert res.json == { 'apiVersion': 'admission.k8s.io/v1', 'kind': 'AdmissionReview', @@ -172,7 +172,7 @@ def test_no_user(client): }, ) - assert res.status_code == 400 + assert res.status_code == 200 assert res.json == { 'apiVersion': 'admission.k8s.io/v1', 'kind': 'AdmissionReview', @@ -195,7 +195,7 @@ def test_no_user(client): }, ) - assert res.status_code == 400 + assert res.status_code == 200 assert res.json == { 'apiVersion': 'admission.k8s.io/v1', 'kind': 'AdmissionReview', @@ -229,7 +229,7 @@ def test_empty_group_members(client): }, ) - assert res.status_code == 400 + assert res.status_code == 200 assert res.json == { 'apiVersion': 'admission.k8s.io/v1', 'kind': 'AdmissionReview',