Skip to content

Commit 01b3bb3

Browse files
Fix version printing on startup
1 parent 56fae07 commit 01b3bb3

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

pkg/cli/agent/agent.go

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/rancher/k3s/pkg/cli/cmds"
1010
"github.com/rancher/norman/pkg/resolvehome"
1111
"github.com/rancher/norman/signal"
12+
"github.com/sirupsen/logrus"
1213
"github.com/urfave/cli"
1314
)
1415

@@ -25,6 +26,8 @@ func Run(ctx *cli.Context) error {
2526
return fmt.Errorf("--server is required")
2627
}
2728

29+
logrus.Infof("Starting k3s agent %s", ctx.App.Version)
30+
2831
dataDir, err := resolvehome.Resolve(cmds.AgentConfig.DataDir)
2932
if err != nil {
3033
return err
@@ -35,5 +38,6 @@ func Run(ctx *cli.Context) error {
3538
cfg.DataDir = dataDir
3639

3740
contextCtx := signal.SigTermCancelContext(context.Background())
41+
3842
return agent.Run(contextCtx, cfg)
3943
}

pkg/cli/cmds/root.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func NewApp() *cli.App {
1616
app := cli.NewApp()
1717
app.Name = appName
1818
app.Usage = "Kubernetes, but small and simple"
19-
app.Version = version.Version
19+
app.Version = fmt.Sprintf("%s (%s)", version.Version, version.GitCommit)
2020
cli.VersionPrinter = func(c *cli.Context) {
2121
fmt.Printf("%s version %s\n", app.Name, app.Version)
2222
}

scripts/build

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ source $(dirname $0)/version.sh
55

66
cd $(dirname $0)/..
77

8-
LDFLAGS="-X github.com/rancher/k3s/version.Version=$VERSION -w -s"
8+
LDFLAGS="-X github.com/rancher/k3s/pkg/version.Version=$VERSION -X github.com/rancher/k3s/pkg/version.GitCommit=${COMMIT:0:8} -w -s"
99
STATIC="-extldflags '-static'"
1010
STATIC_SQLITE="-extldflags '-static -lm -ldl -lz -lpthread'"
1111
TAGS="ctrd apparmor seccomp no_btrfs netgo osusergo"

0 commit comments

Comments
 (0)