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

[cmd/builder] ocb ignores otelcol_version if set to v0.86.0 or higher #8692

Closed
robinlindberg opened this issue Oct 17, 2023 · 4 comments · Fixed by #8713
Closed

[cmd/builder] ocb ignores otelcol_version if set to v0.86.0 or higher #8692

robinlindberg opened this issue Oct 17, 2023 · 4 comments · Fixed by #8713
Labels
area:builder bug Something isn't working priority:p1 High

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 (8691).

Describe the bug
Before 0.87.0 was released my setup was working, using 0.86.0. After release of 0.87.0 I get a build error saying:

\go.opentelemetry.io\collector\receiver\otlpreceiver@v0.86.0\factory.go:71:37: not enough arguments in call to receivers.GetOrAdd
  have (*Config, func() (*otlpReceiver, error))
  want (*Config, func() (*otlpReceiver, error), *component.TelemetrySettings)

See images in bottom for more details.

It seems that PR 8169 introduced a new required parameter, component.TelemetrySettings, which fails any build with a otlpreceiver of an older version than 0.87.0.

If I change my config to match the latest version it builds.

I tried downloading the binary version of the builder, just to make sure I did not have any issues there with versions etc and I got the same behavior.

Steps to reproduce
go install go.opentelemetry. io/collector/cmd/builder@v0.86.0
builder --config="path to yaml defined below" --output-path="some output path"

What did you expect to see?
A successful build

What did you see instead?
image

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
@robinlindberg robinlindberg added the bug Something isn't working label Oct 17, 2023
@robinlindberg robinlindberg changed the title Breaking change in 0.87.0? Build fails and demands component.TelemetrySettings argument for call to receivers.GetOrAdd Breaking change in 0.87.0 of otlpreceiver? Build fails and demands component.TelemetrySettings argument for call to receivers.GetOrAdd Oct 18, 2023
@mx-psi
Copy link
Member

mx-psi commented Oct 19, 2023

I can reproduce, a more minimal manifest would be the following:

dist:
  otelcol_version: 0.86.0

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

exporters:
  - gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.86.0

This generates the following go.mod for me:

Generated go.mod file with --skip-compilation
// Code generated by "go.opentelemetry.io/collector/cmd/builder". DO NOT EDIT.

module go.opentelemetry.io/collector/cmd/builder

go 1.20

require (
	github.com/stretchr/testify v1.8.4
	go.opentelemetry.io/collector/component v0.87.0
	go.opentelemetry.io/collector/connector v0.87.0
	go.opentelemetry.io/collector/exporter v0.87.0
	go.opentelemetry.io/collector/exporter/otlpexporter v0.86.0
	go.opentelemetry.io/collector/extension v0.87.0
	go.opentelemetry.io/collector/otelcol v0.87.0
	go.opentelemetry.io/collector/processor v0.87.0
	go.opentelemetry.io/collector/receiver v0.87.0
	go.opentelemetry.io/collector/receiver/otlpreceiver v0.86.0
	golang.org/x/sys v0.12.0
)

