Skip to content
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

Printout git commit for better debugging. #209

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
IMAGE_REGISTRY_NAME ?= quay.io/open-cluster-management
Expand Down Expand Up @@ -112,9 +111,11 @@ client-gen:
--versions=open-cluster-management.io/cluster-proxy/pkg/apis/proxy/v1alpha1

images:
git_commit=$$(git rev-parse --short HEAD) && \
docker build \
-f cmd/Dockerfile \
--build-arg ADDON_AGENT_IMAGE_NAME=$(IMAGE_REGISTRY_NAME)/$(IMAGE_NAME):$(IMAGE_TAG) \
--build-arg GIT_COMMIT=$$git_commit \
-t $(IMAGE_REGISTRY_NAME)/$(IMAGE_NAME):$(IMAGE_TAG) .

ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
Expand Down
4 changes: 3 additions & 1 deletion cmd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ WORKDIR /workspace
ARG APISERVER_NETWORK_PROXY_VERSION=0.30.2
ARG KUBECTL_VERSION=v1.30.2
ARG ADDON_AGENT_IMAGE_NAME
ARG GIT_COMMIT

# Build Apiserver-network-proxy binaries
RUN wget https://github.com/kubernetes-sigs/apiserver-network-proxy/archive/refs/tags/v${APISERVER_NETWORK_PROXY_VERSION}.tar.gz \
Expand Down Expand Up @@ -33,7 +34,8 @@ COPY pkg pkg/
# Build addons
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o agent cmd/addon-agent/main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a \
-ldflags="-X 'open-cluster-management.io/cluster-proxy/pkg/config.AgentImageName=${ADDON_AGENT_IMAGE_NAME}'" \
-ldflags="-X 'open-cluster-management.io/cluster-proxy/pkg/config.AgentImageName=${ADDON_AGENT_IMAGE_NAME}' \
-X 'main.gitCommit=${GIT_COMMIT}'" \
-o manager cmd/addon-manager/main.go

# Use distroless as minimal base image to package the manager binary
Expand Down
5 changes: 5 additions & 0 deletions cmd/addon-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main
import (
"context"
"flag"
"fmt"
"os"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
Expand Down Expand Up @@ -49,6 +50,8 @@ import (
//+kubebuilder:scaffold:imports
)

var gitCommit string

var (
scheme = runtime.NewScheme()
setupLog = ctrl.Log.WithName("setup")
Expand Down Expand Up @@ -91,6 +94,8 @@ func main() {

flag.Parse()

fmt.Printf("Starting addon-manager. Git commit: %s\n", gitCommit)

// pipe controller-runtime logs to klog
ctrl.SetLogger(logger)

Expand Down
Loading