Skip to content

K8SPG-738: Add startup log to print commit hash, branch and build time #1109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 1, 2025
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
4 changes: 2 additions & 2 deletions build/postgres-operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ RUN mkdir -p build/_output/bin \
apt-get update -y && apt-get install gcc-x86-64-linux-gnu -y && export CC=x86_64-linux-gnu-gcc; \
fi \
&& CGO_ENABLED=$OPERATOR_CGO_ENABLED GOARCH=${TARGETARCH} GOOS=$GOOS GO_LDFLAGS=$GO_LDFLAGS \
go build -ldflags "-w -s -X main.GitCommit=$GIT_COMMIT -X main.GitBranch=$GIT_BRANCH" \
go build -ldflags "-w -s -X main.GitCommit=$GIT_COMMIT -X main.GitBranch=$GIT_BRANCH -X main.BuildTime=$BUILD_TIME" \
-o build/_output/bin/postgres-operator \
./cmd/postgres-operator \
&& CGO_ENABLED=$EXTENSION_INSTALLER_CGO_ENABLED GOARCH=${TARGETARCH} GOOS=$GOOS GO_LDFLAGS=$GO_LDFLAGS \
go build -ldflags "-w -s -X main.GitCommit=$GIT_COMMIT -X main.GitBranch=$GIT_BRANCH" \
go build -ldflags "-w -s -X main.GitCommit=$GIT_COMMIT -X main.GitBranch=$GIT_BRANCH -X main.BuildTime=$BUILD_TIME" \
-o build/_output/bin/extension-installer \
./cmd/extension-installer \
&& cp -r build/_output/bin/postgres-operator /usr/local/bin/postgres-operator \
Expand Down
11 changes: 10 additions & 1 deletion cmd/postgres-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"context"
"fmt"
"os"
goruntime "runtime"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -47,7 +48,12 @@ import (
"github.com/percona/percona-postgresql-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
)

var versionString string
var (
GitCommit string
GitBranch string
BuildTime string
versionString string
)

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

log.Info("Manager starting up", "gitCommit", GitCommit, "gitBranch", GitBranch,
"buildTime", BuildTime, "goVersion", goruntime.Version(), "os", goruntime.GOOS, "arch", goruntime.GOARCH)

features := feature.NewGate()
err = features.SetFromMap(map[string]bool{
string(feature.InstanceSidecars): true, // needed for PMM
Expand Down
Loading