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

[teleport-update] Add link subcommand #48712

Merged
merged 16 commits into from
Nov 15, 2024
Merged

Conversation

sclevine
Copy link
Member

@sclevine sclevine commented Nov 8, 2024

This PR adds the link subcommand to the teleport-update command.

This subcommand will allow the teleport RPM and DEB packages to co-exist with versions of Teleport that are installed by the teleport-update binary, by ensuring that Teleport binaries installed by the package into /usr/local/teleport-system are always linked to /usr/local when no teleport-update-managed installation is present.

The link subcommand links the system (package) installation of Teleport from /usr/local/teleport-system to /usr/local/{bin,lib/systemd/system}. This subcommand will be executed by the teleport package's postinst script to ensure that when auto-updates are disabled, the package continues to function as it does today. See the RFD linked below for more details.

Note that the Teleport package will have its files moved into /usr/local/teleport-system in a future PR. This command is not useful until this packaging change is complete.

This PR also fixes the following small bugs related to linking:

  • teleport.service must be copied instead of linked, since systemctl enable resolves multi-level links
  • enterprise installations are broken due to the tarball containing teleport-ent as the top-level directory

This is the sixth in a series of PRs implementing teleport-update:
Update Command: #48244
Reloading with rollbacks: #47929
Linking: #47879
Enable Command: #47565
Initial scaffolding PR: #46418

The teleport-update binary will be used to enable, disable, and trigger automatic Teleport agent updates. The new auto-updates system manages a local installation of the cluster-specified version of Teleport stored in /var/lib/teleport/versions.

RFD: #47126
Goal (internal): https://github.com/gravitational/cloud/issues/10289

Examples:

bash$ sudo ./teleport-update update
2024-11-12T23:02:56Z INFO [UPDATER]   Update available. Initiating update. target_version:17.0.0-beta.1 active_version:18.0.0-dev.updates.2 agent/updater.go:435
2024-11-12T23:03:56Z INFO [UPDATER]   Version already present. version:17.0.0-beta.1 agent/installer.go:140
2024-11-12T23:03:56Z INFO [UPDATER]   Target version successfully installed. target_version:17.0.0-beta.1 agent/updater.go:510
2024-11-12T23:03:56Z INFO [UPDATER]   Teleport gracefully reloaded. agent/process.go:74
2024-11-12T23:03:56Z INFO [UPDATER]   Backup version set. backup_version:18.0.0-dev.updates.2 agent/updater.go:535
2024-11-12T23:03:56Z INFO [UPDATER]   Configuration updated. agent/updater.go:450

bash$ sudo ./teleport-update link
2024-11-12T23:11:02Z INFO [UPDATER]   Automatic updates enabled. Skipping system package link. active_version:17.0.0-beta.1 agent/updater.go:626

bash$ sudo ./teleport-update disable
bash$ sudo ./teleport-update link
ERROR: failed to link system package installation: failed to find Teleport binary directory: open /usr/local/teleport-system/bin: no such file or directory

bash$ sudo cp -r /var/lib/teleport/versions/17.0.0-beta.1 /usr/local/teleport-system
bash$ sudo ./teleport-update link
2024-11-13T01:42:18Z WARN [UPDATER]   Automatic updates disabled, but a non-package version of Teleport is linked. active_version:17.0.0-beta.1 agent/updater.go:633

bash$ sudo rm /usr/local/bin/{teleport,tsh,tctl,tbot,fdpass-teleport}
bash$ sudo rm /usr/local/lib/systemd/system/teleport.service
bash$ sudo ./teleport-update link
2024-11-13T01:47:01Z INFO [UPDATER]   Successfully linked system package installation. agent/updater.go:638

bash$ ls -l /usr/local/bin/
lrwxrwxrwx  1 root root   46 Nov 13 01:47 fdpass-teleport -> /usr/local/teleport-system/bin/fdpass-teleport
lrwxrwxrwx  1 root root   35 Nov 13 01:47 tbot -> /usr/local/teleport-system/bin/tbot
lrwxrwxrwx  1 root root   35 Nov 13 01:47 tctl -> /usr/local/teleport-system/bin/tctl
lrwxrwxrwx  1 root root   39 Nov 13 01:47 teleport -> /usr/local/teleport-system/bin/teleport
lrwxrwxrwx  1 root root   34 Nov 13 01:47 tsh -> /usr/local/teleport-system/bin/tsh
bash$ ls -l /usr/local/lib/systemd/system
-rw-r--r-- 1 root root  435 Nov 13 01:47 teleport.service

Base automatically changed from sclevine/teleport-update-update to master November 11, 2024 22:08
@sclevine sclevine force-pushed the sclevine/teleport-update-link branch from 84bac8f to 3b37722 Compare November 12, 2024 02:06
@sclevine sclevine marked this pull request as ready for review November 12, 2024 23:11
@sclevine sclevine added the no-changelog Indicates that a PR does not require a changelog entry label Nov 12, 2024
lib/autoupdate/agent/installer.go Outdated Show resolved Hide resolved
lib/autoupdate/agent/installer.go Show resolved Hide resolved
lib/autoupdate/agent/installer.go Outdated Show resolved Hide resolved
lib/autoupdate/agent/installer_test.go Outdated Show resolved Hide resolved
@sclevine
Copy link
Member Author

Could use one more review when someone has a chance 🙂

@sclevine sclevine added this pull request to the merge queue Nov 15, 2024
Merged via the queue into master with commit fb64dbe Nov 15, 2024
41 checks passed
@sclevine sclevine deleted the sclevine/teleport-update-link branch November 15, 2024 02:57
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.

3 participants