Skip to content
This repository has been archived by the owner on Jun 28, 2023. It is now read-only.

The install.sh script fails if user doesn't have sudo access. #1647

Closed
GrahamDumpleton opened this issue Sep 10, 2021 · 2 comments · Fixed by #3260
Closed

The install.sh script fails if user doesn't have sudo access. #1647

GrahamDumpleton opened this issue Sep 10, 2021 · 2 comments · Fixed by #3260
Assignees
Labels
good-first-issue Good for newcomers help-wanted Looking for contributors to help kind/enhancement An enhancement to an existing capability kind/feature A request for a new feature owner/core-eng Work executed by TCE's core engineering team
Milestone

Comments

@GrahamDumpleton
Copy link

Bug Report

If a user does not have sudo access or sudo is prohibited in some way, the install.sh script will fail when run, but in failing it doesn't actually detect the failure and tries to keep running.

Further, the documentation does not seem to warn you of the following:

  • That by default you must have sudo access to run the install.sh script or it will not work.
  • That the install.sh script by default cannot be run directly as root and that you need to set ALLOW_INSTALL_AS_ROOT environment variable to install as root.
  • If overridden and installed as root, there is no mention of non root users needing to install plugins in their own user environment using a separate step.
  • That if you don't have sudo access you can still run the install.sh script as a normal user by creating $HOME/bin directory.
  • That if you use the path of creating $HOME/bin and installing as a normal user, that you will also need to add that directory to your PATH so the tanzu command is found.

Expected Behavior

The documentation should better explain the options/requirements for running the install.sh script.

The install.sh script should properly detect when sudo fails and generate a decent error message explaining how you can install it into $HOME/bin instead.

Steps to Reproduce the Bug

On a system where the user does not have sudo access run:

./tce-linux-amd64-v0.8.0-rc.1/install.sh

Doing this in a docker container is a good option for doing this and actually highlights why the current behaviour is bad as it causes failures if someone tries use it from a Dockerfile. First they will find it fails to run when run as root as they will not know about the special environment variable, but then as non root user it will fail due to lack of sudo access.

When the script is run as normal user without sudo access, the script fails with:

+ ALLOW_INSTALL_AS_ROOT=
+ [[ 1001 -eq 0 ]]
+++ dirname ./tce-linux-amd64-v0.8.0-rc.1/install.sh
++ cd ./tce-linux-amd64-v0.8.0-rc.1
++ pwd
+ MY_DIR=/home/eduk8s/exercises/tce-linux-amd64-v0.8.0-rc.1
++ uname
+ BUILD_OS=Linux
+ case "${BUILD_OS}" in
+ XDG_DATA_HOME=/home/eduk8s/.local/share
+ echo /home/eduk8s/.local/share
/home/eduk8s/.local/share
++ command -v tanzu
+ TANZU_BIN_PATH=
+ [[ -n '' ]]
+ TANZU_BIN_PATH=/usr/local/bin
+ [[ :/home/eduk8s/bin:/opt/eduk8s/bin:/opt/kubernetes/bin:/opt/code-server/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: == *\:\/\h\o\m\e\/\e\d\u\k\8\s\/\b\i\n\:* ]]
+ [[ -d /home/eduk8s/bin ]]
+ echo Installing tanzu cli to /usr/local/bin
Installing tanzu cli to /usr/local/bin
+ sudo install /home/eduk8s/exercises/tce-linux-amd64-v0.8.0-rc.1/bin/tanzu /usr/local/bin
sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?
+ mkdir -p /home/eduk8s/.local/share/tanzu-cli
+ for plugin in "${MY_DIR}"/bin/tanzu-plugin*
+ install /home/eduk8s/exercises/tce-linux-amd64-v0.8.0-rc.1/bin/tanzu-plugin-builder /home/eduk8s/.local/share/tanzu-cli
+ for plugin in "${MY_DIR}"/bin/tanzu-plugin*
+ install /home/eduk8s/exercises/tce-linux-amd64-v0.8.0-rc.1/bin/tanzu-plugin-cluster /home/eduk8s/.local/share/tanzu-cli
+ for plugin in "${MY_DIR}"/bin/tanzu-plugin*
+ install /home/eduk8s/exercises/tce-linux-amd64-v0.8.0-rc.1/bin/tanzu-plugin-conformance /home/eduk8s/.local/share/tanzu-cli
+ for plugin in "${MY_DIR}"/bin/tanzu-plugin*
+ install /home/eduk8s/exercises/tce-linux-amd64-v0.8.0-rc.1/bin/tanzu-plugin-diagnostics /home/eduk8s/.local/share/tanzu-cli
+ for plugin in "${MY_DIR}"/bin/tanzu-plugin*
+ install /home/eduk8s/exercises/tce-linux-amd64-v0.8.0-rc.1/bin/tanzu-plugin-kubernetes-release /home/eduk8s/.local/share/tanzu-cli
+ for plugin in "${MY_DIR}"/bin/tanzu-plugin*
+ install /home/eduk8s/exercises/tce-linux-amd64-v0.8.0-rc.1/bin/tanzu-plugin-login /home/eduk8s/.local/share/tanzu-cli
+ for plugin in "${MY_DIR}"/bin/tanzu-plugin*
+ install /home/eduk8s/exercises/tce-linux-amd64-v0.8.0-rc.1/bin/tanzu-plugin-management-cluster /home/eduk8s/.local/share/tanzu-cli
+ for plugin in "${MY_DIR}"/bin/tanzu-plugin*
+ install /home/eduk8s/exercises/tce-linux-amd64-v0.8.0-rc.1/bin/tanzu-plugin-package /home/eduk8s/.local/share/tanzu-cli
+ for plugin in "${MY_DIR}"/bin/tanzu-plugin*
+ install /home/eduk8s/exercises/tce-linux-amd64-v0.8.0-rc.1/bin/tanzu-plugin-pinniped-auth /home/eduk8s/.local/share/tanzu-cli
+ for plugin in "${MY_DIR}"/bin/tanzu-plugin*
+ install /home/eduk8s/exercises/tce-linux-amd64-v0.8.0-rc.1/bin/tanzu-plugin-standalone-cluster /home/eduk8s/.local/share/tanzu-cli
+ mkdir -p /home/eduk8s/.local/share/tce
+ install /home/eduk8s/exercises/tce-linux-amd64-v0.8.0-rc.1/uninstall.sh /home/eduk8s/.local/share/tce
+ TANZU_PLUGIN_CACHE=/home/eduk8s/.cache/tanzu/catalog.yaml
+ [[ -n /home/eduk8s/.cache/tanzu/catalog.yaml ]]
+ echo 'Removing old plugin cache from /home/eduk8s/.cache/tanzu/catalog.yaml'
Removing old plugin cache from /home/eduk8s/.cache/tanzu/catalog.yaml
+ rm -f /home/eduk8s/.cache/tanzu/catalog.yaml
+ TANZU_CLI_NO_INIT=true
+ tanzu init
./tce-linux-amd64-v0.8.0-rc.1/install.sh: line 72: tanzu: command not found
++ grep tce
++ tanzu plugin repo list
./tce-linux-amd64-v0.8.0-rc.1/install.sh: line 73: tanzu: command not found
+ TCE_REPO=
+ [[ -z '' ]]
+ tanzu plugin repo add --name tce --gcp-bucket-name tce-cli-plugins --gcp-root-path artifacts
./tce-linux-amd64-v0.8.0-rc.1/install.sh: line 75: tanzu: command not found
+ echo 'Installation complete!'
Installation complete!

