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

🐛bugfix for operator-controller not outputting the right commit ID in the version #1811

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rashmigottipati
Copy link
Member

Description

The --version doesn't output the source code commit ID. It refers to "vcs-ref" in the image instead of "io.openshift.build.commit.id".

Setting the GIT_COMMIT value to SOURCE_GIT_COMMIT if empty (which is a corresponding downstream variable) will ensure that the version outputs the right commit ID as the code from this repo gets copied to another repo for building purposes.

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

@rashmigottipati rashmigottipati requested a review from a team as a code owner February 25, 2025 21:05
Copy link

netlify bot commented Feb 25, 2025

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 6217d52
🔍 Latest deploy log https://app.netlify.com/sites/olmv1/deploys/67c609e5ed09b800082d32e8
😎 Deploy Preview https://deploy-preview-1811--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Feb 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.45%. Comparing base (97b1337) to head (6217d52).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1811      +/-   ##
==========================================
- Coverage   68.50%   68.45%   -0.05%     
==========================================
  Files          63       63              
  Lines        5134     5136       +2     
==========================================
- Hits         3517     3516       -1     
- Misses       1388     1390       +2     
- Partials      229      230       +1     
Flag Coverage Δ
e2e 51.60% <100.00%> (-0.14%) ⬇️
unit 56.01% <0.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@joelanford
Copy link
Member

If this is a downstream-only concern, is it possible to make a change in the downstream repo instead?

I'm kinda curious why the existing upstream implementation doesn't "just work" in downstreams since it should be pulling commit refs for the downstream git repo in the same way.

camilamacedo86

This comment was marked as resolved.

@rashmigottipati
Copy link
Member Author

@joelanford yeah, this is a downstream only concern. And I think it's fine when we build from the repo downstream too, but it's something to do with the way images get generated using ART. That's when it's using the env var SOURCE_GIT_COMMIT which is the downstream equivalent of GIT_COMMIT.

We can fix this in downstream repo directly as well without fixing it here, but I thought fixing it here and sync'ing it downstream would be better to have both repos as close as possible for maintainability purposes. Let me know if you disagree.

@rashmigottipati
Copy link
Member Author

@camilamacedo86 since we were discussing this on slack, will continue the conversation there to avoid typing in two different places :)

Makefile Outdated
Comment on lines 298 to 299
GIT_COMMIT := $(if $(SOURCE_GIT_COMMIT),$(SOURCE_GIT_COMMIT),$(shell git rev-parse HEAD))

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this line. If we (or a fork) want to build binaries with a specific GIT_COMMIT reference, we/they should explicitly set GIT_COMMIT

When GIT_COMMIT is left unset, we will also set $(VERSION_PATH).gitCommit to empty string. So we should:

  1. Initialize gitCommit as "" rather than "unknown" here.
  2. Put this in an if statement that only sets from the build data when gitCommit == "".

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed based on this feedback in the latest commit.

This approach seems better as it eliminates the need to introduce an openshift specific envvar upstream.

@camilamacedo86 camilamacedo86 dismissed their stale review February 28, 2025 06:53

I marked as solved my above comment #1811 (review) to make it easier for the review since we had already sorted out the raised concerns, and we will move with the change for upstream.

@rashmigottipati rashmigottipati force-pushed the fix-commit-ID branch 3 times, most recently from 2dc7dad to 7afc14c Compare March 3, 2025 19:57
Signed-off-by: Rashmi Gottipati <[email protected]>
@@ -29,7 +29,9 @@ func init() {
for _, setting := range info.Settings {
switch setting.Key {
case "vcs.revision":
gitCommit = setting.Value
if gitCommit == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Couldn't this be a check against "unknown", and leave the default value as-is?

Copy link
Contributor

Choose a reason for hiding this comment

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

i.e. is there a need to change the default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants