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

Go install builder installs dev version instead of the specified version #8691

Closed
robinlindberg opened this issue Oct 17, 2023 · 5 comments · Fixed by #8712
Closed

Go install builder installs dev version instead of the specified version #8691

robinlindberg opened this issue Oct 17, 2023 · 5 comments · Fixed by #8712
Labels
bug Something isn't working

Comments

@robinlindberg
Copy link

robinlindberg commented Oct 17, 2023

After some further investigating I believe it is not my setup that is causing this issue, so I moved it from Discussions to Issues.
I also split it to 2 separate issues, since they don't seem related (8692).

Describe the bug
I can't currently install any specific version of the builder.

Steps to reproduce
go install go.opentelemetry. io/collector/cmd/builder@v0.86.0
builder version

What did you expect to see?
ocb version 0.86.0

What did you see instead?
ocb version dev

What version did you use?
Version: v0.86.0

What config did you use?
Config: yaml

dist:
  name: otel-collector.exe
  otelcol_version: 0.86.0

receivers:
  - gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v0.86.0

processors:
  - gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.86.0
  - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/redactionprocessor v0.86.0
  - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.86.0

exporters:
  - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/fileexporter v0.86.0
  - gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.86.0

Environment
OS: Win 11 Version 10.0.22621
Compiler: go 1.21.3

Discussed in #8668

Originally posted by robinlindberg October 11, 2023
This might be two separate bugs.

I am unable to install a specific version of the builder. I always get "dev" which seems to be the default value the version.go file sets.

image-2023-10-11-15-59-19-589

I suspected the builder version being wrong was the cause of the go.mod being filled with both 0.86.0 and 0.87.0 versions. But now I tried using the binaries of the builder directly, instead of doing Go install. I got the same result when building for the non-latest version, e.g. 0.86.0. Building for the latest version works in both scenarios.
image
image

Does anyone have any clue what this might be caused by?

What I have tried:

  • Uninstalling Go
  • Clearing out all files from GOPATH
  • If I instead refer to the latest version, it builds just fine
  • Running everything as a Github action and try building there, completely separate from my machine. Same behavior.
  • Using the builder binary directly instead of using Go install
@mx-psi
Copy link
Member

mx-psi commented Oct 19, 2023

We set the version through a linker flag

- -s -w -X go.opentelemetry.io/collector/cmd/builder/internal.version={{.Version}} -X go.opentelemetry.io/collector/cmd/builder/internal.date={{.Date}}

which go install will not do by default.

We advise users to install the builder from the official releases (see https://opentelemetry.io/docs/collector/custom-collector/#step-1---install-the-builder)

@robinlindberg
Copy link
Author

Thanks for the reply!

I'm not sure I understand what you mean. Is go install not supported for older versions then?

If users are not adviced to use go install, maybe the go install line should be removed from the builders readme? It's a bit confusing since it shows that go install should/can be used: https://github.com/open-telemetry/opentelemetry-collector/tree/main/cmd/builder

@mx-psi
Copy link
Member

mx-psi commented Oct 20, 2023

I'm not sure I understand what you mean. Is go install not supported for older versions then?

Using go install should work, with the caveat that the version will always show up as dev. The binary will work correctly and correspond to the version you specify, but the version will show up wrong because we are not passing the linker flag.

If users are not adviced to use go install, maybe the go install line should be removed from the builders readme? It's a bit confusing since it shows that go install should/can be used: https://github.com/open-telemetry/opentelemetry-collector/tree/main/cmd/builder

That's a good point, thanks for pointing that out :) I agree we should reword this.

@robinlindberg
Copy link
Author

Ah, then I understand how it works 🙂 Thanks for taking the time to explain it!

Should I close this issue then, or do should I leave it and you guys can close it if/when you reword the readme?

@mx-psi
Copy link
Member

mx-psi commented Oct 20, 2023

Let's leave it open until we reword the README

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants