linkerd2/jaeger/cmd
Kevin Leimkuhler 2442ca07bf
Parse Pod labels for owning Deployment instead of name (#8920)
Closes #8916

When a random Pod (meshed or not) is created in the `linkerd`, `linkerd-viz`, or
`linkerd-jaeger` namespaces their respective `check` subcommands can fail.

We parse Pod names for their owning Deployment by assuming the Pod name has a
randomized suffix. For example, the `linkerd-destination` Deployment creates the
`linkerd-destination-58c57dd675-7tthr` Pod. We split the name on `-` and take
the first two parts (`["linkerd", "destination"]`); those first two parts make
up the Deployment name.

Now, if a random Pod is created in the namespace with the name `test`, we apply
that same logic but hit a runtime error when trying to get the first two parts
of the split. `test` did not split at all since it contains no `-` and therefore
we error with `slice bounds out of range`.

To fix this, we now use the fact that all Linkerd components have a
`linkerd.io/control-plane-component` or `component` label with a value that is
the owning Deployment. This allows us to avoid any extra parsing logic and just
look at a single label value.

Additionally, some of these checks get all the Pods in a namespace with the
`GetPodsByNamespace` method but we don't always need something so general. In
the places where we are checking specifically for Linkerd components, we can
narrow this further by using the expected LabelSelector such as
`linkerd.io/extension=viz`.

Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
2022-07-19 12:14:55 -06:00
..
testdata Allow extension deployments to be evicted by autoscaler (#8828) 2022-07-12 10:46:31 -07:00
check.go Parse Pod labels for owning Deployment instead of name (#8920) 2022-07-19 12:14:55 -06:00
dashboard.go Run extension checks when linkerd check is invoked (#5647) 2021-02-11 10:50:16 -06:00
install.go cli: consistent flag to ignore cluster on install (#7564) 2022-01-19 13:08:26 -08:00
install_test.go test: Diff structured YAML when possible (#8432) 2022-05-10 08:40:29 -07:00
list.go add resource aware completion in jaeger and multicluster (#6183) 2021-05-28 13:45:30 -05:00
main_test.go jaeger: add install unit tests (#6166) 2021-05-24 13:21:22 -07:00
root.go Remove namespace from charts and split them into `linkerd-crd` and `linkerd-control-plane` (#6635) 2021-12-10 15:53:08 -05:00
uninstall.go Add support for legacy names in extension uninstall (#6226) 2021-06-08 20:18:52 +05:30