mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
support fieldSelector spec.schedulerName
This commit is contained in:
parent
2820b45caa
commit
58669f6f1d
@ -192,6 +192,7 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
|
|||||||
"spec.nodeName",
|
"spec.nodeName",
|
||||||
"spec.restartPolicy",
|
"spec.restartPolicy",
|
||||||
"spec.serviceAccountName",
|
"spec.serviceAccountName",
|
||||||
|
"spec.schedulerName",
|
||||||
"status.phase",
|
"status.phase",
|
||||||
"status.hostIP",
|
"status.hostIP",
|
||||||
"status.podIP":
|
"status.podIP":
|
||||||
|
@ -196,9 +196,10 @@ func PodToSelectableFields(pod *api.Pod) fields.Set {
|
|||||||
// amount of allocations needed to create the fields.Set. If you add any
|
// amount of allocations needed to create the fields.Set. If you add any
|
||||||
// field here or the number of object-meta related fields changes, this should
|
// field here or the number of object-meta related fields changes, this should
|
||||||
// be adjusted.
|
// be adjusted.
|
||||||
podSpecificFieldsSet := make(fields.Set, 6)
|
podSpecificFieldsSet := make(fields.Set, 7)
|
||||||
podSpecificFieldsSet["spec.nodeName"] = pod.Spec.NodeName
|
podSpecificFieldsSet["spec.nodeName"] = pod.Spec.NodeName
|
||||||
podSpecificFieldsSet["spec.restartPolicy"] = string(pod.Spec.RestartPolicy)
|
podSpecificFieldsSet["spec.restartPolicy"] = string(pod.Spec.RestartPolicy)
|
||||||
|
podSpecificFieldsSet["spec.schedulerName"] = string(pod.Spec.SchedulerName)
|
||||||
podSpecificFieldsSet["status.phase"] = string(pod.Status.Phase)
|
podSpecificFieldsSet["status.phase"] = string(pod.Status.Phase)
|
||||||
podSpecificFieldsSet["status.podIP"] = string(pod.Status.PodIP)
|
podSpecificFieldsSet["status.podIP"] = string(pod.Status.PodIP)
|
||||||
return generic.AddObjectMetaFieldsSet(podSpecificFieldsSet, &pod.ObjectMeta, true)
|
return generic.AddObjectMetaFieldsSet(podSpecificFieldsSet, &pod.ObjectMeta, true)
|
||||||
|
@ -71,6 +71,20 @@ func TestMatchPod(t *testing.T) {
|
|||||||
fieldSelector: fields.ParseSelectorOrDie("spec.restartPolicy=Never"),
|
fieldSelector: fields.ParseSelectorOrDie("spec.restartPolicy=Never"),
|
||||||
expectMatch: false,
|
expectMatch: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
in: &api.Pod{
|
||||||
|
Spec: api.PodSpec{SchedulerName: "scheduler1"},
|
||||||
|
},
|
||||||
|
fieldSelector: fields.ParseSelectorOrDie("spec.schedulerName=scheduler1"),
|
||||||
|
expectMatch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
in: &api.Pod{
|
||||||
|
Spec: api.PodSpec{SchedulerName: "scheduler1"},
|
||||||
|
},
|
||||||
|
fieldSelector: fields.ParseSelectorOrDie("spec.schedulerName=scheduler2"),
|
||||||
|
expectMatch: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
in: &api.Pod{
|
in: &api.Pod{
|
||||||
Status: api.PodStatus{Phase: api.PodRunning},
|
Status: api.PodStatus{Phase: api.PodRunning},
|
||||||
|
Loading…
Reference in New Issue
Block a user