Note how the sudo failed:

+ sudo install /home/eduk8s/exercises/tce-linux-amd64-v0.8.0-rc.1/bin/tanzu /usr/local/bin
sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?

but the script kept running, resulting in later steps also failing as tanzu command couldn't be found.

Environment Details

  • Build version (tanzu version): tce-linux-amd64-v0.8.0-rc.1
  • Operating System (client): Linux

cc @jorgemoralespou

@GrahamDumpleton GrahamDumpleton added kind/bug A bug in an existing capability triage/needs-triage Needs triage by TCE maintainers labels Sep 10, 2021
@dvonthenen
Copy link
Contributor

dvonthenen commented Sep 10, 2021

Yea, you need sudo access if you choose to install or your environment is setup in such a way that you can only install to /usr/local/bin (based on TKG docs). If you have a ~/bin directory where it is in path, the install should work without sudo. We should maybe also have a secondary fallback to GOPATH/bin

The root check was added only to allow the CI system to install because all runners run as root.

@joshrosso
Copy link
Contributor

joshrosso commented Sep 11, 2021

After some conversations in Slack, seems general UX improvement around the logging we present to users when running install would go a long way.

We'd love help with this! For now, putting it to after GA.

@joshrosso joshrosso added kind/enhancement An enhancement to an existing capability help-wanted Looking for contributors to help good-first-issue Good for newcomers owner/core-eng Work executed by TCE's core engineering team and removed kind/bug A bug in an existing capability triage/needs-triage Needs triage by TCE maintainers labels Sep 11, 2021
@joshrosso joshrosso added this to the v0.10.0 milestone Sep 11, 2021
@joshrosso joshrosso added the kind/feature A request for a new feature label Oct 12, 2021
@dvonthenen dvonthenen self-assigned this Dec 6, 2021
@joshrosso joshrosso modified the milestones: v0.10.0, v0.11.0 Jan 4, 2022
@stmcginnis stmcginnis self-assigned this Feb 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good-first-issue Good for newcomers help-wanted Looking for contributors to help kind/enhancement An enhancement to an existing capability kind/feature A request for a new feature owner/core-eng Work executed by TCE's core engineering team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants