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

[opampsupervisor]: Skip executing the collector if no config is provided #35430

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

BinaryFissionGames
Copy link
Contributor

@BinaryFissionGames BinaryFissionGames commented Sep 26, 2024

Description:
If an empty config map is received, the supervisor does not run the agent.

The current logic here works fine, but I'm considering adding an option to only do this if the user opts into it. I'm not sure if there's a reason why a user might want to run the collector with the noop config though (maybe for the agent's self-telemetry?)

I've thought about it some more, and I don't think we need a config option here. If users want the collector to use a noop config, they can send a basic noop config.

I think we should also implement #32598 (closed as stale, we'll want to re-open this or open a new issue for it), which would allow users to configure a backup config to use when no config is provided by the server, if they would like.

Link to tracking Issue: Closes #33680

Testing:
e2e test added
Manually tested with a modified OpAMP server to send an empty config map

Documentation:
Update spec where it seemed applicable to call out this behavior.

@BinaryFissionGames BinaryFissionGames force-pushed the feat/opampsupervisor-start-stop-empty-confmap branch from 014352a to 7c00860 Compare October 1, 2024 07:57
Copy link
Member

@djaglowski djaglowski left a comment

Choose a reason for hiding this comment

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

One question but otherwise LGTM


newConfigState := &configState{
mergedConfig: string(newMergedConfigBytes),
emptyConfigMap: len(config.GetConfig().GetConfigMap()) == 0,
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious about the difference between this condition and the if config.GetConfig() != nil above. Are we essentially evaluating the same thing twice, or is there a meaningful difference. If they are not the same, are we sure at this point that config.GetConfig() is not nil? (I don't see where it would have changed, but maybe I missed it.) If they are the same, should we evaluate it once, then use it to control the if/else and also to set this field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you're right that the nil check and this check should be unified in some way. I do think there is currently a subtle difference between the two, but this bool (emptyConfigMap) is a more general and basically overrides whatever is being done above anyways. I'll take a look at that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to unify them here. A note about chaining these getters from the generated protobufs - all these getters have nil checks in them that avoid panic here. So if the config.GetConfig() returns a nil *AgentConfigMap, calling GetConfigMap on the nil value doesn't panic, it just returns a nil map (which has size 0).

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.

Don't execute otel collector if configuration is "noop"
3 participants