mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Merge pull request #30060 from gmarek/schedulerPredicates-json
Automatic merge from submit-queue Fix JSON-based scheduler predicates tests Fixes two completely broken tests. cc @kevin-wangzefeng @jayunit100
This commit is contained in:
commit
10b0f58f51
@ -41,6 +41,79 @@ const minPodCPURequest int64 = 500
|
|||||||
// variable set in BeforeEach, never modified afterwards
|
// variable set in BeforeEach, never modified afterwards
|
||||||
var masterNodes sets.String
|
var masterNodes sets.String
|
||||||
|
|
||||||
|
var podWithNodeAffinity = api.Pod{
|
||||||
|
ObjectMeta: api.ObjectMeta{
|
||||||
|
Name: "with-labels",
|
||||||
|
Annotations: map[string]string{
|
||||||
|
"scheduler.alpha.kubernetes.io/affinity": `{
|
||||||
|
"nodeAffinity": {
|
||||||
|
"requiredDuringSchedulingIgnoredDuringExecution": {
|
||||||
|
"nodeSelectorTerms": [{
|
||||||
|
"matchExpressions": [{
|
||||||
|
"key": "kubernetes.io/e2e-az-name",
|
||||||
|
"operator": "In",
|
||||||
|
"values": ["e2e-az1", "e2e-az2"]
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`,
|
||||||
|
"another-annotation-key": "another-annotation-value",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Spec: api.PodSpec{
|
||||||
|
Containers: []api.Container{
|
||||||
|
{
|
||||||
|
Name: "with-labels",
|
||||||
|
Image: "gcr.io/google_containers/pause:2.0",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var podWithPodAffinity = api.Pod{
|
||||||
|
ObjectMeta: api.ObjectMeta{
|
||||||
|
Name: "with-newlabels",
|
||||||
|
Annotations: map[string]string{
|
||||||
|
"scheduler.alpha.kubernetes.io/affinity": `{
|
||||||
|
"podAffinity": {
|
||||||
|
"requiredDuringSchedulingIgnoredDuringExecution": [{
|
||||||
|
"labelSelector": {
|
||||||
|
"matchExpressions": [{
|
||||||
|
"key": "security",
|
||||||
|
"operator": "In",
|
||||||
|
"values":["S1"]
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
"topologyKey": "kubernetes.io/hostname"
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
"podAntiAffinity": {
|
||||||
|
"requiredDuringSchedulingIgnoredDuringExecution": [{
|
||||||
|
"labelSelector": {
|
||||||
|
"matchExpressions": [{
|
||||||
|
"key": "security",
|
||||||
|
"operator": "In",
|
||||||
|
"values":["S2"]
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
"topologyKey": "kubernetes.io/hostname"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}`,
|
||||||
|
"another-annotation-key": "another-annotation-value",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Spec: api.PodSpec{
|
||||||
|
Containers: []api.Container{
|
||||||
|
{
|
||||||
|
Name: "with-newlabels",
|
||||||
|
Image: "gcr.io/google_containers/pause:2.0",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// Returns a number of currently scheduled and not scheduled Pods.
|
// Returns a number of currently scheduled and not scheduled Pods.
|
||||||
func getPodsScheduled(pods *api.PodList) (scheduledPods, notScheduledPods []api.Pod) {
|
func getPodsScheduled(pods *api.PodList) (scheduledPods, notScheduledPods []api.Pod) {
|
||||||
for _, pod := range pods.Items {
|
for _, pod := range pods.Items {
|
||||||
@ -708,9 +781,9 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() {
|
|||||||
defer framework.RemoveLabelOffNode(c, nodeName, k)
|
defer framework.RemoveLabelOffNode(c, nodeName, k)
|
||||||
|
|
||||||
By("Trying to launch a pod that with NodeAffinity setting as embedded JSON string in the annotation value.")
|
By("Trying to launch a pod that with NodeAffinity setting as embedded JSON string in the annotation value.")
|
||||||
labelPodName := "with-labels"
|
labelPodName := podWithNodeAffinity.Name
|
||||||
testPodPath := "test/e2e/testing-manifests/node-selection/pod-with-node-affinity.yaml"
|
pod, err = c.Pods(ns).Create(&podWithNodeAffinity)
|
||||||
framework.RunKubectlOrDie("create", "-f", testPodPath, fmt.Sprintf("--namespace=%v", ns))
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
// check that pod got scheduled. We intentionally DO NOT check that the
|
// check that pod got scheduled. We intentionally DO NOT check that the
|
||||||
// pod is running because this will create a race condition with the
|
// pod is running because this will create a race condition with the
|
||||||
@ -1223,10 +1296,9 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() {
|
|||||||
defer framework.RemoveLabelOffNode(c, nodeName, k)
|
defer framework.RemoveLabelOffNode(c, nodeName, k)
|
||||||
|
|
||||||
By("Trying to launch a pod that with PodAffinity & PodAntiAffinity setting as embedded JSON string in the annotation value.")
|
By("Trying to launch a pod that with PodAffinity & PodAntiAffinity setting as embedded JSON string in the annotation value.")
|
||||||
labelPodName := "with-newlabels"
|
labelPodName := podWithPodAffinity.Name
|
||||||
testPodPath := "test/e2e/testing-manifests/node-selection/pod-with-pod-affinity.yaml"
|
pod, err = c.Pods(ns).Create(&podWithPodAffinity)
|
||||||
framework.RunKubectlOrDie("create", "-f", testPodPath, fmt.Sprintf("--namespace=%v", ns))
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
// check that pod got scheduled. We intentionally DO NOT check that the
|
// check that pod got scheduled. We intentionally DO NOT check that the
|
||||||
// pod is running because this will create a race condition with the
|
// pod is running because this will create a race condition with the
|
||||||
// kubelet and the scheduler: the scheduler might have scheduled a pod
|
// kubelet and the scheduler: the scheduler might have scheduled a pod
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Pod
|
|
||||||
metadata:
|
|
||||||
name: with-labels
|
|
||||||
annotations:
|
|
||||||
scheduler.alpha.kubernetes.io/affinity: >
|
|
||||||
{
|
|
||||||
"nodeAffinity": {
|
|
||||||
"requiredDuringSchedulingIgnoredDuringExecution": {
|
|
||||||
"nodeSelectorTerms": [
|
|
||||||
{
|
|
||||||
"matchExpressions": [
|
|
||||||
{
|
|
||||||
"key": "kubernetes.io/e2e-az-name",
|
|
||||||
"operator": "In",
|
|
||||||
"values": ["e2e-az1", "e2e-az2"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
another-annotation-key: another-annotation-value
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: with-labels
|
|
||||||
image: gcr.io/google_containers/pause:2.0
|
|
@ -1,37 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Pod
|
|
||||||
metadata:
|
|
||||||
name: with-newlabels
|
|
||||||
annotations:
|
|
||||||
scheduler.alpha.kubernetes.io/affinity: >
|
|
||||||
{
|
|
||||||
"podAffinity": {
|
|
||||||
"requiredDuringSchedulingIgnoredDuringExecution": [{
|
|
||||||
"labelSelector": {
|
|
||||||
"matchExpressions": [{
|
|
||||||
"key": "security",
|
|
||||||
"operator": "In",
|
|
||||||
"values":["S1"]
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
"topologyKey": "kubernetes.io/hostname"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
"podAntiAffinity": {
|
|
||||||
"requiredDuringSchedulingIgnoredDuringExecution": [{
|
|
||||||
"labelSelector": {
|
|
||||||
"matchExpressions": [{
|
|
||||||
"key": "security",
|
|
||||||
"operator": "In",
|
|
||||||
"values":["S2"]
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
"topologyKey": "kubernetes.io/hostname"
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
another-annotation-key: another-annotation-value
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: with-newlabels
|
|
||||||
image: gcr.io/google_containers/pause:2.0
|
|
Loading…
Reference in New Issue
Block a user