Skip to content

feat(startup): log git commit SHA at startup: v0.54.0 - #312

Open
vparfonov wants to merge 1 commit into
ViaQ:v0.54.0-rhfrom
vparfonov:add-git-commit-to-startup
Open

vparfonov wants to merge 1 commit into
ViaQ:v0.54.0-rhfrom
vparfonov:add-git-commit-to-startup

Conversation

@vparfonov

@vparfonov vparfonov commented Sep 25, 2026 •

Copy link
Copy Markdown

Summary

Add Git commit SHA to Vector startup log for build traceability. When Vector starts, it now logs the commit SHA it was built from, making it easy to identify which code version is running in dev, test, and production environments.

Example output:
Vector has started. debug="false" version="0.47.0" arch="x86_64" revision="" git_commit="8f50ca91d5"

Implementation

Uses a three-tier fallback approach to detect the commit in all build scenarios:

  1. Git command (git rev-parse --short HEAD) — works for local dev builds with full .git
  2. GIT_COMMIT environment variable — set by Makefile's build target
  3. Direct .git file reading — reads .git/HEAD and ref files for Docker/CI builds

Includes minimal .git metadata (~208KB) in Docker build context:

  • .git/HEAD — pointer to current branch
  • .git/refs/heads/ — branch commit references
  • .git/packed-refs — packed ref fallback

Changes

  • build.rs: git_short_hash() with three fallbacks, optional constant
  • src/internal_events/process.rs: git_commit field in startup log
  • src/lib.rs: handle Option<&str> in version string with .unwrap_or("unknown")
  • Makefile: export GIT_COMMIT in build/build-offline, add make image target with macOS platform detection
  • .dockerignore: allow minimal .git metadata with explanatory comment

/assign @jcantrill

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 2b3a8661-2b31-4921-a90e-d6d3cb74674d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@vparfonov

Copy link
Copy Markdown
Author

/hold

@jcantrill

Copy link
Copy Markdown
Member

/approve
/lgtm

@openshift-ci openshift-ci Bot added the lgtm label Sep 25, 2026
@openshift-ci

openshift-ci Bot commented Sep 25, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jcantrill, vparfonov

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jcantrill

Copy link
Copy Markdown
Member

blocked by openshift/cluster-logging-operator#3482 where minio is missing

@jcantrill

Copy link
Copy Markdown
Member

/override ci/prow/clo-functional
/override ci/prow/cluster-logging-operator-e2e

@openshift-ci

openshift-ci Bot commented Sep 25, 2026

Copy link
Copy Markdown

@jcantrill: Overrode contexts on behalf of jcantrill: ci/prow/clo-functional, ci/prow/cluster-logging-operator-e2e

Details

In response to this:

/override ci/prow/clo-functional
/override ci/prow/cluster-logging-operator-e2e

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci openshift-ci Bot removed the lgtm label Sep 25, 2026
@openshift-ci

openshift-ci Bot commented Sep 25, 2026

Copy link
Copy Markdown

New changes are detected. LGTM label has been removed.

@vparfonov vparfonov changed the title feat(startup): log git commit SHA at startup feat(startup): log git commit SHA at startup: v0.54.0 Sep 25, 2026
@vparfonov
vparfonov force-pushed the add-git-commit-to-startup branch from 0c7e3ee to 2567d92 Compare September 25, 2026 14:35
@vparfonov

Copy link
Copy Markdown
Author

/retest

Add git_commit field to Vector startup log showing the commit SHA the binary
was built from. Uses three-tier fallback:
1. git rev-parse --short HEAD (local builds with full .git)
2. GIT_COMMIT environment variable (set by Makefile)
3. Direct .git file reading (Docker builds with minimal .git metadata)

Include minimal .git metadata (~208KB) in Docker context:
- .git/HEAD
- .git/refs/heads
- .git/packed-refs

This enables git commit detection in all build scenarios: local dev, Docker
builds, and CI/ART without requiring full git history.

Changes:
- build.rs: add git_short_hash() with three fallbacks, use optional constant
- src/internal_events/process.rs: add git_commit field to startup log
- src/lib.rs: handle Option<&str> in version string
- Makefile: export GIT_COMMIT in build targets, add image target with platform detection
- .dockerignore: allow minimal .git metadata

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@vparfonov
vparfonov force-pushed the add-git-commit-to-startup branch from 2567d92 to 92a262c Compare September 25, 2026 17:59
@openshift-ci

openshift-ci Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

@vparfonov: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/clo-functional 2567d92 link true /test clo-functional
ci/prow/cargo-fmt-check 92a262c link false /test cargo-fmt-check
ci/prow/cargo-clippy-check 92a262c link false /test cargo-clippy-check

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants