mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Merge pull request #66115 from jasonrichardsmith/add-serviceAccount-fieldselector
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. added serviceAccountName to field selectors What this PR does / why we need it: Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #66114 Special notes for your reviewer: ```release-note NONE ```
This commit is contained in:
		@@ -63,6 +63,7 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
 | 
				
			|||||||
				"spec.nodeName",
 | 
									"spec.nodeName",
 | 
				
			||||||
				"spec.restartPolicy",
 | 
									"spec.restartPolicy",
 | 
				
			||||||
				"spec.schedulerName",
 | 
									"spec.schedulerName",
 | 
				
			||||||
 | 
									"spec.serviceAccountName",
 | 
				
			||||||
				"status.phase",
 | 
									"status.phase",
 | 
				
			||||||
				"status.podIP",
 | 
									"status.podIP",
 | 
				
			||||||
				"status.nominatedNodeName":
 | 
									"status.nominatedNodeName":
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -237,10 +237,11 @@ 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, 8)
 | 
						podSpecificFieldsSet := make(fields.Set, 9)
 | 
				
			||||||
	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["spec.schedulerName"] = string(pod.Spec.SchedulerName)
 | 
				
			||||||
 | 
						podSpecificFieldsSet["spec.serviceAccountName"] = string(pod.Spec.ServiceAccountName)
 | 
				
			||||||
	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)
 | 
				
			||||||
	podSpecificFieldsSet["status.nominatedNodeName"] = string(pod.Status.NominatedNodeName)
 | 
						podSpecificFieldsSet["status.nominatedNodeName"] = string(pod.Status.NominatedNodeName)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -86,6 +86,20 @@ func TestMatchPod(t *testing.T) {
 | 
				
			|||||||
			fieldSelector: fields.ParseSelectorOrDie("spec.schedulerName=scheduler2"),
 | 
								fieldSelector: fields.ParseSelectorOrDie("spec.schedulerName=scheduler2"),
 | 
				
			||||||
			expectMatch:   false,
 | 
								expectMatch:   false,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								in: &api.Pod{
 | 
				
			||||||
 | 
									Spec: api.PodSpec{ServiceAccountName: "serviceAccount1"},
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								fieldSelector: fields.ParseSelectorOrDie("spec.serviceAccountName=serviceAccount1"),
 | 
				
			||||||
 | 
								expectMatch:   true,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								in: &api.Pod{
 | 
				
			||||||
 | 
									Spec: api.PodSpec{SchedulerName: "serviceAccount1"},
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								fieldSelector: fields.ParseSelectorOrDie("spec.serviceAccountName=serviceAccount2"),
 | 
				
			||||||
 | 
								expectMatch:   false,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			in: &api.Pod{
 | 
								in: &api.Pod{
 | 
				
			||||||
				Status: api.PodStatus{Phase: api.PodRunning},
 | 
									Status: api.PodStatus{Phase: api.PodRunning},
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user