Skip to content
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

Open
2 of 4 tasks
Sevy007 opened this issue Sep 19, 2021 · 2 comments
Open
2 of 4 tasks

Comments

@Sevy007
Copy link

Sevy007 commented Sep 19, 2021

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 setting pipefail, 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 with set -o pipefail; so the return code is != 0 if one of the commands in the pipe is !=0

Expected 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?)

  • Yes
  • No

Possible Solution

I attached a patch as patch.txt

Steps to Reproduce

  1. Blacklist one of the systems on which k3s should be installed in the router, so the internet access is blocked or tamper the /etc/resolv.conf file of a system so name resolution doesn't work properly.
  2. Run the installation on this modified machine via k3sup

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

  • What Kubernetes distribution are you using?
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.4", GitCommit:"3cce4a82b44f032d0cd1a1790e6d2f5a55d20aae", GitTreeState:"clean", BuildDate:"2021-08-11T18:16:05Z", GoVersion:"go1.16.7", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.1+k3s1", GitCommit:"b66760fccdddfc98fa107ec38c86c5e2814e559d", GitTreeState:"clean", BuildDate:"2020-09-17T17:17:18Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"linux/arm"}
  • What OS or type or VM are you using for your cluster? Where is it hosted? (for k3sup install/join):

Rasbian on RaspberryPi

  • Operating System and version (e.g. Linux, Windows, MacOS):
uname -a
Linux name 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l GNU/Linux

cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

"Be part of the solution"

Subject to approval, are you willing to work on a Pull Request for this issue or feature request?

  • Yes
  • No
@alexellis
Copy link
Owner

alexellis commented Oct 12, 2021

Hi there, it looks like you edited the template and removed the important "Steps to reproduce this issue" section.

So if curl fails here this will not be visible in the return code.

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

@Sevy007
Copy link
Author

Sevy007 commented Oct 12, 2021

Hi there, it looks like you edited the template and removed the important "Steps to reproduce this issue" section.

Oh sorry for that.

So if curl fails here this will not be visible in the return code.

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

I edited the first comments with the missing parts from the template. I hope this is fine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants