Skip to content

[receiver/k8sobjectsreceiver] Handle missing objects via error_mode #38851

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

Merged
merged 12 commits into from
Apr 25, 2025

Conversation

krisztianfekete
Copy link
Contributor

@krisztianfekete krisztianfekete commented Mar 21, 2025

Description

This PR adopts a similar logic to ottl.ErrorMode for k8sobjectsreceiver, enabling users to choose between ignoring, silencing, and propagating errors for missing objects.

The default is propagate, therefore it is backward compatible with the current state.

Link to tracking issue

Fixes #38803

Testing

Added tests, and also tested by building my own image and deployed into a Kubernetes cluster.

Documentation

I've updated receiver/k8sobjectsreceiver/config.yaml and README with the new config options.

@krisztianfekete krisztianfekete marked this pull request as ready for review March 21, 2025 18:02
@krisztianfekete krisztianfekete requested a review from a team as a code owner March 21, 2025 18:02
@atoulme
Copy link
Contributor

atoulme commented Mar 21, 2025

Not a big fan of bringing a language feature of ottl into an exporter. I think the k8sobjectsreceiver can create and maintain its own semantics. That said, will defer to codeowners.

@krisztianfekete
Copy link
Contributor Author

Not a big fan of bringing a language feature of ottl into an exporter. I think the k8sobjectsreceiver can create and maintain its own semantics. That said, will defer to codeowners.

Yes, there are other components re-using that, but more closely related to OTTL maybe. I am fine re-implementing it for this receiver too, if that's the consensus.

@atoulme atoulme marked this pull request as draft March 22, 2025 04:49
@krisztianfekete krisztianfekete marked this pull request as ready for review March 24, 2025 08:37
@krisztianfekete krisztianfekete changed the title [receiver/k8sobjectsreceiver] Handle missing objects via ottl.ErrorMode [receiver/k8sobjectsreceiver] Handle missing objects via error_mode Mar 24, 2025
@atoulme atoulme marked this pull request as draft April 7, 2025 05:10
@krisztianfekete krisztianfekete requested a review from atoulme April 16, 2025 09:49
TylerHelmuth pushed a commit that referenced this pull request Apr 22, 2025
…ic config (#39469)

#### Description

Refactor Validate() to only validate static config without external
calls to Kubernetes API server as discussed in
#38851 (comment)

Once this is merged, the PR linked above should introduce `error_mode`
implemented in `start` too.

#### Link to tracking issue
It is related to the issue and follow-up PR mentioned above, but it
doesn't fix the issue.

#### Testing

I've refactored the tests in config_test.go, so we are not testing
object discovery and added new tests for additional failure modes.
I've build a dev images, and validated that functionality is the same as
before the refactor.

#### Documentation

This is a "breaking change" in a sense we are changing what we are
validating in Validate. The new validation logic will not fail when
objects are missing. The receiver will fail the same way in this case,
but in `start`.
Copy link
Member

@ChrsMark ChrsMark left a comment

Choose a reason for hiding this comment

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

Thank's @krisztianfekete, overall looks good to me with few small suggestions.

Probably a make fmt will fix the lint errors.

@ChrsMark ChrsMark marked this pull request as ready for review April 23, 2025 12:21
…related errors that should propagate regardless of error_mode
Copy link
Member

@ChrsMark ChrsMark left a comment

Choose a reason for hiding this comment

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

LGTM

@songy23 songy23 merged commit 5e6dcfd into open-telemetry:main Apr 25, 2025
173 checks passed
@github-actions github-actions bot added this to the next release milestone Apr 25, 2025
vincentfree pushed a commit to ing-bank/opentelemetry-collector-contrib that referenced this pull request May 6, 2025
…open-telemetry#38851)

#### Description
This PR adopts a similar logic to `ottl.ErrorMode` for
`k8sobjectsreceiver`, enabling users to choose between ignoring,
silencing, and propagating errors for missing objects.

The default is `propagate`, therefore it is backward compatible with the
current state.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes
open-telemetry#38803

<!--Describe what testing was performed and which tests were added.-->
#### Testing
Added tests, and also tested by building my own image and deployed into
a Kubernetes cluster.

<!--Describe the documentation added.-->
#### Documentation
I've updated `receiver/k8sobjectsreceiver/config.yaml` and README with
the new config options.

<!--Please delete paragraphs that you did not use before submitting.-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[k8sobjectsreceiver] Degrade gracefully, when watched CRDs are not found
7 participants