Skip to content

Conversation

@liggitt
Copy link
Contributor

@liggitt liggitt commented Apr 10, 2019

  • restores manager.New signature from before Reorganize code to allow conditional enablement of runtimes #2209 was merged
  • moves plugin install import packages to standalone packages (so that importing the docker package, for example, which is done to satisfy the DockerImages() and DockerInfo() methods, doesn't automatically run the docker collector)
  • adds a github.com/cadvisor/container/install package that installs all optional container collectors
  • installs all optional plugins in manager test and in cadvisor#main()
  • switches plugin registration to be an actual interface, instead of a bare method
  • moves plugin-specific init code into plugin hooks so callers don't have to recreate it

/cc @dims

@liggitt
Copy link
Contributor Author

liggitt commented Apr 10, 2019

/cc @dashpole

still testing this, but wanted to get it opened for early review

@liggitt
Copy link
Contributor Author

liggitt commented Apr 10, 2019

the first commit simply restores the manager.New signature and logic... the remaining commits make it easy to see the imports getting whittled away

@liggitt
Copy link
Contributor Author

liggitt commented Apr 10, 2019

I'll open a WIP PR in kubernetes as well to exercise vendoring and CI there

@liggitt
Copy link
Contributor Author

liggitt commented Apr 10, 2019

/retest

@dims
Copy link
Contributor

dims commented Apr 10, 2019

/test pull-cadvisor-e2e

@dims
Copy link
Contributor

dims commented Apr 10, 2019

thanks for taking care of this @liggitt. glad we were able to go back to the old signature!

@dims
Copy link
Contributor

dims commented Apr 10, 2019

/lgtm

@liggitt
Copy link
Contributor Author

liggitt commented Apr 10, 2019

kube PR to exercise CI is at kubernetes/kubernetes#76355

@derekwaynecarr
Copy link
Contributor

derekwaynecarr commented Apr 10, 2019 via email

@liggitt
Copy link
Contributor Author

liggitt commented Apr 10, 2019

yay for CI:

ERROR(darwin/386,darwin/amd64,windows/386,windows/amd64) cmd/genkubedocs/gen_kube_docs.go:33:13: could not import k8s.io/kubernetes/cmd/kubelet/app (type-checking package "k8s.io/kubernetes/cmd/kubelet/app" failed (/home/prow/go/src/k8s.io/kubernetes/cmd/kubelet/app/auth.go:34:2: could not import k8s.io/kubernetes/pkg/kubelet/server (type-checking package "k8s.io/kubernetes/pkg/kubelet/server" failed (/home/prow/go/src/k8s.io/kubernetes/pkg/kubelet/server/server.go:36:18: could not import github.com/google/cadvisor/container (type-checking package "k8s.io/kubernetes/vendor/github.com/google/cadvisor/container" failed (/home/prow/go/src/k8s.io/kubernetes/vendor/github.com/google/cadvisor/container/factory.go:83:32: Context not declared by package fs))))))
ERROR(darwin/386,darwin/amd64,windows/386,windows/amd64) cmd/genman/gen_kube_man.go:37:13: could not import k8s.io/kubernetes/cmd/kubelet/app (type-checking package "k8s.io/kubernetes/cmd/kubelet/app" failed (/home/prow/go/src/k8s.io/kubernetes/cmd/kubelet/app/auth.go:34:2: could not import k8s.io/kubernetes/pkg/kubelet/server (type-checking package "k8s.io/kubernetes/pkg/kubelet/server" failed (/home/prow/go/src/k8s.io/kubernetes/pkg/kubelet/server/server.go:36:18: could not import github.com/google/cadvisor/container (type-checking package "k8s.io/kubernetes/vendor/github.com/google/cadvisor/container" failed (/home/prow/go/src/k8s.io/kubernetes/vendor/github.com/google/cadvisor/container/factory.go:83:32: Context not declared by package fs))))))

since the Context type was used in the plugin interface, moved it to the os-neutral fs/types.go file

liggitt added a commit to liggitt/kubernetes that referenced this pull request Apr 10, 2019
@liggitt liggitt changed the title WIP - move plugin-specific init code into plugin hooks move plugin-specific init code into plugin hooks Apr 10, 2019
@liggitt
Copy link
Contributor Author

liggitt commented Apr 10, 2019

/retest

@dashpole
Copy link
Collaborator

I'm out for a couple weeks. If this needs attention soon, @derekwaynecarr or @tallclair will need to review it. Otherwise, I'll take a look when I get back.

@liggitt
Copy link
Contributor Author

liggitt commented Apr 10, 2019

thanks for the heads up. yeah, would like to avoid letting the signature change linger in cadvisor master

@dims
Copy link
Contributor

dims commented Apr 10, 2019

/lgtm

/assign @tallclair @derekwaynecarr

@liggitt
Copy link
Contributor Author

liggitt commented Apr 10, 2019

kube CI was green with this (kubernetes/kubernetes#76355)

@derekwaynecarr
Copy link
Contributor

I am fine with this change.

err := container.RegisterPlugin("docker", container.PluginFn{
InitializeContextFn: func(context *fs.Context) error {
docker.SetTimeout(dockerClientTimeout)
// Try to connect to docker indefinitely on startup.

Choose a reason for hiding this comment

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

Is the Docker plugin the only one that retries the initialization because of the design of Docker itself? or were you planning on adding this connection retry logic for the other plugins at a later time? I'm just curious why the docker plugin is different from the others... thanks in advance for your answer!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is simply moving the existing behavior, I'll defer to the cadvisor maintainers on the reason for the current behavior

Choose a reason for hiding this comment

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

Ah, cool. Sorry, didn't realize it was the existing behaviour...

Copy link
Contributor

Choose a reason for hiding this comment

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

historical context: #1871

It was fixing a specific bug with docker. Not sure if the same bug could exist in the other runtimes...

Copy link
Contributor

@tallclair tallclair left a comment

Choose a reason for hiding this comment

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

LGTM, just a couple stylistic points - take 'em or leave 'em.

err := container.RegisterPlugin("docker", container.PluginFn{
InitializeContextFn: func(context *fs.Context) error {
docker.SetTimeout(dockerClientTimeout)
// Try to connect to docker indefinitely on startup.
Copy link
Contributor

Choose a reason for hiding this comment

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

historical context: #1871

It was fixing a specific bug with docker. Not sure if the same bug could exist in the other runtimes...

This config struct is now used in the plugin InitializeContext method, so it should be defined in the os-neutral types.go file
@liggitt liggitt force-pushed the plugin-init-hooks branch from 655e1c1 to f8a73e0 Compare April 11, 2019 13:51
@liggitt
Copy link
Contributor Author

liggitt commented Apr 11, 2019

@dims
Copy link
Contributor

dims commented Apr 11, 2019

/lgtm

@tallclair can we please merge this? would be good to try to get a full weekends worth of CI testing in k/k

@tallclair tallclair merged commit 9db8c7d into google:master Apr 11, 2019
@liggitt liggitt deleted the plugin-init-hooks branch January 23, 2020 15:47
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.

6 participants