fix(node-installer): avoid false positive via grep process itself #152
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was testing with the latest v0.15.0 node-installer image and stumbled upon the following issue.
My K8s cluster happened to be a KinD cluster and yet the node-installer script thought I was using k0s and thus failed like so:
It turns out that the current logic here will exit 0 because the latter
grep
process itself is successfully found -- whereas it should not be counted.For example, on my kind-worker node:
There are a couple ways to fix this. In this first iteration, I've elected to use pgrep which won't report its own process as an eligible result.
However, I'm not 100% certain that this binary is present in all of the supported distros...(pgrep exists in the node-installer image, so we are good there)Another option would be to tweak the logic to add an additional
grep -v grep
at the end of the pipe, egps aux | grep kubelet | grep /var/lib/k0s/bin/kubelet | grep -vq grep
. Happy to go with this approach if preferred.PS I'm still not totally sure why the similar microk8s detection method doesn't also produce a false positive. eg on my kind-worker, it exits 1 as expected: