Config validate#859
Conversation
Embeds config.Config into controller.Config
| "should be in the range [0..1]. 0 disables off-cpu profiling") | ||
| } | ||
|
|
||
| if !cfg.NoKernelVersionCheck { |
There was a problem hiding this comment.
The following part is mixing configuration validation with system validation. This should be avoided.
There was a problem hiding this comment.
I have just moved the existing code.
There was a problem hiding this comment.
maybe it's time to separate it.
There was a problem hiding this comment.
System checks should maybe stay in internal/controller while configuration checks should be close to collector/config.
| if cfg.VerboseMode { | ||
| minMajor, minMinor = 5, 2 | ||
| } else { | ||
| minMajor, minMinor = 4, 19 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
How to fix CI / Check licenses of dependencies (pull_request)? Running |
| return fmt.Errorf("invalid sampling frequency: %d", cfg.SamplesPerSecond) | ||
| } | ||
|
|
||
| if cfg.MapScaleFactor > 8 { |
There was a problem hiding this comment.
| if cfg.MapScaleFactor > 8 { | |
| if cfg.MapScaleFactor > MaxArgMapScaleFactor { |
| "should be in the range [0..1]. 0 disables off-cpu profiling") | ||
| } | ||
|
|
||
| if !cfg.NoKernelVersionCheck { |
There was a problem hiding this comment.
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"` |
There was a problem hiding this comment.
Should there be a check on MaxRPCMsgSize? As it is of type int, it could also be negative.
Running In this process, no file was removed. |
|
This does way more than just validate config. Could you split it? |
|
@florianl I ran the command on Ubuntu ARM64. Any ideas? |
This PR has the minimal changes to validate the config using this recommend solution. |
|
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. |
This PR automatically validates the Configuration:
collector.Configto its own packageconfigto avoid dependency cycle.collector.Configinto thecontroller.Configcontroller.Config.Validatecontent toconfig.Config.ValidateIt is a replacement for #849.
Note: Reviewing commit by commit is recommended.