Skip to content

Config validate#859

Closed
ogaca-dd wants to merge 3 commits into
open-telemetry:mainfrom
ogaca-dd:config-validate
Closed

Config validate#859
ogaca-dd wants to merge 3 commits into
open-telemetry:mainfrom
ogaca-dd:config-validate

Conversation

@ogaca-dd
Copy link
Copy Markdown
Contributor

@ogaca-dd ogaca-dd commented Oct 8, 2025

This PR automatically validates the Configuration:

  • Move collector.Config to its own package config to avoid dependency cycle.
  • Embeds the collector.Config into the controller.Config
  • Move controller.Config.Validate content to config.Config.Validate

It is a replacement for #849.

Note: Reviewing commit by commit is recommended.

"should be in the range [0..1]. 0 disables off-cpu profiling")
}

if !cfg.NoKernelVersionCheck {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The following part is mixing configuration validation with system validation. This should be avoided.

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.

I have just moved the existing code.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe it's time to separate it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

System checks should maybe stay in internal/controller while configuration checks should be close to collector/config.

Comment on lines +94 to +97
if cfg.VerboseMode {
minMajor, minMinor = 5, 2
} else {
minMajor, minMinor = 4, 19
Copy link
Copy Markdown
Member

@florianl florianl Oct 8, 2025

Choose a reason for hiding this comment

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

This check is incorrect. 4.19 is no longer supported, as the project moved on and the instruction limit (4096) is no longer enforced on eBPF programs. As an example - unwind_native currently uses 7014 instructions on amd64.
The bump of the kernel version is therefore not related to the changes around cfg.VerboseMode, but it enabled the changes around cfg.VerboseMode.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The minimal supported kernel version (for x86) should align with https://github.com/open-telemetry/opentelemetry-ebpf-profiler?tab=readme-ov-file#supported-linux-kernel-version and not make a difference based on cfg.VerboseMode.

@ogaca-dd
Copy link
Copy Markdown
Contributor Author

ogaca-dd commented Oct 8, 2025

How to fix CI / Check licenses of dependencies (pull_request)?

Running make legal locally removes a lot of files.

@ogaca-dd ogaca-dd marked this pull request as ready for review October 8, 2025 15:08
@ogaca-dd ogaca-dd requested review from a team as code owners October 8, 2025 15:08
return fmt.Errorf("invalid sampling frequency: %d", cfg.SamplesPerSecond)
}

if cfg.MapScaleFactor > 8 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if cfg.MapScaleFactor > 8 {
if cfg.MapScaleFactor > MaxArgMapScaleFactor {

"should be in the range [0..1]. 0 disables off-cpu profiling")
}

if !cfg.NoKernelVersionCheck {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe it's time to separate it.

BPFVerifierLogLevel uint `mapstructure:"bpf_verifier_log_level"`
NoKernelVersionCheck bool `mapstructure:"no_kernel_version_check"`
MaxGRPCRetries uint32 `mapstructure:"max_grpc_retries"`
MaxRPCMsgSize int `mapstructure:"max_rpc_msg_size"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should there be a check on MaxRPCMsgSize? As it is of type int, it could also be negative.

@florianl
Copy link
Copy Markdown
Member

florianl commented Oct 8, 2025

How to fix CI / Check licenses of dependencies (pull_request)?

Running make legal locally removes a lot of files.

Running make clean; make legal will add the missing legal files. Here, this is:

?? LICENSES/github.com/go-viper/
?? LICENSES/github.com/gobwas/
?? LICENSES/github.com/knadh/
?? LICENSES/github.com/mitchellh/
?? LICENSES/go.opentelemetry.io/collector/confmap/
?? LICENSES/go.uber.org/zap/
?? LICENSES/go.yaml.in/

In this process, no file was removed.

@dmathieu
Copy link
Copy Markdown
Member

dmathieu commented Oct 8, 2025

This does way more than just validate config. Could you split it?

@ogaca-dd
Copy link
Copy Markdown
Contributor Author

ogaca-dd commented Oct 9, 2025

@florianl
After running make clean && make legal I have the following files deleted

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        deleted:    LICENSES/github.com/cilium/ebpf/LICENSE
        deleted:    LICENSES/github.com/elastic/go-freelru/LICENSE
        deleted:    LICENSES/github.com/elastic/go-freelru/NOTICE
        deleted:    LICENSES/github.com/elastic/go-perf/LICENSE
        deleted:    LICENSES/github.com/gogo/protobuf/LICENSE
        deleted:    LICENSES/github.com/google/uuid/LICENSE
        deleted:    LICENSES/github.com/hashicorp/go-version/.github/dependabot.yml
        deleted:    LICENSES/github.com/hashicorp/go-version/.github/workflows/go-tests.yml
        deleted:    LICENSES/github.com/hashicorp/go-version/CHANGELOG.md
        deleted:    LICENSES/github.com/hashicorp/go-version/LICENSE
        deleted:    LICENSES/github.com/hashicorp/go-version/README.md
        deleted:    LICENSES/github.com/hashicorp/go-version/constraint.go
        deleted:    LICENSES/github.com/hashicorp/go-version/constraint_test.go
        deleted:    LICENSES/github.com/hashicorp/go-version/go.mod
        deleted:    LICENSES/github.com/hashicorp/go-version/version.go
        deleted:    LICENSES/github.com/hashicorp/go-version/version_collection.go
        deleted:    LICENSES/github.com/hashicorp/go-version/version_collection_test.go
        deleted:    LICENSES/github.com/hashicorp/go-version/version_test.go
        deleted:    LICENSES/github.com/josharian/native/license
        deleted:    LICENSES/github.com/json-iterator/go/LICENSE
        deleted:    LICENSES/github.com/klauspost/cpuid/v2/LICENSE
        deleted:    LICENSES/github.com/mdlayher/kobject/LICENSE.md
        deleted:    LICENSES/github.com/mdlayher/netlink/LICENSE.md
        deleted:    LICENSES/github.com/mdlayher/socket/LICENSE.md
        deleted:    LICENSES/github.com/minio/sha256-simd/LICENSE
        deleted:    LICENSES/github.com/modern-go/concurrent/LICENSE
        deleted:    LICENSES/github.com/modern-go/reflect2/LICENSE
        deleted:    LICENSES/github.com/peterbourgon/ff/v3/LICENSE
        deleted:    LICENSES/github.com/sirupsen/logrus/LICENSE
        deleted:    LICENSES/github.com/zeebo/xxh3/LICENSE
        deleted:    LICENSES/go.opentelemetry.io/collector/consumer/LICENSE
        deleted:    LICENSES/go.opentelemetry.io/collector/consumer/xconsumer/LICENSE
        deleted:    LICENSES/go.opentelemetry.io/collector/featuregate/LICENSE
        deleted:    LICENSES/go.opentelemetry.io/collector/pdata/LICENSE
        deleted:    LICENSES/go.opentelemetry.io/collector/pdata/pprofile/LICENSE
        deleted:    LICENSES/go.opentelemetry.io/ebpf-profiler/LICENSE
        deleted:    LICENSES/go.opentelemetry.io/otel/LICENSE
        deleted:    LICENSES/go.opentelemetry.io/otel/metric/LICENSE
        deleted:    LICENSES/go.uber.org/multierr/LICENSE.txt
        deleted:    LICENSES/golang.org/x/arch/LICENSE
        deleted:    LICENSES/golang.org/x/exp/constraints/LICENSE
        deleted:    LICENSES/golang.org/x/net/LICENSE
        deleted:    LICENSES/golang.org/x/sync/errgroup/LICENSE
        deleted:    LICENSES/golang.org/x/sys/unix/LICENSE
        deleted:    LICENSES/golang.org/x/text/LICENSE
        deleted:    LICENSES/google.golang.org/genproto/googleapis/rpc/status/LICENSE
        deleted:    LICENSES/google.golang.org/grpc/LICENSE
        deleted:    LICENSES/google.golang.org/grpc/NOTICE.txt
        deleted:    LICENSES/google.golang.org/protobuf/LICENSE

I ran the command on Ubuntu ARM64. Any ideas?

@ogaca-dd
Copy link
Copy Markdown
Contributor Author

ogaca-dd commented Oct 9, 2025

@dmathieu

This does way more than just validate config. Could you split it?

This PR has the minimal changes to validate the config using this recommend solution.
As there were quite a lot of back and forth (This is the third version) can we make agree first on this PR about all the changes required and then I'll split this PR into small PR?

@dmathieu
Copy link
Copy Markdown
Member

dmathieu commented Oct 9, 2025

This PR also includes a refactoring of the config, which is a nice thing. But that's what I mean should be its own PR.
Making small PRs is actually intended to reduce back and forth, as it helps review the code in smaller chunks rather than large ones.

@ogaca-dd
Copy link
Copy Markdown
Contributor Author

@dmathieu dmathieu closed this Oct 16, 2025
@florianl florianl mentioned this pull request Oct 29, 2025
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.

3 participants