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

The "extension" configuration item of the configuration file is overwritten #32050

Open
mike9421 opened this issue Mar 31, 2024 · 7 comments
Open
Assignees
Labels
bug Something isn't working cmd/opampsupervisor

Comments

@mike9421
Copy link

Component(s)

cmd/opampsupervisor

What happened?

Description

When I delivered the remote configuration through the OpAMP sample server, I found that the extension in the final configuration of OTEL was cleared, leaving only health_check.

Steps to Reproduce

  1. Fill in the correct configuration to ensure that the opampsupervisor can connect to the backend normally
  2. Start the backend OpAMP sample server
  3. Start opampsupervisor
  4. Deliver remote configuration through OpAMP UI
  5. Check the otel configuration displayed by the OpAMP UI or view the local file named effective.yaml

Expected Result

The extension component I added is not cleared, at most health_check is added

Actual Result

The extension component I added was cleared

Collector version

all

Environment information

OS: Darwin
Compiler: go 1.21

OpenTelemetry Collector configuration

receivers:
  prometheus:
    config:
      scrape_configs:
        - job_name: otel-collector
          scrape_interval: 10s
          static_configs:
            - targets:
              - 0.0.0.0:55149
exporters:
  otlphttp:
    endpoint: http://localhost:4318/v1/metrics
extensions:
  pprof:
  memory_ballast:
    size_mib: "256"
service:
  pipelines:
    metrics:
      exporters:
        - otlphttp
      receivers:
        - prometheus
  extensions:
    - memory_ballast
    - pprof

Log output

No response

Additional context

I know that the extensions configuration item is overwritten in this code.
The fundamental reason is that koanf cannot parse extensions into key-value form, so the previous value will be overwritten.
I think we can solve this problem by adding configuration items to extensions instead of executing koanf.merge directly.

@mike9421 mike9421 added bug Something isn't working needs triage New item requiring triage labels Mar 31, 2024
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@evan-bradley
Copy link
Contributor

evan-bradley commented Apr 15, 2024

Thanks for opening this. You're right, this is currently an issue due to the way the Collector's underlying conf library merges lists. A potential fix in the Collector has been documented here: open-telemetry/opentelemetry-collector#8754. For now, I have an open PR that will introduce a fix for the Supervisor in the meantime: #31641

@evan-bradley evan-bradley removed the needs triage New item requiring triage label Apr 15, 2024
@evan-bradley evan-bradley self-assigned this Apr 15, 2024
Copy link
Contributor

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions github-actions bot added the Stale label Jun 17, 2024
@mike9421
Copy link
Author

mike9421 commented Aug 7, 2024

Information can be synchronized at #8754 and #31641

@github-actions github-actions bot removed the Stale label Aug 8, 2024
Copy link
Contributor

github-actions bot commented Oct 8, 2024

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions github-actions bot added the Stale label Oct 8, 2024
@mike9421
Copy link
Author

Reply to ensure the issue remains open

@github-actions github-actions bot removed the Stale label Oct 29, 2024
@srikanthccv
Copy link
Member

@mike9421 can you verify with the latest changes given the following code has been added to address the issue

// The default koanf behavior is to override lists in the config.
// Instead, we provide this function, which merges the source and destination config's
// extension lists by concatenating the two.
// Will be resolved by https://github.com/open-telemetry/opentelemetry-collector/issues/8754
func configMergeFunc(src, dest map[string]any) error {
srcExtensions := maps.Search(src, []string{"service", "extensions"})
destExtensions := maps.Search(dest, []string{"service", "extensions"})
maps.Merge(src, dest)
if destExt, ok := destExtensions.([]any); ok {
if srcExt, ok := srcExtensions.([]any); ok {
if service, ok := dest["service"].(map[string]any); ok {
service["extensions"] = append(destExt, srcExt...)
}
}
}
return nil
}
?

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

No branches or pull requests

3 participants