Skip to content

Commit

Permalink
Update updater inventory reporting after removal (#43371)
Browse files Browse the repository at this point in the history
* Verify updater script

* unit version defaults to ""

* Ensure semver

* Add missing return
  • Loading branch information
bernardjkim authored Jun 24, 2024
1 parent 9b33d16 commit 213407a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/automaticupgrades/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
package automaticupgrades

import (
"bytes"
"context"
"os"
"os/exec"
"strconv"
"strings"

log "github.com/sirupsen/logrus"

"github.com/gravitational/teleport/lib/automaticupgrades/version"
)

const (
Expand Down Expand Up @@ -78,11 +80,14 @@ func GetUpgraderVersion(ctx context.Context) string {
out, err := exec.CommandContext(ctx, teleportUpgradeScript, "version").Output()
if err != nil {
log.WithError(err).Debug("Failed to exec /usr/sbin/teleport-upgrade version command.")
} else {
if version := strings.TrimSpace(string(out)); version != "" {
return version
}
return ""
}
ver, err := version.EnsureSemver(string(bytes.TrimSpace(out)))
if err != nil {
log.WithError(err).Debug("Unexpected teleport-upgrade version.")
return ""
}
return ver
}
return os.Getenv(EnvUpgraderVersion)
}
3 changes: 3 additions & 0 deletions lib/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,9 @@ func NewTeleport(cfg *servicecfg.Config) (*TeleportProcess, error) {

upgraderKind := os.Getenv(automaticupgrades.EnvUpgrader)
upgraderVersion := automaticupgrades.GetUpgraderVersion(process.GracefulExitContext())
if upgraderVersion == "" {
upgraderKind = ""
}

// Instances deployed using the AWS OIDC integration are automatically updated
// by the proxy. The instance heartbeat should properly reflect that.
Expand Down

0 comments on commit 213407a

Please sign in to comment.