mirror of https://github.com/linkerd/linkerd2.git
GetPodsFor() called for an ExternalName service shouldn't return any pods (#2226)
Running `linkerd routes` for some resource was returning, besides the data for the resource, additional rows for each `ExternalName` service in the namespace. Fixes #2216 Signed-off-by: Alejandro Pedraza <alejandro@buoyant.io>
This commit is contained in:
parent
5b054785e5
commit
1ef25390ec
|
|
@ -307,6 +307,9 @@ func (api *API) GetPodsFor(obj runtime.Object, includeFailed bool) ([]*apiv1.Pod
|
|||
selector = labels.Set(typed.Spec.Selector).AsSelector()
|
||||
|
||||
case *apiv1.Service:
|
||||
if typed.Spec.Type == apiv1.ServiceTypeExternalName {
|
||||
return []*apiv1.Pod{}, nil
|
||||
}
|
||||
namespace = typed.Namespace
|
||||
selector = labels.Set(typed.Spec.Selector).AsSelector()
|
||||
|
||||
|
|
|
|||
|
|
@ -362,7 +362,7 @@ func TestGetPodsFor(t *testing.T) {
|
|||
|
||||
// all 3 of these are used to seed the k8s client
|
||||
k8sResInput string // object used as input to GetPodFor()
|
||||
k8sResResults []string // expected results from GetPodFor
|
||||
k8sResResults []string // expected results from GetPodsFor
|
||||
k8sResMisc []string // additional k8s objects for seeding the k8s client
|
||||
}
|
||||
|
||||
|
|
@ -393,6 +393,57 @@ status:
|
|||
phase: Finished`,
|
||||
},
|
||||
},
|
||||
// Retrieve pods associated to a ClusterIP service
|
||||
getPodsForExpected{
|
||||
err: nil,
|
||||
k8sResInput: `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: emoji-svc
|
||||
namespace: emojivoto
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: emoji-svc`,
|
||||
k8sResResults: []string{`
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: emojivoto-meshed-finished
|
||||
namespace: emojivoto
|
||||
labels:
|
||||
app: emoji-svc
|
||||
status:
|
||||
phase: Running`,
|
||||
},
|
||||
k8sResMisc: []string{},
|
||||
},
|
||||
// ExternalName services shouldn't return any pods
|
||||
getPodsForExpected{
|
||||
err: nil,
|
||||
k8sResInput: `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: emoji-svc
|
||||
namespace: emojivoto
|
||||
spec:
|
||||
type: ExternalName
|
||||
externalName: someapi.example.com`,
|
||||
k8sResResults: []string{},
|
||||
k8sResMisc: []string{`
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: emojivoto-meshed-finished
|
||||
namespace: emojivoto
|
||||
labels:
|
||||
app: emoji-svc
|
||||
status:
|
||||
phase: Running`,
|
||||
},
|
||||
},
|
||||
getPodsForExpected{
|
||||
err: nil,
|
||||
k8sResInput: `
|
||||
|
|
|
|||
Loading…
Reference in New Issue