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] use new updater to reload and verify Teleport #51734

Merged
merged 9 commits into from
Feb 6, 2025

Conversation

sclevine
Copy link
Member

@sclevine sclevine commented Jan 31, 2025

This PR moves the healthcheck and agent restart logic into the copy of teleport-update that is being installed by teleport-update update. This ensures that any bugs are caught on the leading-edge of the update process, so that a broken version of teleport-update is less likely to be installed and prevent future updates.


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 /opt/teleport.

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

@sclevine sclevine marked this pull request as ready for review February 1, 2025 18:38
@sclevine sclevine requested review from hugoShaka and vapopov February 1, 2025 18:39
@sclevine sclevine added the no-changelog Indicates that a PR does not require a changelog entry label Feb 1, 2025
// Setup is safe to run concurrently with other Updater commands.
func (u *Updater) Setup(ctx context.Context, restart bool) error {
// Setup teleport-updater configuration and sync systemd.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was tempted to include the linking / reverting logic here as well, but I think it introduces complexity that may be undesirable:

  • The LocalInstaller logic would be split between versions, which may be difficult to reason about for future changes. E.g., we would not be able to change the format of the installation within a single version.
  • Reverting logic would move to the new version, and never execute until it's installed.

Comment on lines 185 to 190
// ExecSetup execs teleport-update to verify and reload the installation.
ExecSetup func(ctx context.Context, restart bool) error
// SetupConfig installs the Teleport updater service using the running installation.
SetupConfig func(ctx context.Context) error
// TeardownConfig removes all traces of the updater and all managed installations.
TeardownConfig func(ctx context.Context) error
Copy link
Contributor

Choose a reason for hiding this comment

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

Those names are not very explicit about what those functions are doing, especially the *Config part.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// ExecSetup execs teleport-update to verify and reload the installation.
ExecSetup func(ctx context.Context, restart bool) error
// SetupConfig installs the Teleport updater service using the running installation.
SetupConfig func(ctx context.Context) error
// TeardownConfig removes all traces of the updater and all managed installations.
TeardownConfig func(ctx context.Context) error
// VerifyAndReload execs teleport-update to verify and reload the installation.
VerifyAndReload func(ctx context.Context, restart bool) error
// SetupUpdater installs the Teleport updater service using the running installation.
SetupUpdater func(ctx context.Context) error
// Teardown removes all traces of the updater and all managed installations.
Teardown func(ctx context.Context) error

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 Made these names more descriptive and added better godoc.

(Note that ExecSetup re-execs the binary with the setup subcommand, while the others just execute Namespace methods.)

tool/teleport-update/main.go Outdated Show resolved Hide resolved
Comment on lines +760 to +780
if ok := revertConfig(ctx); ok {
u.Log.WarnContext(ctx, "Teleport updater encountered a configuration error and successfully reverted the installation.")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also log if the revert failed?

Copy link
Member Author

Choose a reason for hiding this comment

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

revertConfig is a local function that always logs when it returns false.

@sclevine sclevine force-pushed the sclevine/split-link branch from 9024972 to 2a15809 Compare February 6, 2025 01:38
@sclevine
Copy link
Member Author

sclevine commented Feb 6, 2025

@vapopov looking for a second review whenever you have a chance 🙂

@sclevine sclevine force-pushed the sclevine/split-link branch from 2a15809 to 515726c Compare February 6, 2025 03:18
@sclevine sclevine enabled auto-merge February 6, 2025 03:20
@sclevine sclevine added this pull request to the merge queue Feb 6, 2025
Merged via the queue into master with commit 0aba334 Feb 6, 2025
43 checks passed
@sclevine sclevine deleted the sclevine/split-link branch February 6, 2025 03: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/sm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants