HYPERFLEET-710: Fix config file resolution broken by -trimpath build flag#66
HYPERFLEET-710: Fix config file resolution broken by -trimpath build flag#66ciaranRoche wants to merge 2 commits intomainfrom
Conversation
…flag Replace runtime.Caller(0)-based GetProjectRootDir() with os.Getwd() for resolving relative config file paths. runtime.Caller(0) returns the Go module path when built with -trimpath, causing the db-migrate init container to crash looking for paths like: github.com/openshift-hyperfleet/hyperfleet-api/secrets/db.host instead of the correct /app/secrets/db.host. Also fixes the Helm deployment template secret mount path from /build/secrets to /app/secrets to match the Dockerfile WORKDIR, and clears secret file paths in unit test environment since it uses a mock DB. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe pull request updates path handling and configuration across three areas. The Helm deployment template changes secret volume mount paths from Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/config/config.go`:
- Around line 81-82: The current check "if err != nil || fileContents == "" {
return err }" lets an empty file bypass error when err == nil; change the logic
so that you first return the existing err if non-nil, but if err is nil and
fileContents == "" return a new explicit error (e.g., fmt.Errorf("empty file
contents") ) to signal an empty-config file while preserving the original "no
file configured" behavior; update the block around the variables err and
fileContents accordingly (refer to the function that reads config where err and
fileContents are used).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d464fc6b-6c39-4f21-b897-7f18df504cb5
📒 Files selected for processing (3)
charts/templates/deployment.yamlcmd/hyperfleet-api/environments/e_unit_testing.gopkg/config/config.go
Integration tests use testcontainers for DB and don't need file-based credentials. Without this, the integration test environment fails to initialize when secrets files aren't present at the test CWD. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
/test presubmits-integration |
|
@ciaranRoche: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. |
Summary
runtime.Caller(0)-basedGetProjectRootDir()withos.Getwd()for resolving relative config file paths/build/secretsto/app/secrets(matching DockerfileWORKDIR)Root Cause
GetProjectRootDir()inpkg/config/config.gousesruntime.Caller(0)to derive the project root from the source file path at compile time. When built with-trimpath(required for reproducible builds and FIPS 140-3 compliance),runtime.Caller(0)returns the Go module path instead of the actual filesystem path.Before (broken)
{ "level": "error", "message": "Fatal error", "error": "open github.com/openshift-hyperfleet/hyperfleet-api/secrets/db.host: no such file or directory" }Pod status:
Init:CrashLoopBackOff— API cannot start in any Kubernetes environment.After (fixed)
{ "level": "info", "message": "Migration completed successfully" }{ "level": "info", "message": "Application ready to receive traffic" }Pods:
1/1 RunningTest plan
make test)-trimpathand deployed to GKE clusterJIRA: https://issues.redhat.com/browse/HYPERFLEET-710
🤖 Generated with Claude Code
Summary by CodeRabbit
Breaking Changes
Bug Fixes
Chores