mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-12-08 17:15:36 +00:00
Graduate PodSchedulingReadiness to stable
This commit is contained in:
@@ -25,12 +25,9 @@ import (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
typedv1 "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||
kubeapiservertesting "k8s.io/kubernetes/cmd/kube-apiserver/app/testing"
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
"k8s.io/kubernetes/test/integration"
|
||||
"k8s.io/kubernetes/test/integration/framework"
|
||||
)
|
||||
@@ -689,47 +686,11 @@ func TestMutablePodSchedulingDirectives(t *testing.T) {
|
||||
defer framework.DeleteNamespaceOrDie(client, ns, t)
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
create *v1.Pod
|
||||
update *v1.Pod
|
||||
enableSchedulingGates bool
|
||||
err string
|
||||
name string
|
||||
create *v1.Pod
|
||||
update *v1.Pod
|
||||
err string
|
||||
}{
|
||||
{
|
||||
name: "node selector is immutable when AllowMutableNodeSelector is false",
|
||||
create: &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-pod",
|
||||
},
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Name: "fake-name",
|
||||
Image: "fakeimage",
|
||||
},
|
||||
},
|
||||
SchedulingGates: []v1.PodSchedulingGate{{Name: "baz"}},
|
||||
},
|
||||
},
|
||||
update: &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-pod",
|
||||
},
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Name: "fake-name",
|
||||
Image: "fakeimage",
|
||||
},
|
||||
},
|
||||
NodeSelector: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
SchedulingGates: []v1.PodSchedulingGate{{Name: "baz"}},
|
||||
},
|
||||
},
|
||||
err: "Forbidden: pod updates may not change fields other than `spec.containers[*].image",
|
||||
},
|
||||
{
|
||||
name: "adding node selector is allowed for gated pods",
|
||||
create: &v1.Pod{
|
||||
@@ -763,7 +724,6 @@ func TestMutablePodSchedulingDirectives(t *testing.T) {
|
||||
SchedulingGates: []v1.PodSchedulingGate{{Name: "baz"}},
|
||||
},
|
||||
},
|
||||
enableSchedulingGates: true,
|
||||
},
|
||||
{
|
||||
name: "addition to nodeAffinity is allowed for gated pods",
|
||||
@@ -842,7 +802,6 @@ func TestMutablePodSchedulingDirectives(t *testing.T) {
|
||||
SchedulingGates: []v1.PodSchedulingGate{{Name: "baz"}},
|
||||
},
|
||||
},
|
||||
enableSchedulingGates: true,
|
||||
},
|
||||
{
|
||||
name: "addition to nodeAffinity is allowed for gated pods with nil affinity",
|
||||
@@ -899,12 +858,9 @@ func TestMutablePodSchedulingDirectives(t *testing.T) {
|
||||
SchedulingGates: []v1.PodSchedulingGate{{Name: "baz"}},
|
||||
},
|
||||
},
|
||||
enableSchedulingGates: true,
|
||||
},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodSchedulingReadiness, tc.enableSchedulingGates)()
|
||||
|
||||
if _, err := client.CoreV1().Pods(ns.Name).Create(context.TODO(), tc.create, metav1.CreateOptions{}); err != nil {
|
||||
t.Errorf("Failed to create pod: %v", err)
|
||||
}
|
||||
|
||||
@@ -33,12 +33,9 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/apiserver/pkg/util/feature"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
listersv1 "k8s.io/client-go/listers/core/v1"
|
||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||
configv1 "k8s.io/kube-scheduler/config/v1"
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
"k8s.io/kubernetes/pkg/scheduler"
|
||||
schedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
|
||||
configtesting "k8s.io/kubernetes/pkg/scheduler/apis/config/testing"
|
||||
@@ -2199,8 +2196,6 @@ func TestPreScorePlugin(t *testing.T) {
|
||||
|
||||
// TestPreEnqueuePlugin tests invocation of enqueue plugins.
|
||||
func TestPreEnqueuePlugin(t *testing.T) {
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.PodSchedulingReadiness, true)()
|
||||
|
||||
testContext := testutils.InitTestAPIServer(t, "enqueue-plugin", nil)
|
||||
|
||||
tests := []struct {
|
||||
@@ -2636,8 +2631,6 @@ func (pl *SchedulingGatesPluginWOEvents) EventsToRegister() []framework.ClusterE
|
||||
|
||||
// This test helps to verify registering nil events for schedulingGates plugin works as expected.
|
||||
func TestSchedulingGatesPluginEventsToRegister(t *testing.T) {
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.PodSchedulingReadiness, true)()
|
||||
|
||||
testContext := testutils.InitTestAPIServer(t, "preenqueue-plugin", nil)
|
||||
|
||||
num := func(pl framework.Plugin) int {
|
||||
@@ -2659,12 +2652,12 @@ func TestSchedulingGatesPluginEventsToRegister(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "preEnqueue plugin without event registered",
|
||||
enqueuePlugin: &SchedulingGatesPluginWOEvents{SchedulingGates: schedulinggates.SchedulingGates{EnablePodSchedulingReadiness: true}},
|
||||
enqueuePlugin: &SchedulingGatesPluginWOEvents{SchedulingGates: schedulinggates.SchedulingGates{}},
|
||||
count: 2,
|
||||
},
|
||||
{
|
||||
name: "preEnqueue plugin with event registered",
|
||||
enqueuePlugin: &SchedulingGatesPluginWithEvents{SchedulingGates: schedulinggates.SchedulingGates{EnablePodSchedulingReadiness: true}},
|
||||
enqueuePlugin: &SchedulingGatesPluginWithEvents{SchedulingGates: schedulinggates.SchedulingGates{}},
|
||||
count: 3,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -58,55 +58,33 @@ func TestSchedulingGates(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
pods []*v1.Pod
|
||||
featureEnabled bool
|
||||
want []string
|
||||
rmPodsSchedulingGates []int
|
||||
wantPostGatesRemoval []string
|
||||
}{
|
||||
{
|
||||
name: "feature disabled, regular pods",
|
||||
name: "regular pods",
|
||||
pods: []*v1.Pod{
|
||||
st.MakePod().Name("p1").Container("pause").Obj(),
|
||||
st.MakePod().Name("p2").Container("pause").Obj(),
|
||||
},
|
||||
featureEnabled: false,
|
||||
want: []string{"p1", "p2"},
|
||||
want: []string{"p1", "p2"},
|
||||
},
|
||||
{
|
||||
name: "feature enabled, regular pods",
|
||||
pods: []*v1.Pod{
|
||||
st.MakePod().Name("p1").Container("pause").Obj(),
|
||||
st.MakePod().Name("p2").Container("pause").Obj(),
|
||||
},
|
||||
featureEnabled: true,
|
||||
want: []string{"p1", "p2"},
|
||||
},
|
||||
{
|
||||
name: "feature disabled, one pod carrying scheduling gates",
|
||||
name: "one pod carrying scheduling gates",
|
||||
pods: []*v1.Pod{
|
||||
st.MakePod().Name("p1").SchedulingGates([]string{"foo"}).Container("pause").Obj(),
|
||||
st.MakePod().Name("p2").Container("pause").Obj(),
|
||||
},
|
||||
featureEnabled: false,
|
||||
want: []string{"p1", "p2"},
|
||||
want: []string{"p2"},
|
||||
},
|
||||
{
|
||||
name: "feature enabled, one pod carrying scheduling gates",
|
||||
pods: []*v1.Pod{
|
||||
st.MakePod().Name("p1").SchedulingGates([]string{"foo"}).Container("pause").Obj(),
|
||||
st.MakePod().Name("p2").Container("pause").Obj(),
|
||||
},
|
||||
featureEnabled: true,
|
||||
want: []string{"p2"},
|
||||
},
|
||||
{
|
||||
name: "feature enabled, two pod carrying scheduling gates, and remove gates of one pod",
|
||||
name: "two pod carrying scheduling gates, and remove gates of one pod",
|
||||
pods: []*v1.Pod{
|
||||
st.MakePod().Name("p1").SchedulingGates([]string{"foo"}).Container("pause").Obj(),
|
||||
st.MakePod().Name("p2").SchedulingGates([]string{"bar"}).Container("pause").Obj(),
|
||||
st.MakePod().Name("p3").Container("pause").Obj(),
|
||||
},
|
||||
featureEnabled: true,
|
||||
want: []string{"p3"},
|
||||
rmPodsSchedulingGates: []int{1}, // remove gates of 'p2'
|
||||
wantPostGatesRemoval: []string{"p2"},
|
||||
@@ -115,8 +93,6 @@ func TestSchedulingGates(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodSchedulingReadiness, tt.featureEnabled)()
|
||||
|
||||
// Use zero backoff seconds to bypass backoffQ.
|
||||
// It's intended to not start the scheduler's queue, and hence to
|
||||
// not start any flushing logic. We will pop and schedule the Pods manually later.
|
||||
|
||||
Reference in New Issue
Block a user