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

Client tools auto update #47466

Merged
merged 16 commits into from
Oct 18, 2024
Merged

Client tools auto update #47466

merged 16 commits into from
Oct 18, 2024

Conversation

vapopov
Copy link
Contributor

@vapopov vapopov commented Oct 10, 2024

In this PR implemented logic for client tools auto update {tsh, tctl} described in this RFD #39805

Update logic downloads Teleport binaries from CDN, extracts data in tools sub-directory (going to be used $TELEPORT_HOME/bin/{UUID-update-pkg}/{tsh,tctl}) and creates symlinks for {tsh,tctl} to $TELEPORT_HOME/bin/{tsh,tctl}.
Added integration tests which compiles updater binary with update logic only to simulate command execution with requested version to downloads them from fake test CDN server.

@vapopov vapopov added the no-changelog Indicates that a PR does not require a changelog entry label Oct 10, 2024
return 0, trace.Errorf("invalid size")
}
avail := stat.Bavail * uint64(stat.Bsize)
avail := uint64(stat.Bavail) * uint64(stat.Bsize)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change related to this comment #47060 (comment)
also I'm locally checking linter for warnings related touint64(stat.Bavail)

@vapopov vapopov requested review from sclevine and hugoShaka October 10, 2024 19:11
@vapopov vapopov force-pushed the vapopov/client-auto-update branch from 5bc4215 to ddcbaf9 Compare October 10, 2024 20:21
integration/autoupdate/client_update_test.go Outdated Show resolved Hide resolved
lib/autoupdate/client_update.go Outdated Show resolved Hide resolved
lib/autoupdate/client_update.go Outdated Show resolved Hide resolved
lib/autoupdate/client_update.go Outdated Show resolved Hide resolved
lib/autoupdate/client_update.go Outdated Show resolved Hide resolved
lib/autoupdate/client_update.go Outdated Show resolved Hide resolved
lib/autoupdate/client_update.go Outdated Show resolved Hide resolved
lib/autoupdate/client_update.go Outdated Show resolved Hide resolved
lib/autoupdate/progress.go Outdated Show resolved Hide resolved
lib/autoupdate/utils.go Outdated Show resolved Hide resolved
Move integration tests to client tools specific dir
Use context cancellation with SIGTERM, SIGINT
Remove cancelable tee reader with context replacement
Renaming
Fix archive cleanup if hash is not valid
Limit the archive write bytes
@vapopov vapopov force-pushed the vapopov/client-auto-update branch from 144d573 to d5dd770 Compare October 16, 2024 00:55
@vapopov vapopov force-pushed the vapopov/client-auto-update branch from 355c675 to 5f5688e Compare October 16, 2024 19:44
@vapopov vapopov requested a review from sclevine October 16, 2024 19:44
lib/autoupdate/tools/utils.go Outdated Show resolved Hide resolved
integration/autoupdate/tools/main_test.go Outdated Show resolved Hide resolved
lib/autoupdate/tools/updater.go Outdated Show resolved Hide resolved
lib/autoupdate/tools/updater.go Outdated Show resolved Hide resolved
lib/autoupdate/tools/updater.go Outdated Show resolved Hide resolved
lib/autoupdate/tools/updater.go Outdated Show resolved Hide resolved
@vapopov vapopov requested a review from sclevine October 16, 2024 22:27
integration/autoupdate/tools/main_test.go Outdated Show resolved Hide resolved
integration/autoupdate/tools/updater_test.go Outdated Show resolved Hide resolved
lib/autoupdate/tools/utils.go Outdated Show resolved Hide resolved
lib/autoupdate/tools/updater.go Outdated Show resolved Hide resolved
lib/autoupdate/tools/updater.go Outdated Show resolved Hide resolved
lib/autoupdate/tools/updater.go Outdated Show resolved Hide resolved
lib/autoupdate/tools/updater.go Outdated Show resolved Hide resolved
lib/autoupdate/tools/updater.go Outdated Show resolved Hide resolved
lib/autoupdate/tools/updater.go Outdated Show resolved Hide resolved
lib/autoupdate/tools/updater.go Outdated Show resolved Hide resolved
Replace hash for bytes matching
Proper temp file close for archive download
@vapopov vapopov requested a review from sclevine October 17, 2024 20:17
@vapopov vapopov force-pushed the vapopov/client-auto-update branch from c860415 to b019206 Compare October 17, 2024 20:55
lib/autoupdate/feature.go Outdated Show resolved Hide resolved
lib/autoupdate/tools/utils.go Outdated Show resolved Hide resolved
Copy link
Contributor

@hugoShaka hugoShaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me but we might wanbt to check if there's a saner way to detect enterprise builds. I'll open a thread in #teleport-dev

