From 96ab232f5f77b7619904541091b97bc22b1d3f47 Mon Sep 17 00:00:00 2001 From: kerthcet Date: Tue, 6 Jun 2023 16:25:24 +0800 Subject: [PATCH] Remove reasons from PodConditionType Signed-off-by: kerthcet --- pkg/apis/core/types.go | 6 ------ pkg/printers/internalversion/printers.go | 4 ++-- pkg/printers/internalversion/printers_test.go | 5 +++-- pkg/registry/core/pod/strategy.go | 3 ++- pkg/registry/core/pod/strategy_test.go | 3 ++- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/pkg/apis/core/types.go b/pkg/apis/core/types.go index 04ffd250b61..8e26f2cc883 100644 --- a/pkg/apis/core/types.go +++ b/pkg/apis/core/types.go @@ -2543,12 +2543,6 @@ const ( PodReady PodConditionType = "Ready" // PodInitialized means that all init containers in the pod have started successfully. PodInitialized PodConditionType = "Initialized" - // PodReasonUnschedulable reason in PodScheduled PodCondition means that the scheduler - // can't schedule the pod right now, for example due to insufficient resources in the cluster. - PodReasonUnschedulable = "Unschedulable" - // PodReasonSchedulingGated reason in PodScheduled PodCondition means that the scheduler - // skips scheduling the pod because one or more scheduling gates are still present. - PodReasonSchedulingGated = "SchedulingGated" // ContainersReady indicates whether all containers in the pod are ready. ContainersReady PodConditionType = "ContainersReady" // DisruptionTarget indicates the pod is about to be terminated due to a diff --git a/pkg/printers/internalversion/printers.go b/pkg/printers/internalversion/printers.go index 3509a55f157..0ab4e060001 100644 --- a/pkg/printers/internalversion/printers.go +++ b/pkg/printers/internalversion/printers.go @@ -826,8 +826,8 @@ func printPod(pod *api.Pod, options printers.GenerateOptions) ([]metav1.TableRow // If the Pod carries {type:PodScheduled, reason:WaitingForGates}, set reason to 'SchedulingGated'. for _, condition := range pod.Status.Conditions { - if condition.Type == api.PodScheduled && condition.Reason == api.PodReasonSchedulingGated { - reason = api.PodReasonSchedulingGated + if condition.Type == api.PodScheduled && condition.Reason == apiv1.PodReasonSchedulingGated { + reason = apiv1.PodReasonSchedulingGated } } diff --git a/pkg/printers/internalversion/printers_test.go b/pkg/printers/internalversion/printers_test.go index 8f4a7f0ee86..2edbcc406f8 100644 --- a/pkg/printers/internalversion/printers_test.go +++ b/pkg/printers/internalversion/printers_test.go @@ -25,6 +25,7 @@ import ( "time" "github.com/google/go-cmp/cmp" + apiv1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" @@ -1513,12 +1514,12 @@ func TestPrintPod(t *testing.T) { { Type: api.PodScheduled, Status: api.ConditionFalse, - Reason: api.PodReasonSchedulingGated, + Reason: apiv1.PodReasonSchedulingGated, }, }, }, }, - []metav1.TableRow{{Cells: []interface{}{"test15", "0/2", api.PodReasonSchedulingGated, "0", ""}}}, + []metav1.TableRow{{Cells: []interface{}{"test15", "0/2", apiv1.PodReasonSchedulingGated, "0", ""}}}, }, } diff --git a/pkg/registry/core/pod/strategy.go b/pkg/registry/core/pod/strategy.go index ec5e2195c6d..b0380228137 100644 --- a/pkg/registry/core/pod/strategy.go +++ b/pkg/registry/core/pod/strategy.go @@ -26,6 +26,7 @@ import ( "strings" "time" + apiv1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" @@ -686,7 +687,7 @@ func applyWaitingForSchedulingGatesCondition(pod *api.Pod) { pod.Status.Conditions = append(pod.Status.Conditions, api.PodCondition{ Type: api.PodScheduled, Status: api.ConditionFalse, - Reason: api.PodReasonSchedulingGated, + Reason: apiv1.PodReasonSchedulingGated, Message: "Scheduling is blocked due to non-empty scheduling gates", }) } diff --git a/pkg/registry/core/pod/strategy_test.go b/pkg/registry/core/pod/strategy_test.go index 625f8550efe..76f589a1642 100644 --- a/pkg/registry/core/pod/strategy_test.go +++ b/pkg/registry/core/pod/strategy_test.go @@ -26,6 +26,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + apiv1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -351,7 +352,7 @@ func TestWaitingForGatesCondition(t *testing.T) { want: api.PodCondition{ Type: api.PodScheduled, Status: api.ConditionFalse, - Reason: api.PodReasonSchedulingGated, + Reason: apiv1.PodReasonSchedulingGated, Message: "Scheduling is blocked due to non-empty scheduling gates", }, },