-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix auto-update re-exec arguments modified by aliases #50228
Conversation
4c7c3f3
to
ba62d79
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. After reading the issue analysis my first suggestion would be to move away from the global os.Args
, so I'm happy to see this is indeed the fix.
Also, very cool feature 👍
Nit: perhaps worth mentioning this bugfix in the changelog? A bit of marketing for both features involved ;-)
…ate-re-exec-with-aliases
@hugoShaka could you please take a look when you have time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have a test covering the re-exec with alias mechanism? I'm worried someone might break it again in the future and won't detect it.
Added a full-cycle integration test to verify client tools auto-updates within a test cluster by modifying AutoUpdateConfig and AutoUpdateVersion resources. The test executes the login command using alias configurations to ensure no recursive re-execution occurs. The updater binary used in integration tests has been replaced with the `Run` logic of tctl and tsh.
6ce9b27
to
894aab9
Compare
@hugoShaka reminder to review when you have a chance 🙂 |
22392b1
to
5156850
Compare
@hugoShaka I had to restore this part since your last review 894aab9#diff-6ddd22bd400fc52c2062de3b1fc775fdaf05594f85c5ffa5a02262af40f5d62dL163-L182 I mislead myself with this check, after verifying rfd again and draft implementation we should keep priority of env variable version set over that we receive from TELEPORT_TOOLS_VERSION=off tsh login --insecure --proxy localhost:8443 --user teleport We able to completely disable updates, same as override the version which is defined in cluster. Let say cluster target version is set to $ TELEPORT_TOOLS_VERSION=17.1.2 tsh login --insecure --proxy localhost:8443 --user teleport
Update progress: [▒▒▒▒▒▒▒▒▒▒] (Ctrl-C to cancel update)
Enter password for Teleport user teleport:
WARNING: You are using insecure connection to Teleport proxy https://localhost:8443
Enter an OTP code from a device:
> Profile URL: https://localhost:8443
Logged in as: teleport
Cluster: logrotate.teleport
Roles: editor
Kubernetes: enabled
Valid until: 2025-01-17 09:47:45 -0800 PST [valid for 12h0m0s]
Extensions: login-ip, permit-agent-forwarding, permit-port-forwarding, permit-pty, private-key-policy
$ tsh --insecure version
Teleport v17.1.2 git:v17.1.2-0-g5274176 go1.23.4
Proxy version: 17.0.0-dev
Proxy: localhost:8443 So, the version is picked from the environment variable in this case. After logging out and re-logging in, the client tools should update to the version defined in the cluster configuration, exmaple:
Another part is related to double re-execution, as we have
For instance we have When we run a command Previously we set |
In case of double re-execution case we should stop second one to prevent loop re-execution Drop localDir set during compilation
5156850
to
bb59630
Compare
* Fix auto-update re-exec arguments modified by aliases * Make arguments to be required to set * Restore progress bar show before request * Improve integration tests to execute with `tsh` and `tctl` Added a full-cycle integration test to verify client tools auto-updates within a test cluster by modifying AutoUpdateConfig and AutoUpdateVersion resources. The test executes the login command using alias configurations to ensure no recursive re-execution occurs. The updater binary used in integration tests has been replaced with the `Run` logic of tctl and tsh. * Set generated test password by env variable instead of constant value * Restore priority of env check over remote check In case of double re-execution case we should stop second one to prevent loop re-execution Drop localDir set during compilation
* Fix auto-update re-exec arguments modified by aliases * Make arguments to be required to set * Restore progress bar show before request * Improve integration tests to execute with `tsh` and `tctl` Added a full-cycle integration test to verify client tools auto-updates within a test cluster by modifying AutoUpdateConfig and AutoUpdateVersion resources. The test executes the login command using alias configurations to ensure no recursive re-execution occurs. The updater binary used in integration tests has been replaced with the `Run` logic of tctl and tsh. * Set generated test password by env variable instead of constant value * Restore priority of env check over remote check In case of double re-execution case we should stop second one to prevent loop re-execution Drop localDir set during compilation
* Fix auto-update re-exec arguments modified by aliases * Make arguments to be required to set * Restore progress bar show before request * Improve integration tests to execute with `tsh` and `tctl` Added a full-cycle integration test to verify client tools auto-updates within a test cluster by modifying AutoUpdateConfig and AutoUpdateVersion resources. The test executes the login command using alias configurations to ensure no recursive re-execution occurs. The updater binary used in integration tests has been replaced with the `Run` logic of tctl and tsh. * Set generated test password by env variable instead of constant value * Restore priority of env check over remote check In case of double re-execution case we should stop second one to prevent loop re-execution Drop localDir set during compilation
* Fix auto-update re-exec arguments modified by aliases * Make arguments to be required to set * Restore progress bar show before request * Improve integration tests to execute with `tsh` and `tctl` Added a full-cycle integration test to verify client tools auto-updates within a test cluster by modifying AutoUpdateConfig and AutoUpdateVersion resources. The test executes the login command using alias configurations to ensure no recursive re-execution occurs. The updater binary used in integration tests has been replaced with the `Run` logic of tctl and tsh. * Set generated test password by env variable instead of constant value * Restore priority of env check over remote check In case of double re-execution case we should stop second one to prevent loop re-execution Drop localDir set during compilation
* Fix auto-update re-exec arguments modified by aliases * Make arguments to be required to set * Restore progress bar show before request * Improve integration tests to execute with `tsh` and `tctl` Added a full-cycle integration test to verify client tools auto-updates within a test cluster by modifying AutoUpdateConfig and AutoUpdateVersion resources. The test executes the login command using alias configurations to ensure no recursive re-execution occurs. The updater binary used in integration tests has been replaced with the `Run` logic of tctl and tsh. * Set generated test password by env variable instead of constant value * Restore priority of env check over remote check In case of double re-execution case we should stop second one to prevent loop re-execution Drop localDir set during compilation
* Fix auto-update re-exec arguments modified by aliases * Make arguments to be required to set * Restore progress bar show before request * Improve integration tests to execute with `tsh` and `tctl` Added a full-cycle integration test to verify client tools auto-updates within a test cluster by modifying AutoUpdateConfig and AutoUpdateVersion resources. The test executes the login command using alias configurations to ensure no recursive re-execution occurs. The updater binary used in integration tests has been replaced with the `Run` logic of tctl and tsh. * Set generated test password by env variable instead of constant value * Restore priority of env check over remote check In case of double re-execution case we should stop second one to prevent loop re-execution Drop localDir set during compilation
* Fix auto-update re-exec arguments modified by aliases * Make arguments to be required to set * Restore progress bar show before request * Improve integration tests to execute with `tsh` and `tctl` Added a full-cycle integration test to verify client tools auto-updates within a test cluster by modifying AutoUpdateConfig and AutoUpdateVersion resources. The test executes the login command using alias configurations to ensure no recursive re-execution occurs. The updater binary used in integration tests has been replaced with the `Run` logic of tctl and tsh. * Set generated test password by env variable instead of constant value * Restore priority of env check over remote check In case of double re-execution case we should stop second one to prevent loop re-execution Drop localDir set during compilation
In this PR fixed issue related
tsh {alias}
if we define in alias same executable path oftsh
, for instance:~/.tsh/config/config.yaml
we don't spawn new process, instead just re-run the tsh main function with modified execution arguments
teleport/tool/tsh/common/aliases.go
Lines 205 to 221 in e50dae9
but in updater we use
os.Args
arguments, not modified ones by alias runnerteleport/lib/autoupdate/tools/updater.go
Lines 351 to 352 in e50dae9
this produce issue with updater, when it executed by alias
discussion
Related: https://github.com/gravitational/cloud/issues/10053
changelog: Fixed client tools autoupdates executed by aliases (causes recursive alias error)