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

Fixes Dockerfile based examples to run from correct directory #767

Merged
merged 6 commits into from
Jun 7, 2021

Conversation

evantorrie
Copy link
Contributor

@evantorrie evantorrie commented May 3, 2021

With go-1.16, go install no longer modifies go.mod files to correct omissions of required module imports. This means all go.mod files must provide a complete and correct set of requires module imports.

While the go.mod files inside the examples directories do include the correct requires, some of the Dockerfile examples run a go install command from the corresponding instrumentation directory (one level above the examples directory). This means go install looks at the go.mod file at the instrumentation directory level instead of the go.mod file included in the examples/ directory.

This changes all such cases to set the working directory to the example directory containing the correct go.mod before running go install.

With go-1.16, `go install` no longer modifies `go.mod` files to
correct omissions of required module imports.  This means all `go.mod`
files must provide a complete and correct set of `requires` module
imports.

While the `go.mod` files inside the `examples` directories does
include the correct requires, some of the `Dockerfile` examples run a
`go install` command from the corresponding instrumentation
directory (one level above the examples directory).

This means `go install` was looking at the `go.mod` file at the
instrumentation directory level, not the `go.mod` file included in the
`examples/` directory.  This changes all such cases to set the working
directory to the `example` directory containing the correct `go.mod`
before running `go install`.
@evantorrie
Copy link
Contributor Author

This fixes #623.

However it also indicates we may want to include checking that the examples for each contrib instrumentation build as part of the CI process, as we do in the opentelemetry-go main repo.

I've opened an issue #768 to track this

CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Anthony Mirabella <[email protected]>
Copy link
Contributor

@MrAlias MrAlias left a comment

Choose a reason for hiding this comment

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

Should this include upgrading the base image to 1.16, or have I missed something?

@evantorrie
Copy link
Contributor Author

Should this include upgrading the base image to 1.16, or have I missed something?

It could, but I thought this could be done in a separate PR. For example, in opentelemetry-go-contrib, I believe we're still testing using only go-1.14 and go-1.15, so standardizing the base images on 1.16 should probably be done in conjunction with that.

In this case, the issue is that two examples were pulling from `golang:alpine" rather than a specific version of golang

  1. otelgin
  2. otelmacaron

These were the only ones failing, but I took the opportunity to fix all the examples which were incorrectly trying to run go install from a parent directory with a different go.mod file than that inside the example directory, but just happened to work due to go-1.14 and go-1.15's behavior of silently fixing go.mod files that were incorrect.

In other words, this PR just fixes the previously incorrect behavior - which means they now work with any version of go.

What do you think about creating a separate issue to go through and standardize the Dockerfile based images to all be a consistent version of golang:alpine? Or perhaps use a --build-arg version which would allow building the docker-based examples using the same matrix of supported go versions as we use in the ci-build.

@evantorrie evantorrie changed the title Fixes Dockerfile based examples to run with go-1.16 Fixes Dockerfile based examples to run from correct directory May 4, 2021
@evantorrie evantorrie requested a review from MadVikingGod as a code owner May 21, 2021 22:29
@MrAlias MrAlias merged commit 8714bfd into open-telemetry:main Jun 7, 2021
@Aneurysm9 Aneurysm9 mentioned this pull request Jun 18, 2021
@pellared pellared added this to the untracked milestone Nov 8, 2024
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