open-telemetry / opentelemetry-collector

OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
4.46k stars 1.47k forks source link

ocb go mod tidy bug v0.107.0 #10895

Open agardnerIT opened 3 months ago

agardnerIT commented 3 months ago

I'm following the OCB instructions and getting invalid value "1.21" for flag -compat

I found this issue so I specified go: (whereis go) but that didn't seem to do anything.

`go version

  1. Downloaded v0.107.0
  2. Created my manifest file
dist:
  name: otelcol-dev
  description: Basic OTel Collector distribution for Developers
  output_path: ./otelcol-dev
  otelcol_version: 0.107.0
  go: /usr/local/go/bin/go

receivers:
  - gomod:
      go.opentelemetry.io/collector/receiver/filestatsreceiver v0.107.0
./ocb_0.107.0_darwin_arm64 --config manifest.yaml --verbose
2024-08-16T15:50:36.299+1000    INFO    internal/command.go:125 OpenTelemetry Collector Builder {"version": "(devel)"}
2024-08-16T15:50:36.302+1000    INFO    internal/command.go:161 Using config file       {"path": "manifest.yaml"}
2024-08-16T15:50:36.474+1000    INFO    builder/config.go:142   Using go        {"go-executable": "/usr/local/go/bin/go"}
2024-08-16T15:50:36.475+1000    INFO    builder/main.go:100     Sources created {"path": "./otelcol-dev"}
2024-08-16T15:50:36.475+1000    INFO    builder/main.go:34      Running go subcommand.  {"arguments": ["mod", "tidy", "-compat=1.21"]}
Error: failed to update go.mod: go subcommand failed with args '[mod tidy -compat=1.21]': exit status 2, error message: invalid value "1.21" for flag -compat: maximum supported Go version is 1.20
usage: go mod tidy [-e] [-v] [-x] [-go=version] [-compat=version]
Run 'go help mod tidy' for details.
% go version
go version go1.20.4 darwin/amd64

Extended Manifest

I thought it may have been to do with only having a receiver, so I added processors and exporters. Still the same.

dist:
  name: otelcol-dev
  description: Basic OTel Collector distribution for Developers
  output_path: ./otelcol-dev
  otelcol_version: 0.107.0
  go: /usr/local/go/bin/go

receivers:
  - gomod: go.opentelemetry.io/collector/receiver/filestatsreceiver v0.107.0
processors:
  - gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.107.0
exporters:
  - gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.107.0
  - gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.107.0

Generate default collector

Reading the man it suggests that running without --config will generate a default collector. This also fails, so this bug has nothing to do with the config YAML file:

% ./ocb_0.107.0_darwin_arm64                              
2024-08-16T15:57:02.193+1000    INFO    internal/command.go:125 OpenTelemetry Collector Builder {"version": "(devel)"}
2024-08-16T15:57:02.193+1000    INFO    internal/command.go:136 Using default build configuration
2024-08-16T15:57:02.194+1000    INFO    builder/config.go:142   Using go        {"go-executable": "/usr/local/go/bin/go"}
2024-08-16T15:57:02.197+1000    INFO    builder/main.go:100     Sources created {"path": "/var/folders/kj/8djq04fs2_v7ywp6lqy67bxc0000gn/T/otelcol-distribution2427294044"}
Error: failed to update go.mod: go subcommand failed with args '[mod tidy -compat=1.21]': exit status 2, error message: invalid value "1.21" for flag -compat: maximum supported Go version is 1.20
usage: go mod tidy [-e] [-v] [-x] [-go=version] [-compat=version]
Run 'go help mod tidy' for details.
codeboten commented 3 months ago

thanks for the report @agardnerIT, the policy of go support for the collector is to support N-1 where N is the latest version of go. See https://github.com/open-telemetry/opentelemetry-collector/blob/main/CONTRIBUTING.md#required-tools for more details. As of v0.107.0, the supported versions were go 1.21 and go 1.22

chan-tim-sumo commented 1 month ago

hey @agardnerIT , do you know how come the output shows (devel):

2024-08-16T15:50:36.299+1000    INFO    internal/command.go:125 OpenTelemetry Collector Builder {"version": "(devel)"}

? shouldn't it be 0.107.0?

chan-tim-sumo commented 1 month ago

@codeboten do you have an idea why this might be also?

quarckster commented 1 month ago

I was trying to build a collector with ocb version 0.96.0 and got this error too. Is there a way to stick with the specific Go version?