Skip to content

moved build details to version package #1185

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 1 commit into from
Jul 18, 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
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ COPY cmd/epp ./cmd/epp
COPY pkg/epp ./pkg/epp
COPY internal ./internal
COPY api ./api
COPY version ./version
WORKDIR /src/cmd/epp
RUN go build -ldflags="-X sigs.k8s.io/gateway-api-inference-extension/pkg/epp/metrics.CommitSHA=${COMMIT_SHA} -X sigs.k8s.io/gateway-api-inference-extension/pkg/epp/metrics.BuildRef=${BUILD_REF}" -o /epp
RUN go build -ldflags="-X sigs.k8s.io/gateway-api-inference-extension/version.CommitSHA=${COMMIT_SHA} -X sigs.k8s.io/gateway-api-inference-extension/version.BuildRef=${BUILD_REF}" -o /epp

## Multistage deploy
FROM ${BASE_IMAGE}
Expand Down
5 changes: 4 additions & 1 deletion cmd/epp/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling"
runserver "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/server"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/util/logging"
"sigs.k8s.io/gateway-api-inference-extension/version"
)

var (
Expand Down Expand Up @@ -197,6 +198,8 @@ func (r *Runner) Run(ctx context.Context) error {
flag.Parse()
initLogging(&opts)

setupLog.Info("GIE build", "commit-sha", version.CommitSHA, "build-ref", version.BuildRef)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we set log levels on the setup log? If so, this feels like a Debug level log

Copy link
Contributor Author

@nirrozenbaum nirrozenbaum Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don’t you want to always know the details of the image we’re running? last commit sha? currently when seeing the log we have no way to know what version of GIE was used.
This is a common practice, also in kubernetes.. for example:
https://github.com/kubernetes/kubernetes/blob/master/cmd/kube-scheduler/app/server.go#L174


// Validate flags
if err := validateFlags(); err != nil {
setupLog.Error(err, "Failed to validate flags")
Expand Down Expand Up @@ -242,7 +245,7 @@ func (r *Runner) Run(ctx context.Context) error {
// --- Setup Metrics Server ---
customCollectors := []prometheus.Collector{collectors.NewInferencePoolMetricsCollector(datastore)}
metrics.Register(customCollectors...)
metrics.RecordInferenceExtensionInfo()
metrics.RecordInferenceExtensionInfo(version.CommitSHA, version.BuildRef)
// Register metrics handler.
// Metrics endpoint is enabled in 'config/default/kustomization.yaml'. The Metrics options configure the server.
// More info:
Expand Down
12 changes: 2 additions & 10 deletions pkg/epp/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ const (
InferenceExtension = "inference_extension"
)

var (
// The git hash of the latest commit in the build.
CommitSHA string

// The build ref from the _PULL_BASE_REF from cloud build trigger.
BuildRef string
)

var (
// Inference Model Metrics
requestCounter = prometheus.NewCounterVec(
Expand Down Expand Up @@ -437,6 +429,6 @@ func RecordPrefixCacheMatch(matchedLength, totalLength int) {
}
}

func RecordInferenceExtensionInfo() {
InferenceExtensionInfo.WithLabelValues(CommitSHA, BuildRef).Set(1)
func RecordInferenceExtensionInfo(commitSha, buildRef string) {
InferenceExtensionInfo.WithLabelValues(commitSha, buildRef).Set(1)
}
8 changes: 8 additions & 0 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ limitations under the License.

package version

var (
// The git hash of the latest commit in the build.
CommitSHA string

// The build ref from the _PULL_BASE_REF from cloud build trigger.
BuildRef string
)

const (
// BundleVersion is the value used for labeling the version of the gateway-api-inference-extension.
BundleVersion = "v0.4.0-dev"
Expand Down