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

add docker_only_prefix_whitelist #1926

Merged
merged 1 commit into from
Jun 21, 2018

Conversation

andyxning
Copy link
Contributor

Partially fix kubernetes/kubernetes#61994

This PR adds docker_only_prefix_whitelist to cadvisor to specify A comma-separated list of cgroup path prefix that needs to be collected even docker-only is specified.

/cc @dashpole @tallclair

@@ -29,6 +30,7 @@ import (
)

var dockerOnly = flag.Bool("docker_only", false, "Only report docker containers in addition to root stats")
var dockerOnlyPrefixWhitelist = flag.String("docker_only_prefix_whitelist", "", "A comma-separated list of cgroup path prefix that needs to be collected when docker-only is specified")
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we call this rawPrefixWhitelist? I am hoping we can move away from dockerOnly, and instead use a whitelist of handlers in the future.

@dashpole
Copy link
Collaborator

lgtm other than naming nit

@dashpole
Copy link
Collaborator

Actually, how would you feel about making this an argument to manager.New()? The desire to whitelist particular cgroup trees seems fairly kubernetes specific, and I would rather not add another flag if we can avoid it. I think this would be a win for everyone in the community, as everyone would see better performance. It would also give us flexibility to change this interface in the future if we want a different model without having to deprecate flags and such.

The only downside is that if people are using cadvisor metrics for particular cgroups that are outside of what we plan to monitor, those would no longer be accessible.

@andyxning
Copy link
Contributor Author

how would you feel about making this an argument to manager.New()?

I have also thought about this since rawPrefixWhitelist is a inter package variable. What i think about integrate this cAdvisor functionality into Kubernetes is to only pass this raw prefix whitelist when docker_only is specified automatically. Adding rawPrefixWhitelist should help us to easily integrate this functionality into Kubernetes.

The only downside is that if people are using cadvisor metrics for particular cgroups that are outside of what we plan to monitor, those would no longer be accessible.

Yep. That is the truth when make rawPrefixWhitelist an argument to manager.New(). IMHO, it should be fine as no users have complained about lacking the ability to customize the whitelist when docker_only has been specified. Since we have no clear plan about how to evolve the related settings, leaving customizing whitelist from command line seems fine. If we need this later, it should also not difficult to add the support.

@andyxning andyxning force-pushed the add_docker-only_whitelist branch 2 times, most recently from 007b71d to 2f1250a Compare April 12, 2018 05:29
@andyxning
Copy link
Contributor Author

/retest

@andyxning
Copy link
Contributor Author

@dashpole @tallclair PTAL. I have moved the configuration from command line to manager field. This should be fine for us to integrate cadvisor into Kubernetes.

@@ -62,14 +66,24 @@ func (self *rawFactory) NewContainerHandler(name string, inHostNamespace bool) (
// The raw factory can handle any container. If --docker_only is set to false, non-docker containers are ignored.
func (self *rawFactory) CanHandleAndAccept(name string) (bool, bool, error) {
accept := name == "/" || !*dockerOnly

if *dockerOnly {
Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of having this only in effect when --docker_only is specified, can we make it always take effect, but have the default be [ "/" ], so all raw cgroups are collected? We can make setting --docker_only set this to [ ] during creation of the raw factory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me. Will do.

Copy link
Contributor Author

@andyxning andyxning Apr 16, 2018

Choose a reason for hiding this comment

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

We can make setting --docker_only set this to [ ] during creation of the raw factory.

We should not do this, imo. What we want is to respect with whitelist settings even docker_only is set and we should customize whitelist settings to at least []string{"/kubepods"} to allow pod level metrics in Kubernetes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What i think is about this:

  • by default setting rawPrefixWhiteList to []string{"/"} to allow all raw cgroups to be collected or be compatible with backwards
  • always filter whitelist raw cgroups and respect with the whitelist settings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PTAL.

@andyxning
Copy link
Contributor Author

Ping @dashpole @tallclair

BTW, after this PR is merged, i will prepare an PR to bump cAdvisor dep to Kubernetes to utilizing this new change.

@dashpole
Copy link
Collaborator

This looks good to me, although I would really like to hear @tallclair 's opinion on this.
@andyxning have you brought this up at sig-instrumentation at all? It may be valuable to hear more opinions on limiting the cgroups that are scraped.

@andyxning
Copy link
Contributor Author

have you brought this up at sig-instrumentation at all? It may be valuable to hear more opinions on limiting the cgroups that are scraped.

No. I have not talk about this in sig-instrumentation. Do we need to do a email to sig-instrumentation to describe this PR.

@andyxning
Copy link
Contributor Author

@dashpole Seems @tallclair has temporarily no response. Do anyone else can help us to review
this?

@andyxning
Copy link
Contributor Author

Ping @dashpole @tallclair

@andyxning
Copy link
Contributor Author

Ping @dashpole @tallclair in case the notification emails are lost in your inbox. :)

@andyxning
Copy link
Contributor Author

/cc @dashpole @tallclair

@andyxning
Copy link
Contributor Author

Ping @dashpole @tallclair

@andyxning
Copy link
Contributor Author

@dashpole @tallclair PTAL. 😆

@andyxning
Copy link
Contributor Author

/cc @dashpole @tallclair PTAL.

1 similar comment
@andyxning
Copy link
Contributor Author

/cc @dashpole @tallclair PTAL.

Copy link
Collaborator

@dashpole dashpole left a comment

Choose a reason for hiding this comment

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

LGTM

@dashpole dashpole merged commit b1535b8 into google:master Jun 21, 2018
@andyxning andyxning deleted the add_docker-only_whitelist branch June 22, 2018 01:52
@andyxning
Copy link
Contributor Author

Will make a PR to Kubernetes once the dependency for cAdvisor is updated to make use of the new functionality. :)

@serathius
Copy link

@andyxning is this integrated into k8s?

@andyxning
Copy link
Contributor Author

@serathius No. Will work on this later this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incompatibility for kubelet stats api and cadvisor docker-only option
3 participants