Edit: just saw your comment

@sclevine
Copy link
Member

@hugoShaka note lib/modules might not work for tbot: #47565 (comment)

@@ -0,0 +1,25 @@
//go:build fips
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zmb3 should I move this one to lib/modules to identify if the build supports the FIPS? Or there already a way to get this info from modules package

Copy link
Member

@sclevine sclevine Oct 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is present as modules.GetModules().IsBoringCrypto() -- BoringCrypto is FIPS validated

@hugoShaka
Copy link
Contributor

hugoShaka commented Oct 18, 2024

@hugoShaka note lib/modules might not work for tbot: #47565 (comment)

I think tbot should be considered an agent like teleport and be updated by the agent updater we're building (as opposed to tools self-update). According to the RFD we going to have a single agent updater for oss, ent, fips and it will figure out the right build from /find or /ping rather than any existing binary version or build flag. So I think everything will fit nicely?

@sclevine
Copy link
Member

@hugoShaka tbot also has a oneshot mode for CI/CD use cases. The current (possibly only verbally discussed) plan is to allow tbot to be upgraded through either method. But this may not ship in the first release of client tools updates.

@vapopov
Copy link
Contributor Author

vapopov commented Oct 18, 2024

@avatus @EdwardDowling would appreciate your review, need one more approval

@vapopov vapopov added this pull request to the merge queue Oct 18, 2024
Merged via the queue into master with commit 84719b3 Oct 18, 2024
39 checks passed
@vapopov vapopov deleted the vapopov/client-auto-update branch October 18, 2024 20:53
vapopov added a commit that referenced this pull request Nov 8, 2024
* Add client tools auto update

* Replace fork for posix platform for re-exec
Move integration tests to client tools specific dir
Use context cancellation with SIGTERM, SIGINT
Remove cancelable tee reader with context replacement
Renaming

* Fix syscall path execution
Fix archive cleanup if hash is not valid
Limit the archive write bytes

* Cover the case with single package for darwin platform after v17

* Move updater logic to tools package

* Move context out from the library
Base URL renaming

* Add more context in comments

* Changes in find endpoint

* Replace test http server with `httptest`
Replace hash for bytes matching
Proper temp file close for archive download

* Add more context to comments

* Move feature flag to main package to be reused

* Constant rename

* Replace build tag with lib/modules to identify enterprise build

* Replace fips tag with modules flag
vapopov added a commit that referenced this pull request Nov 8, 2024
* Add client tools auto update

* Replace fork for posix platform for re-exec
Move integration tests to client tools specific dir
Use context cancellation with SIGTERM, SIGINT
Remove cancelable tee reader with context replacement
Renaming

* Fix syscall path execution
Fix archive cleanup if hash is not valid
Limit the archive write bytes

* Cover the case with single package for darwin platform after v17

* Move updater logic to tools package

* Move context out from the library
Base URL renaming

* Add more context in comments

* Changes in find endpoint

* Replace test http server with `httptest`
Replace hash for bytes matching
Proper temp file close for archive download

* Add more context to comments

* Move feature flag to main package to be reused

* Constant rename

* Replace build tag with lib/modules to identify enterprise build

* Replace fips tag with modules flag
github-merge-queue bot pushed a commit that referenced this pull request Dec 4, 2024
* Expose client tools auto update for find endpoint (#46785)

* Expose client tools auto update for find endpoint

* Group auto update settings in find response
Log error instead returning error
Add tests auto update settings in find endpoint
Add check for not implemented error

* Add more test cases

* Client AutoUpdate proto structure changes (#47532)

* Update client autoupdate proto structure

* Replace with reserved

* Fix unit tests

* Add more info in proto

* Rename proto to be aligned RFD namings

* Replace enum type for ToolsMode to string

* Add packaging utility for client tools auto updates (#47060)

* Add packaging utility for client tools auto updates

* Add error handling for close functions

* Move archive to existing utils package

* Move archive helpers to integration/helper
CR changes

* CR changes

* CR changes

* CR changes
Replace creating directory with extract path as argument

* CR changes

* Validate full size before un-archive
Extract files to extractDir with ignore dir structure

* Change compressing with relative paths
Add test for cleanup and fix skip logic

* CR changes

* CR changes

* Fix linter

* Client tools auto update (#47466)

* Add client tools auto update

* Replace fork for posix platform for re-exec
Move integration tests to client tools specific dir
Use context cancellation with SIGTERM, SIGINT
Remove cancelable tee reader with context replacement
Renaming

* Fix syscall path execution
Fix archive cleanup if hash is not valid
Limit the archive write bytes

* Cover the case with single package for darwin platform after v17

* Move updater logic to tools package

* Move context out from the library
Base URL renaming

* Add more context in comments

* Changes in find endpoint

* Replace test http server with `httptest`
Replace hash for bytes matching
Proper temp file close for archive download

* Add more context to comments

* Move feature flag to main package to be reused

* Constant rename

* Replace build tag with lib/modules to identify enterprise build

* Replace fips tag with modules flag

* Client auto updates integration for {tctl,tsh} (#47815)

* Client auto updates integration for tctl/tsh

* Add version validation
Fix recursive version check for darwin platform
Fix cleanup for multi-package support

* Fix identifying tools removal from home directory

* Replace ToolsMode with ToolsAutoUpdate

* Reuse insecure flag for tests

* Fix CheckRemote with login

* Fix windows administrative access requirement
Update must be able to be canceled, re-execute with latest version or last updated
Show progress bar before request is made

* Fix update cancellation for login action
Address review comments

* Add signal handler with stack context cancellation

* Use copy instead of hard link for windows
Fix progress bar if we can't receive size of package

* Replace with list in order to support manual cancel

* Download archive package to temp directory

* Decrease timeout for client tools proxy call

* Add audit logs for auto update resources (#48218)

* Connect: Make sure tsh auto-updates are turned off (#49180)

* Add dir for code shared between Node.js processes

* Connect: Make sure tsh auto-updates are turned off

* Pass TELEPORT_TOOLS_VERSION=off to tsh vnet-daemon

* Disable client tools auto update disabled if there are no home dir (#49159)

Move updater to general tools package

* Move client auto update helper to lib package (#49247)

---------

Co-authored-by: Rafał Cieślak <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Dec 11, 2024
* Expose client tools auto update for find endpoint (#46785)

* Expose client tools auto update for find endpoint

* Group auto update settings in find response
Log error instead returning error
Add tests auto update settings in find endpoint
Add check for not implemented error

* Add more test cases

* Client AutoUpdate proto structure changes (#47532)

* Update client autoupdate proto structure

* Replace with reserved

* Fix unit tests

* Add more info in proto

* Rename proto to be aligned RFD namings

* Replace enum type for ToolsMode to string

* Add packaging utility for client tools auto updates (#47060)

* Add packaging utility for client tools auto updates

* Add error handling for close functions

* Move archive to existing utils package

* Move archive helpers to integration/helper
CR changes

* CR changes

* CR changes

* CR changes
Replace creating directory with extract path as argument

* CR changes

* Validate full size before un-archive
Extract files to extractDir with ignore dir structure

* Change compressing with relative paths
Add test for cleanup and fix skip logic

* CR changes

* CR changes

* Fix linter

* Client tools auto update (#47466)

* Add client tools auto update

* Replace fork for posix platform for re-exec
Move integration tests to client tools specific dir
Use context cancellation with SIGTERM, SIGINT
Remove cancelable tee reader with context replacement
Renaming

* Fix syscall path execution
Fix archive cleanup if hash is not valid
Limit the archive write bytes

* Cover the case with single package for darwin platform after v17

* Move updater logic to tools package

* Move context out from the library
Base URL renaming

* Add more context in comments

* Changes in find endpoint

* Replace test http server with `httptest`
Replace hash for bytes matching
Proper temp file close for archive download

* Add more context to comments

* Move feature flag to main package to be reused

* Constant rename

* Replace build tag with lib/modules to identify enterprise build

* Replace fips tag with modules flag

* Client auto updates integration for {tctl,tsh} (#47815)

* Client auto updates integration for tctl/tsh

* Add version validation
Fix recursive version check for darwin platform
Fix cleanup for multi-package support

* Fix identifying tools removal from home directory

* Replace ToolsMode with ToolsAutoUpdate

* Reuse insecure flag for tests

* Fix CheckRemote with login

* Fix windows administrative access requirement
Update must be able to be canceled, re-execute with latest version or last updated
Show progress bar before request is made

* Fix update cancellation for login action
Address review comments

* Add signal handler with stack context cancellation

* Use copy instead of hard link for windows
Fix progress bar if we can't receive size of package

* Replace with list in order to support manual cancel

* Download archive package to temp directory

* Decrease timeout for client tools proxy call

* Add audit logs for auto update resources (#48218)

* Connect: Make sure tsh auto-updates are turned off

* Add dir for code shared between Node.js processes

* Connect: Make sure tsh auto-updates are turned off

* Pass TELEPORT_TOOLS_VERSION=off to tsh vnet-daemon

* Disable client tools auto update disabled if there are no home dir (#49159)

Move updater to general tools package

* Move client auto update helper to lib package (#49247)

---------

Co-authored-by: Rafał Cieślak <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Indicates that a PR does not require a changelog entry size/lg
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants