Skip to content

CM-904: Fix clientgen scripts when .git points at a missing submodule gitdir#396

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift:masterfrom
bharath-b-rh:cm-904
Apr 6, 2026
Merged

CM-904: Fix clientgen scripts when .git points at a missing submodule gitdir#396
openshift-merge-bot[bot] merged 1 commit intoopenshift:masterfrom
bharath-b-rh:cm-904

Conversation

@bharath-b-rh
Copy link
Copy Markdown
Contributor

Problem

hack/update-clientgen.sh used git rev-parse --show-toplevel to find the repo root. When this repository is used as a git submodule, .git is a file that references the parent repo’s modules/... path. Container builds (e.g. Konflux) often copy only the operator tree into the image, so that referenced path does not exist and git rev-parse fails with:

fatal: not a git repository: .../.git/modules/cert-manager-operator

That breaks make generate during make build in the Dockerfile.

Solution

Resolve SCRIPT_ROOT the same way in spirit as the top of the Makefile: try git rev-parse --show-toplevel, and if that fails, use the directory containing hack/ derived from the script’s location (BASH_SOURCE). The fallback is wrapped in a subshell so || / && precedence does not run pwd when git already succeeded.

Files
hack/update-clientgen.sh — primary fix for image/CI builds.
hack/verify-clientgen.sh — same SCRIPT_ROOT logic for consistency.

… gitdir

Signed-off-by: Bharath B <bhb@redhat.com>
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 6, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 6, 2026

@bharath-b-rh: This pull request references CM-904 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Problem

hack/update-clientgen.sh used git rev-parse --show-toplevel to find the repo root. When this repository is used as a git submodule, .git is a file that references the parent repo’s modules/... path. Container builds (e.g. Konflux) often copy only the operator tree into the image, so that referenced path does not exist and git rev-parse fails with:

fatal: not a git repository: .../.git/modules/cert-manager-operator

That breaks make generate during make build in the Dockerfile.

Solution

Resolve SCRIPT_ROOT the same way in spirit as the top of the Makefile: try git rev-parse --show-toplevel, and if that fails, use the directory containing hack/ derived from the script’s location (BASH_SOURCE). The fallback is wrapped in a subshell so || / && precedence does not run pwd when git already succeeded.

Files
hack/update-clientgen.sh — primary fix for image/CI builds.
hack/verify-clientgen.sh — same SCRIPT_ROOT logic for consistency.

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 openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 007eb00b-f3b2-4459-b6ea-e2d860a6def7

📥 Commits

Reviewing files that changed from the base of the PR and between 1d9ab3b and 7ecc7a4.

📒 Files selected for processing (2)
  • hack/update-clientgen.sh
  • hack/verify-clientgen.sh

Walkthrough

Two shell scripts were updated to resolve SCRIPT_ROOT more robustly. Both now attempt git rev-parse --show-toplevel with stderr suppressed and fall back to computing the repository root from the script's directory location when git metadata is unavailable.

Changes

Cohort / File(s) Summary
Script Root Resolution
hack/update-clientgen.sh, hack/verify-clientgen.sh
Enhanced SCRIPT_ROOT determination to suppress git command errors and provide fallback path computation based on script directory location, ensuring robustness when git metadata is missing or invalid.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci openshift-ci Bot requested review from TrilokGeer and swghosh April 6, 2026 13:50
@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 6, 2026
@bharath-b-rh
Copy link
Copy Markdown
Contributor Author

/cherrypick cert-manager-1.19

no user facing changes hence adding required labels
/label docs-approved
/label qe-approved
/label px-approved

@openshift-cherrypick-robot
Copy link
Copy Markdown

@bharath-b-rh: once the present PR merges, I will cherry-pick it on top of cert-manager-1.19 in a new PR and assign it to you.

Details

In response to this:

/cherrypick cert-manager-1.19

no user facing changes hence adding required labels
/label docs-approved
/label qe-approved
/label px-approved

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 added docs-approved Signifies that Docs has signed off on this PR qe-approved Signifies that QE has signed off on this PR px-approved Signifies that Product Support has signed off on this PR labels Apr 6, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 6, 2026

@bharath-b-rh: This pull request references CM-904 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Problem

hack/update-clientgen.sh used git rev-parse --show-toplevel to find the repo root. When this repository is used as a git submodule, .git is a file that references the parent repo’s modules/... path. Container builds (e.g. Konflux) often copy only the operator tree into the image, so that referenced path does not exist and git rev-parse fails with:

fatal: not a git repository: .../.git/modules/cert-manager-operator

That breaks make generate during make build in the Dockerfile.

Solution

Resolve SCRIPT_ROOT the same way in spirit as the top of the Makefile: try git rev-parse --show-toplevel, and if that fails, use the directory containing hack/ derived from the script’s location (BASH_SOURCE). The fallback is wrapped in a subshell so || / && precedence does not run pwd when git already succeeded.

Files
hack/update-clientgen.sh — primary fix for image/CI builds.
hack/verify-clientgen.sh — same SCRIPT_ROOT logic for consistency.

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 openshift-eng/jira-lifecycle-plugin repository.

Copy link
Copy Markdown
Member

@chiragkyal chiragkyal left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 6, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 6, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bharath-b-rh, chiragkyal

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

@openshift-merge-bot openshift-merge-bot Bot merged commit 2beb5f9 into openshift:master Apr 6, 2026
9 of 10 checks passed
@openshift-cherrypick-robot
Copy link
Copy Markdown

@bharath-b-rh: new pull request created: #397

Details

In response to this:

/cherrypick cert-manager-1.19

no user facing changes hence adding required labels
/label docs-approved
/label qe-approved
/label px-approved

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.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. docs-approved Signifies that Docs has signed off on this PR jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. px-approved Signifies that Product Support has signed off on this PR qe-approved Signifies that QE has signed off on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants