mirror of https://github.com/linkerd/linkerd2.git
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> |
||
|---|---|---|
| .. | ||
| charts/linkerd-jaeger | ||
| cmd | ||
| injector | ||
| pkg/labels | ||
| static | ||