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

[autodiscover] - Providing config option to disable Kubeadm config api requests #98

Merged
merged 6 commits into from
Aug 12, 2024

Conversation

gizas
Copy link
Contributor

@gizas gizas commented Jul 3, 2024

Related changes needed for elastic/beats#40086

@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Jul 3, 2024
@gizas gizas added the Team:Cloudnative-Monitoring Label for the Cloud Native Monitoring team label Jul 3, 2024
Comment on lines 150 to 152
if kubeadm {
return clusterInfo, fmt.Errorf("unable to get cluster identifiers from kubeadm-config because conf_kubeadm access has been disabled")
}
Copy link
Member

Choose a reason for hiding this comment

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

One question, will this be reported as an error in the logs? It seems to me if the user disabled that, it should not be reported as an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I will change it to Debug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted to nil

KubeConfig string `config:"kube_config"`

KubeConfig string `config:"kube_config"`
KubeAdm bool `config:"disable_kubeadm"`
Copy link
Contributor

@tetianakravchenko tetianakravchenko Jul 5, 2024

Choose a reason for hiding this comment

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

Suggested change
KubeAdm bool `config:"disable_kubeadm"`
UseKubeAdm bool `config:"use_kubeadm"`

I would use affirmative name instead, so true means enabled, false - disabled, not vice versa
imagine checking in code c.KubeAdm = false would give an impression that it is disabled, it introduce obscurity. WDYT?
default value should be changed in this case

Copy link
Contributor Author

@gizas gizas Jul 5, 2024

Choose a reason for hiding this comment

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

You are right, I was actually thinking about that. Reason that I chose not to is that the absence of setting the variable evaluates to false and it was quicker like that to implement the code. For eg. https://github.com/elastic/beats/blob/feef1138f809281ac0a70ec97be6ed782901c2ab/metricbeat/module/kubernetes/util/kubernetes.go#L1231 the absence here would mean that this will evaluate to false and all will work and wont have to initialise anything in beats

This would mean that in beats we will need to revert the logic.
In a nutshell,
So not setting use_kubeadm -> use_kubeadm: false in beats module but in here KubeAdm should be true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tetianakravchenko I repeated the tests with use_kubeadm

Final PR has the logic reverted , I mean that use_kubeadm is true by default
Users need to disable (use_kubeadm: false) to see no api calls

I have run tests with metricbeat:

Initial run is with metricbeat-8.15.0-SNAPSHOT: 170 api calls
Second run is with new build of metricbeat and not setting the use_kubeadm variable (so is true): 170 api calls
3rd run is with new build of metricbeat and setting use_kubeadm variable=false: 0 api calls

Screenshot 2024-07-19 at 1 00 22 PM

Reverting back returns the calls

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for reverting the logic and tests!

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

@ycombinator
Copy link
Contributor

(Note to self and anyone else watching this PR) @gizas is on PTO until the last week of August.

@gizas gizas merged commit 8d70795 into main Aug 12, 2024
3 checks passed
@gizas gizas deleted the kubeadm branch August 13, 2024 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Cloudnative-Monitoring Label for the Cloud Native Monitoring team Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants