Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/autoupdate/agent/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ func tgzExtractPaths(ent bool) []utils.ExtractPath {
{Src: path.Join(prefix, "README.md"), Dst: "share/README.md", DirMode: systemDirMode},
{Src: path.Join(prefix, "CHANGELOG.md"), Dst: "share/CHANGELOG.md", DirMode: systemDirMode},
{Src: path.Join(prefix, "VERSION"), Dst: "share/VERSION", DirMode: systemDirMode},
{Src: path.Join(prefix, "LICENSE-community"), Dst: "share/LICENSE-community", DirMode: systemDirMode},
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@hugoShaka discovered this license file was missing while we were debugging

{Src: prefix, Dst: "bin", DirMode: systemDirMode},
}
}
Expand Down
2 changes: 0 additions & 2 deletions lib/autoupdate/agent/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,9 @@ func (s SystemdService) checkSystem(ctx context.Context) error {
return trace.Wrap(err)
}
if !present {
s.Log.ErrorContext(ctx, "This system does not support systemd, which is required by the updater.")
return trace.Wrap(ErrNotSupported)
}
return nil

}

// hasSystemD returns true if the system uses the SystemD process manager.
Expand Down
13 changes: 13 additions & 0 deletions lib/autoupdate/agent/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ func (ns *Namespace) Init() (lockFile string, err error) {
// Setup installs service and timer files for the teleport-update binary.
// Afterwords, Setup reloads systemd and enables the timer with --now.
func (ns *Namespace) Setup(ctx context.Context) error {
if ok, err := hasSystemD(); err == nil && !ok {
ns.log.WarnContext(ctx, "Systemd is not running, skipping updater installation.")
return nil
}

err := ns.writeConfigFiles(ctx)
if err != nil {
return trace.Wrap(err, "failed to write teleport-update systemd config files")
Expand Down Expand Up @@ -250,6 +255,14 @@ func (ns *Namespace) Setup(ctx context.Context) error {

// Teardown removes all traces of the auto-updater, including its configuration.
func (ns *Namespace) Teardown(ctx context.Context) error {
if ok, err := hasSystemD(); err == nil && !ok {
ns.log.WarnContext(ctx, "Systemd is not running, skipping updater removal.")
if err := os.RemoveAll(namespaceDir(ns.name)); err != nil {
return trace.Wrap(err, "failed to remove versions directory")
}
return nil
}

svc := &SystemdService{
ServiceName: filepath.Base(ns.updaterTimerFile),
Log: ns.log,
Expand Down
8 changes: 4 additions & 4 deletions lib/autoupdate/agent/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -897,10 +897,6 @@ func (u *Updater) Setup(ctx context.Context, restart bool) error {
if errors.Is(err, context.Canceled) {
return trace.Errorf("sync canceled")
}
if errors.Is(err, ErrNotSupported) {
u.Log.WarnContext(ctx, "Skipping all systemd setup because systemd is not running.")
return nil
}
if err != nil {
return trace.Wrap(err, "failed to setup updater")
}
Expand All @@ -909,6 +905,10 @@ func (u *Updater) Setup(ctx context.Context, restart bool) error {
if errors.Is(err, context.Canceled) {
return trace.Errorf("config check canceled")
}
if errors.Is(err, ErrNotSupported) {
u.Log.WarnContext(ctx, "Skipping all systemd setup because systemd is not running.")
return nil
}
if err != nil {
return trace.Wrap(err, "failed to determine if new version of Teleport has an installed systemd service")
}
Expand Down
10 changes: 5 additions & 5 deletions lib/autoupdate/agent/updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1758,11 +1758,6 @@ func TestUpdater_Setup(t *testing.T) {
setupErr: errors.New("some error"),
errMatch: "some error",
},
{
name: "setup error not supported",
restart: false,
setupErr: ErrNotSupported,
},
{
name: "setup error canceled",
restart: false,
Expand All @@ -1781,6 +1776,11 @@ func TestUpdater_Setup(t *testing.T) {
presentErr: context.Canceled,
errMatch: "canceled",
},
{
name: "preset error not supported",
restart: false,
presentErr: ErrNotSupported,
},
{
name: "reload error canceled",
restart: true,
Expand Down
21 changes: 11 additions & 10 deletions tool/teleport-update/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ import (

const appHelp = `Teleport Updater

The Teleport Updater automatically updates a Teleport agent.
The Teleport Updater applies Managed Updates to a Teleport agent installation.

The Teleport Updater supports upgrade schedules and automated rollbacks.
The Teleport Updater supports update scheduling and automated rollbacks.

Find out more at https://goteleport.com/docs/updater`
Find out more at https://goteleport.com/docs/upgrading/agent-managed-updates`

const (
// proxyServerEnvVar allows the proxy server address to be specified via env var.
Expand Down Expand Up @@ -112,7 +112,7 @@ func Run(args []string) int {

versionCmd := app.Command("version", fmt.Sprintf("Print the version of your %s binary.", autoupdate.BinaryName))

enableCmd := app.Command("enable", "Enable agent auto-updates and perform initial installation or update. This creates a systemd timer that periodically runs the update subcommand.")
enableCmd := app.Command("enable", "Enable agent managed updates and perform initial installation or update. This creates a systemd timer that periodically runs the update subcommand.")
enableCmd.Flag("proxy", "Address of the Teleport Proxy.").
Short('p').Envar(proxyServerEnvVar).StringVar(&ccfg.Proxy)
enableCmd.Flag("group", "Update group for this agent installation.").
Expand All @@ -123,10 +123,12 @@ func Run(args []string) int {
Short('o').BoolVar(&ccfg.AllowOverwrite)
enableCmd.Flag("force-version", "Force the provided version instead of using the version provided by the Teleport cluster.").
Short('f').Envar(updateVersionEnvVar).Hidden().StringVar(&ccfg.ForceVersion)
enableCmd.Flag("self-setup", "Use the current teleport-update binary to create systemd service config for auto-updates.").
enableCmd.Flag("self-setup", "Use the current teleport-update binary to create systemd service config for managed updates.").
Short('s').Hidden().BoolVar(&ccfg.SelfSetup)
// TODO(sclevine): add force-fips and force-enterprise as hidden flags

disableCmd := app.Command("disable", "Disable agent managed updates. Does not affect the active installation of Teleport.")

pinCmd := app.Command("pin", "Install Teleport and lock the updater to the installed version.")
pinCmd.Flag("proxy", "Address of the Teleport Proxy.").
Short('p').Envar(proxyServerEnvVar).StringVar(&ccfg.Proxy)
Expand All @@ -136,19 +138,18 @@ func Run(args []string) int {
Short('b').Envar(common.BaseURLEnvVar).StringVar(&ccfg.BaseURL)
pinCmd.Flag("force-version", "Force the provided version instead of using the version provided by the Teleport cluster.").
Short('f').Envar(updateVersionEnvVar).StringVar(&ccfg.ForceVersion)
pinCmd.Flag("self-setup", "Use the current teleport-update binary to create systemd service config for auto-updates.").
pinCmd.Flag("self-setup", "Use the current teleport-update binary to create systemd service config for managed updates.").
Short('s').Hidden().BoolVar(&ccfg.SelfSetup)

disableCmd := app.Command("disable", "Disable agent auto-updates. Does not affect the active installation of Teleport.")
unpinCmd := app.Command("unpin", "Unpin the current version, allowing it to be updated.")

updateCmd := app.Command("update", "Update the agent to the latest version, if a new version is available.")
updateCmd.Flag("now", "Force immediate update even if update window is not active.").
Short('n').BoolVar(&ccfg.UpdateNow)
updateCmd.Flag("self-setup", "Use the current teleport-update binary to create systemd service config for auto-updates and verify the Teleport installation.").
updateCmd.Flag("self-setup", "Use the current teleport-update binary to create systemd service config for managed updates and verify the Teleport installation.").
Short('s').Hidden().BoolVar(&ccfg.SelfSetup)

linkCmd := app.Command("link-package", "Link the system installation of Teleport from the Teleport package, if auto-updates is disabled.")
linkCmd := app.Command("link-package", "Link the system installation of Teleport from the Teleport package, if managed updates is disabled.")
unlinkCmd := app.Command("unlink-package", "Unlink the system installation of Teleport from the Teleport package.")

setupCmd := app.Command("setup", "Write configuration files that run the update subcommand on a timer and verify the Teleport installation.").
Expand Down Expand Up @@ -365,7 +366,7 @@ func cmdUpdate(ctx context.Context, ccfg *cliConfig) error {
return nil
}

// cmdLinkPackage creates system package links if no version is linked and auto-updates is disabled.
// cmdLinkPackage creates system package links if no version is linked and managed updates is disabled.
func cmdLinkPackage(ctx context.Context, ccfg *cliConfig) error {
updater, lockFile, err := initConfig(ccfg)
if err != nil {
Expand Down