New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return code for install command should be checked for all pipe commands #343
Comments
Hi there, it looks like you edited the template and removed the important "Steps to reproduce this issue" section.
Why would curl fail? And what happens if it does? Please edit the issue and fill out the issue template properly: https://raw.githubusercontent.com/alexellis/k3sup/master/.github/ISSUE_TEMPLATE.md Alex |
Oh sorry for that.
I edited the first comments with the missing parts from the template. I hope this is fine now. |
Currently the code just executes a command like
curl -sfL https://get.k3s.io | K3S_URL='https://<ip>:6443' K3S_TOKEN=’<token> INSTALL_K3S_VERSION='v1.19.1+k3s1' INSTALL_K3S_EXEC='server --server https://<ip>:6443' sh -s -
in https://github.com/alexellis/k3sup/blob/master/cmd/join.go#L319. The return code is checked afterwards. The problem is that the return code of this command is always the return code of the last command in the pipe. So if
curl
fails here this will not be visible in the return code. This behaviour in bash can be changed by settingpipefail
, see https://stackoverflow.com/questions/5934108/how-to-use-the-return-code-of-the-first-program-in-a-pipe-command-line. So the getscript in https://github.com/alexellis/k3sup/blob/master/cmd/install.go#L41 should be prefixed the command withset -o pipefail;
so the return code is != 0 if one of the commands in the pipe is !=0Expected Behaviour
If curl fails e.g. due to a network error or a DNS resolution issue an error should be returned.
Current Behaviour
If curl fails no feedback is given. The tool just stops without any feedback.
Are you a GitHub Sponsor (Yes/No?)
Possible Solution
I attached a patch as patch.txt
Steps to Reproduce
Context
I tried to install on a machine that had a broken internet access and no proper error was returned as the curl failed which was not detected.
Your Environment
k3sup install/join
):Rasbian on RaspberryPi
"Be part of the solution"
Subject to approval, are you willing to work on a Pull Request for this issue or feature request?
The text was updated successfully, but these errors were encountered: