Skip to content

Commit 3ce819f

Browse files
egeguneshors
andauthored
K8SPG-738: Add startup log to print commit hash, branch and build time (#1109)
Co-authored-by: Viacheslav Sarzhan <[email protected]>
1 parent 3f20deb commit 3ce819f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

build/postgres-operator/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ RUN mkdir -p build/_output/bin \
2727
apt-get update -y && apt-get install gcc-x86-64-linux-gnu -y && export CC=x86_64-linux-gnu-gcc; \
2828
fi \
2929
&& CGO_ENABLED=$OPERATOR_CGO_ENABLED GOARCH=${TARGETARCH} GOOS=$GOOS GO_LDFLAGS=$GO_LDFLAGS \
30-
go build -ldflags "-w -s -X main.GitCommit=$GIT_COMMIT -X main.GitBranch=$GIT_BRANCH" \
30+
go build -ldflags "-w -s -X main.GitCommit=$GIT_COMMIT -X main.GitBranch=$GIT_BRANCH -X main.BuildTime=$BUILD_TIME" \
3131
-o build/_output/bin/postgres-operator \
3232
./cmd/postgres-operator \
3333
&& CGO_ENABLED=$EXTENSION_INSTALLER_CGO_ENABLED GOARCH=${TARGETARCH} GOOS=$GOOS GO_LDFLAGS=$GO_LDFLAGS \
34-
go build -ldflags "-w -s -X main.GitCommit=$GIT_COMMIT -X main.GitBranch=$GIT_BRANCH" \
34+
go build -ldflags "-w -s -X main.GitCommit=$GIT_COMMIT -X main.GitBranch=$GIT_BRANCH -X main.BuildTime=$BUILD_TIME" \
3535
-o build/_output/bin/extension-installer \
3636
./cmd/extension-installer \
3737
&& cp -r build/_output/bin/postgres-operator /usr/local/bin/postgres-operator \

cmd/postgres-operator/main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"context"
99
"fmt"
1010
"os"
11+
goruntime "runtime"
1112
"strconv"
1213
"strings"
1314
"time"
@@ -47,7 +48,12 @@ import (
4748
"github.com/percona/percona-postgresql-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
4849
)
4950

50-
var versionString string
51+
var (
52+
GitCommit string
53+
GitBranch string
54+
BuildTime string
55+
versionString string
56+
)
5157

5258
// assertNoError panics when err is not nil.
5359
func assertNoError(err error) {
@@ -74,6 +80,9 @@ func main() {
7480
log := logging.FromContext(ctx)
7581
log.V(1).Info("debug flag set to true")
7682

83+
log.Info("Manager starting up", "gitCommit", GitCommit, "gitBranch", GitBranch,
84+
"buildTime", BuildTime, "goVersion", goruntime.Version(), "os", goruntime.GOOS, "arch", goruntime.GOARCH)
85+
7786
features := feature.NewGate()
7887
err = features.SetFromMap(map[string]bool{
7988
string(feature.InstanceSidecars): true, // needed for PMM

0 commit comments

Comments
 (0)