require (
	contrib.go.opencensus.io/exporter/prometheus v0.4.2 // indirect
	github.com/beorn7/perks v1.0.1 // indirect
	github.com/cenkalti/backoff/v4 v4.2.1 // indirect
	github.com/cespare/xxhash/v2 v2.2.0 // indirect
	github.com/davecgh/go-spew v1.1.1 // indirect
	github.com/felixge/httpsnoop v1.0.3 // indirect
	github.com/fsnotify/fsnotify v1.6.0 // indirect
	github.com/go-kit/log v0.2.1 // indirect
	github.com/go-logfmt/logfmt v0.5.1 // indirect
	github.com/go-logr/logr v1.2.4 // indirect
	github.com/go-logr/stdr v1.2.2 // indirect
	github.com/go-ole/go-ole v1.2.6 // indirect
	github.com/gogo/protobuf v1.3.2 // indirect
	github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
	github.com/golang/protobuf v1.5.3 // indirect
	github.com/golang/snappy v0.0.4 // indirect
	github.com/google/uuid v1.3.1 // indirect
	github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
	github.com/inconshreveable/mousetrap v1.1.0 // indirect
	github.com/json-iterator/go v1.1.12 // indirect
	github.com/klauspost/compress v1.17.0 // indirect
	github.com/knadh/koanf/maps v0.1.1 // indirect
	github.com/knadh/koanf/providers/confmap v0.1.0 // indirect
	github.com/knadh/koanf/v2 v2.0.1 // indirect
	github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
	github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
	github.com/mitchellh/copystructure v1.2.0 // indirect
	github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 // indirect
	github.com/mitchellh/reflectwalk v1.0.2 // indirect
	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
	github.com/modern-go/reflect2 v1.0.2 // indirect
	github.com/mostynb/go-grpc-compression v1.2.1 // indirect
	github.com/pmezard/go-difflib v1.0.0 // indirect
	github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
	github.com/prometheus/client_golang v1.17.0 // indirect
	github.com/prometheus/client_model v0.5.0 // indirect
	github.com/prometheus/common v0.44.0 // indirect
	github.com/prometheus/procfs v0.11.1 // indirect
	github.com/prometheus/statsd_exporter v0.22.7 // indirect
	github.com/rs/cors v1.10.0 // indirect
	github.com/shirou/gopsutil/v3 v3.23.9 // indirect
	github.com/shoenig/go-m1cpu v0.1.6 // indirect
	github.com/spf13/cobra v1.7.0 // indirect
	github.com/spf13/pflag v1.0.5 // indirect
	github.com/tklauser/go-sysconf v0.3.12 // indirect
	github.com/tklauser/numcpus v0.6.1 // indirect
	github.com/yusufpapurcu/wmi v1.2.3 // indirect
	go.opencensus.io v0.24.0 // indirect
	go.opentelemetry.io/collector v0.87.0 // indirect
	go.opentelemetry.io/collector/config/configauth v0.86.0 // indirect
	go.opentelemetry.io/collector/config/configcompression v0.86.0 // indirect
	go.opentelemetry.io/collector/config/configgrpc v0.86.0 // indirect
	go.opentelemetry.io/collector/config/confighttp v0.86.0 // indirect
	go.opentelemetry.io/collector/config/confignet v0.87.0 // indirect
	go.opentelemetry.io/collector/config/configopaque v0.86.0 // indirect
	go.opentelemetry.io/collector/config/configtelemetry v0.87.0 // indirect
	go.opentelemetry.io/collector/config/configtls v0.86.0 // indirect
	go.opentelemetry.io/collector/config/internal v0.86.0 // indirect
	go.opentelemetry.io/collector/confmap v0.87.0 // indirect
	go.opentelemetry.io/collector/consumer v0.87.0 // indirect
	go.opentelemetry.io/collector/extension/auth v0.86.0 // indirect
	go.opentelemetry.io/collector/featuregate v1.0.0-rcv0016 // indirect
	go.opentelemetry.io/collector/pdata v1.0.0-rcv0016 // indirect
	go.opentelemetry.io/collector/semconv v0.87.0 // indirect
	go.opentelemetry.io/collector/service v0.87.0 // indirect
	go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.44.0 // indirect
	go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.44.0 // indirect
	go.opentelemetry.io/contrib/propagators/b3 v1.19.0 // indirect
	go.opentelemetry.io/otel v1.19.0 // indirect
	go.opentelemetry.io/otel/bridge/opencensus v0.42.0 // indirect
	go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.42.0 // indirect
	go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.42.0 // indirect
	go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.42.0 // indirect
	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect
	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 // indirect
	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 // indirect
	go.opentelemetry.io/otel/exporters/prometheus v0.42.0 // indirect
	go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.42.0 // indirect
	go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.19.0 // indirect
	go.opentelemetry.io/otel/metric v1.19.0 // indirect
	go.opentelemetry.io/otel/sdk v1.19.0 // indirect
	go.opentelemetry.io/otel/sdk/metric v1.19.0 // indirect
	go.opentelemetry.io/otel/trace v1.19.0 // indirect
	go.opentelemetry.io/proto/otlp v1.0.0 // indirect
	go.uber.org/multierr v1.11.0 // indirect
	go.uber.org/zap v1.26.0 // indirect
	golang.org/x/net v0.15.0 // indirect
	golang.org/x/text v0.13.0 // indirect
	gonum.org/v1/gonum v0.14.0 // indirect
	google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect
	google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
	google.golang.org/grpc v1.58.2 // indirect
	google.golang.org/protobuf v1.31.0 // indirect
	gopkg.in/yaml.v2 v2.4.0 // indirect
	gopkg.in/yaml.v3 v3.0.1 // indirect
)

// ambiguous import: found package cloud.google.com/go/compute/metadata in multiple modules
replace cloud.google.com/go => cloud.google.com/go v0.110.2

The go.mod file requires go.opentelemetry.io/collector/receiver v0.87.0, which is the root of the issue. I don't know why it requires this version instead of v0.86.0

@mx-psi
Copy link
Member

mx-psi commented Oct 19, 2023

I cannot reproduce for v0.85.0 🤔 The following manifest builds fine:

dist:
  otelcol_version: 0.85.0

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

exporters:
  - gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.85.0

@codeboten
Copy link
Contributor

Tested this with the following config and confirmed i couldn't reproduce the problem:

dist:
  otelcol_version: 0.87.0

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

exporters:
  - gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.87.0

@mx-psi
Copy link
Member

mx-psi commented Oct 20, 2023

#8713 should fix this

@mx-psi mx-psi changed the title Breaking change in 0.87.0 of otlpreceiver? Build fails and demands component.TelemetrySettings argument for call to receivers.GetOrAdd [cmd/builder] ocb ignores otelcol_version if set to v0.86.0 or higher Oct 20, 2023
@mx-psi mx-psi added the priority:p1 High label Oct 20, 2023
codeboten pushed a commit that referenced this issue Oct 20, 2023
Adds `go.opentelemetry.io/collector/otelcol` to `go.mod` template for
the builder. This fixes #8692.

Since #8443, the `otelcol` folder is its own component. Before this
change, `otelcol_version` was enforced by the `collector` module
dependency:

https://github.com/open-telemetry/opentelemetry-collector/blob/287b98f6973fd6baa278150b9fca8c83abea0af4/cmd/builder/internal/builder/templates/go.mod.tmpl#L23

After this change, the `go mod tidy` step here:

https://github.com/open-telemetry/opentelemetry-collector/blob/287b98f6973fd6baa278150b9fca8c83abea0af4/cmd/builder/internal/builder/main.go#L115

will add the latest available version for the `otelcol` module since
none of the components actually depend on it. For example, with the
`v0.86.0` builder config the output is as follows:

```
❯ go mod tidy -v -compat=1.20
go: finding module for package go.opentelemetry.io/collector/otelcol
go: found go.opentelemetry.io/collector/otelcol in go.opentelemetry.io/collector/otelcol v0.87.0
```

Explicitly adding `otelcol` makes it so the `otelcol_version` is
correctly honored.

**Link to tracking Issue:** Fixes #8692
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:builder bug Something isn't working priority:p1 High
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants