From 01b3bb315e9d932330a050c52dee56f6eb1a5af0 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Thu, 7 Feb 2019 21:28:09 -0700 Subject: [PATCH] Fix version printing on startup --- pkg/cli/agent/agent.go | 4 ++++ pkg/cli/cmds/root.go | 2 +- scripts/build | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/cli/agent/agent.go b/pkg/cli/agent/agent.go index 83e863276320..aaba54ab5e58 100644 --- a/pkg/cli/agent/agent.go +++ b/pkg/cli/agent/agent.go @@ -9,6 +9,7 @@ import ( "github.com/rancher/k3s/pkg/cli/cmds" "github.com/rancher/norman/pkg/resolvehome" "github.com/rancher/norman/signal" + "github.com/sirupsen/logrus" "github.com/urfave/cli" ) @@ -25,6 +26,8 @@ func Run(ctx *cli.Context) error { return fmt.Errorf("--server is required") } + logrus.Infof("Starting k3s agent %s", ctx.App.Version) + dataDir, err := resolvehome.Resolve(cmds.AgentConfig.DataDir) if err != nil { return err @@ -35,5 +38,6 @@ func Run(ctx *cli.Context) error { cfg.DataDir = dataDir contextCtx := signal.SigTermCancelContext(context.Background()) + return agent.Run(contextCtx, cfg) } diff --git a/pkg/cli/cmds/root.go b/pkg/cli/cmds/root.go index 1f2923f587e0..a01159db621b 100644 --- a/pkg/cli/cmds/root.go +++ b/pkg/cli/cmds/root.go @@ -16,7 +16,7 @@ func NewApp() *cli.App { app := cli.NewApp() app.Name = appName app.Usage = "Kubernetes, but small and simple" - app.Version = version.Version + app.Version = fmt.Sprintf("%s (%s)", version.Version, version.GitCommit) cli.VersionPrinter = func(c *cli.Context) { fmt.Printf("%s version %s\n", app.Name, app.Version) } diff --git a/scripts/build b/scripts/build index 5a2c5da92d24..9a38024b26c8 100755 --- a/scripts/build +++ b/scripts/build @@ -5,7 +5,7 @@ source $(dirname $0)/version.sh cd $(dirname $0)/.. -LDFLAGS="-X github.com/rancher/k3s/version.Version=$VERSION -w -s" +LDFLAGS="-X github.com/rancher/k3s/pkg/version.Version=$VERSION -X github.com/rancher/k3s/pkg/version.GitCommit=${COMMIT:0:8} -w -s" STATIC="-extldflags '-static'" STATIC_SQLITE="-extldflags '-static -lm -ldl -lz -lpthread'" TAGS="ctrd apparmor seccomp no_btrfs netgo osusergo"