Skip to content

fix(oracledb_exporter): Support CGO_ENABLED=0 cross-compilation#6168

Merged
thampiotr merged 8 commits into
mainfrom
korniltsev-grafanista/oracledb-nocgo-build
May 20, 2026
Merged

fix(oracledb_exporter): Support CGO_ENABLED=0 cross-compilation#6168
thampiotr merged 8 commits into
mainfrom
korniltsev-grafanista/oracledb-nocgo-build

Conversation

@korniltsev-grafanista
Copy link
Copy Markdown
Contributor

The oracledb integration imported github.com/oracle/oracle-db-appdev-monitoring/collector, which transitively pulls in github.com/godror/godror. godror requires CGO, so cd collector && CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build . failed with "undefined: VersionInfo" and similar errors from godror's orahlp.go.

The fix follows the existing loki.source.journal dual-file pattern: pure-Go config and helpers stay unconditional, the godror import and New() body move behind //go:build cgo, and a //go:build !cgo stub New() returns a clear error so configs surface a meaningful message in no-cgo builds.

To prevent regressions, two new CI jobs cross-compile the collector (in test_mac.yml) and the pyroscope playground (in test_pyroscope_pr.yml) for linux/amd64 and linux/arm64 with CGO_ENABLED=0 on macos-15-xlarge.

The oracledb integration imported github.com/oracle/oracle-db-appdev-monitoring/collector,
which transitively pulls in github.com/godror/godror. godror requires CGO, so
`cd collector && CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build .` failed with
"undefined: VersionInfo" and similar errors from godror's orahlp.go.

Apply the existing loki.source.journal dual-file pattern: keep pure-Go config
and helpers unconditional, move the godror-touching New() body behind
//go:build cgo, and add a //go:build !cgo stub New() that returns a clear
error so configs surface a meaningful message in no-cgo builds.

Also add CI cross-compile jobs covering linux/amd64 and linux/arm64 on
macos-15-xlarge: collector in test_mac.yml, pyroscope playground in
test_pyroscope_pr.yml.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@korniltsev-grafanista korniltsev-grafanista changed the title fix(oracledb_exporter): support CGO_ENABLED=0 cross-compilation fix(oracledb_exporter): Support CGO_ENABLED=0 cross-compilation May 1, 2026
korniltsev-grafanista and others added 4 commits May 1, 2026 17:43
Replace the goarch matrix on the new cross-compile jobs with sequential
linux/amd64 + linux/arm64 build steps in a single job, and turn off
setup-go caching on these jobs so they run from a clean module cache.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Merge the collector and pyroscope playground cross-compile jobs into
one job in test_mac.yml with four sequential build steps (collector
amd64/arm64, pyroscope playground amd64/arm64), and rename it to
clarify the purpose: keeping mac-to-linux cross-compilation working for
developers who build Alloy on macOS but test/run on linux.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Move CGO_ENABLED=0 and GOOS=linux to job-level env on the mac-to-linux
cross-compile job, leaving only GOARCH inline. Drop step-level names
from the four build steps so the run command itself labels them.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The job name already communicates the intent.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@korniltsev-grafanista korniltsev-grafanista marked this pull request as ready for review May 1, 2026 08:09
@korniltsev-grafanista korniltsev-grafanista requested a review from a team as a code owner May 1, 2026 08:09
Comment thread .github/workflows/test_mac.yml Outdated
- run: cd collector && GOARCH=amd64 go build .
- run: cd collector && GOARCH=arm64 go build .
- run: GOARCH=amd64 go build ./internal/component/pyroscope/util/internal/cmd/playground
- run: GOARCH=arm64 go build ./internal/component/pyroscope/util/internal/cmd/playground
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would only one arch here be sufficient?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

no

Comment thread .github/workflows/test_mac.yml Outdated
@thampiotr thampiotr merged commit 63ab53d into main May 20, 2026
46 checks passed
@thampiotr thampiotr deleted the korniltsev-grafanista/oracledb-nocgo-build branch May 20, 2026 09:38
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.

2 participants