Merge pull request #79554 from draveness/feature/remove-critical-pod-annotation

feat: cleanup pod critical pod annotations feature
This commit is contained in:
Kubernetes Prow Robot
2019-07-11 22:03:04 -07:00
committed by GitHub
56 changed files with 161 additions and 366 deletions

View File

@@ -36,7 +36,6 @@ go_library(
"//pkg/apis/core:go_default_library",
"//pkg/apis/scheduling:go_default_library",
"//pkg/features:go_default_library",
"//pkg/kubelet/types:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/scheduling/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",

View File

@@ -35,7 +35,6 @@ import (
api "k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/apis/scheduling"
"k8s.io/kubernetes/pkg/features"
kubelettypes "k8s.io/kubernetes/pkg/kubelet/types"
)
const (
@@ -178,13 +177,6 @@ func (p *priorityPlugin) admitPod(a admission.Attributes) error {
if operation == admission.Create {
var priority int32
var preemptionPolicy *apiv1.PreemptionPolicy
// TODO: @ravig - This is for backwards compatibility to ensure that critical pods with annotations just work fine.
// Remove when no longer needed.
if len(pod.Spec.PriorityClassName) == 0 &&
utilfeature.DefaultFeatureGate.Enabled(features.ExperimentalCriticalPodAnnotation) &&
kubelettypes.IsCritical(a.GetNamespace(), pod.Annotations) {
pod.Spec.PriorityClassName = scheduling.SystemClusterCritical
}
if len(pod.Spec.PriorityClassName) == 0 {
var err error
var pcName string

View File

@@ -422,23 +422,7 @@ func TestPodAdmission(t *testing.T) {
Priority: &intPriority,
},
},
// pod[7]: Pod with a critical priority annotation. This needs to be automatically assigned
// system-cluster-critical
{
ObjectMeta: metav1.ObjectMeta{
Name: "pod-w-system-priority",
Namespace: "kube-system",
Annotations: map[string]string{"scheduler.alpha.kubernetes.io/critical-pod": ""},
},
Spec: api.PodSpec{
Containers: []api.Container{
{
Name: containerName,
},
},
},
},
// pod[8]: Pod with a system priority class name in non-system namespace
// pod[7]: Pod with a system priority class name in non-system namespace
{
ObjectMeta: metav1.ObjectMeta{
Name: "pod-w-system-priority-in-nonsystem-namespace",
@@ -453,7 +437,7 @@ func TestPodAdmission(t *testing.T) {
PriorityClassName: scheduling.SystemClusterCritical,
},
},
// pod[9]: Pod with a priority value that matches the resolved priority
// pod[8]: Pod with a priority value that matches the resolved priority
{
ObjectMeta: metav1.ObjectMeta{
Name: "pod-w-zero-priority-in-nonsystem-namespace",
@@ -468,7 +452,7 @@ func TestPodAdmission(t *testing.T) {
Priority: &zeroPriority,
},
},
// pod[10]: Pod with a priority value that matches the resolved default priority
// pod[9]: Pod with a priority value that matches the resolved default priority
{
ObjectMeta: metav1.ObjectMeta{
Name: "pod-w-priority-matching-default-priority",
@@ -483,7 +467,7 @@ func TestPodAdmission(t *testing.T) {
Priority: &defaultClass2.Value,
},
},
// pod[11]: Pod with a priority value that matches the resolved priority
// pod[10]: Pod with a priority value that matches the resolved priority
{
ObjectMeta: metav1.ObjectMeta{
Name: "pod-w-priority-matching-resolved-default-priority",
@@ -499,7 +483,7 @@ func TestPodAdmission(t *testing.T) {
Priority: &systemClusterCritical.Value,
},
},
// pod[12]: Pod without a preemption policy that matches the resolved preemption policy
// pod[11]: Pod without a preemption policy that matches the resolved preemption policy
{
ObjectMeta: metav1.ObjectMeta{
Name: "pod-never-preemption-policy-matching-resolved-preemption-policy",
@@ -516,7 +500,7 @@ func TestPodAdmission(t *testing.T) {
PreemptionPolicy: nil,
},
},
// pod[13]: Pod with a preemption policy that matches the resolved preemption policy
// pod[12]: Pod with a preemption policy that matches the resolved preemption policy
{
ObjectMeta: metav1.ObjectMeta{
Name: "pod-preemption-policy-matching-resolved-preemption-policy",
@@ -533,7 +517,7 @@ func TestPodAdmission(t *testing.T) {
PreemptionPolicy: &preemptLowerPriority,
},
},
// pod[14]: Pod with a preemption policy that does't match the resolved preemption policy
// pod[13]: Pod with a preemption policy that does't match the resolved preemption policy
{
ObjectMeta: metav1.ObjectMeta{
Name: "pod-preemption-policy-not-matching-resolved-preemption-policy",
@@ -551,8 +535,6 @@ func TestPodAdmission(t *testing.T) {
},
},
}
// Enable ExperimentalCriticalPodAnnotation feature gate.
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ExperimentalCriticalPodAnnotation, true)()
// Enable NonPreemptingPriority feature gate.
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NonPreemptingPriority, true)()
tests := []struct {
@@ -638,18 +620,10 @@ func TestPodAdmission(t *testing.T) {
true,
nil,
},
{
"pod with critical pod annotation",
[]*scheduling.PriorityClass{systemClusterCritical},
*pods[7],
scheduling.SystemCriticalPriority,
false,
nil,
},
{
"pod with system critical priority in non-system namespace",
[]*scheduling.PriorityClass{systemClusterCritical},
*pods[8],
*pods[7],
scheduling.SystemCriticalPriority,
true,
nil,
@@ -657,7 +631,7 @@ func TestPodAdmission(t *testing.T) {
{
"pod with priority that matches computed priority",
[]*scheduling.PriorityClass{nondefaultClass1},
*pods[9],
*pods[8],
0,
false,
nil,
@@ -665,7 +639,7 @@ func TestPodAdmission(t *testing.T) {
{
"pod with priority that matches default priority",
[]*scheduling.PriorityClass{defaultClass2},
*pods[10],
*pods[9],
defaultClass2.Value,
false,
nil,
@@ -673,7 +647,7 @@ func TestPodAdmission(t *testing.T) {
{
"pod with priority that matches resolved priority",
[]*scheduling.PriorityClass{systemClusterCritical},
*pods[11],
*pods[10],
systemClusterCritical.Value,
false,
nil,
@@ -681,7 +655,7 @@ func TestPodAdmission(t *testing.T) {
{
"pod with nil preemtpion policy",
[]*scheduling.PriorityClass{preemptionPolicyClass},
*pods[12],
*pods[11],
preemptionPolicyClass.Value,
false,
nil,
@@ -689,7 +663,7 @@ func TestPodAdmission(t *testing.T) {
{
"pod with preemtpion policy that matches resolved preemtpion policy",
[]*scheduling.PriorityClass{preemptionPolicyClass},
*pods[13],
*pods[12],
preemptionPolicyClass.Value,
false,
&preemptLowerPriority,
@@ -697,7 +671,7 @@ func TestPodAdmission(t *testing.T) {
{
"pod with preemtpion policy that does't matches resolved preemtpion policy",
[]*scheduling.PriorityClass{preemptionPolicyClass},
*pods[14],
*pods[13],
preemptionPolicyClass.Value,
true,
&preemptLowerPriority,