lib: introduce github.com/google/cadvisor/lib — a lean, kubelet-focused library module#3895
Merged
Conversation
7252441 to
82de42e
Compare
…ry module A subdirectory module holding the kubelet-only surface of cAdvisor (manager, container, fs, cache, machine, metrics, storage, stats, watcher, cadvisorflags, and lib/model). The manager exposes injection seams that the full binary fills in and the kubelet leaves nil, so the library stays lean. lib/model merges the leaf types of info/v1 and info/v2. Both named a filesystem type FsInfo (machine-level vs runtime); since they now share one package, the runtime type keeps the name FsInfo and the machine-level one is FilesystemInfo. Signed-off-by: Davanum Srinivas <davanum@gmail.com>
root and cmd require+replace github.com/google/cadvisor/lib => ./lib (and ../lib). build.sh stamps version symbols in lib/version; the Makefile and check_gotidy.sh run tests/lint/tidy over the lib module too. Signed-off-by: Davanum Srinivas <davanum@gmail.com>
info/v1 becomes thin aliases to lib/model plus the v1 consts and docker types. info/v2 aliases the identical leaf types and keeps its own ContainerInfo, ContainerStats and Spec, plus the from-v1 converters the REST handlers use. Signed-off-by: Davanum Srinivas <davanum@gmail.com>
Redirect moved-package imports to github.com/google/cadvisor/lib/* and delete the duplicated root copies. The storage-driver registry consolidates into lib/storage -- root and lib both registered the storage_driver_* flags, which would double-register. The remaining root packages (collector, events, perf, resctrl, summary, validate, client, ...) adapt to the library. Signed-off-by: Davanum Srinivas <davanum@gmail.com>
cmd builds the cAdvisor binary and v1/v2 REST API against lib, registering the perf/resctrl factories, summary reader, process-list and app-metrics providers, the cpu-load reader, and the events.EventManager (via the library's EventSink) into the manager's seams. Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This introduces
github.com/google/cadvisor/lib, a lean library submodule containing thekubelet-facing subset of cAdvisor, while keeping the standalone cAdvisor binary and its v1/v2
REST API fully working. The goal: let the kubelet (and other library consumers) depend on a
small, stable cAdvisor library directly, instead of importing the full module — and its
binary-only dependency surface — or carrying an out-of-tree fork.
The kubelet embeds cAdvisor for machine info, per-container stats, and the
/metrics/cadvisorseries. Today it imports the full
github.com/google/cadvisormodule, which pulls in thebinary's dependency surface (HTTP server + web UI, the storage drivers, the standalone
prometheus client, perf/resctrl/NVM, cloud-provider probes, …). That bloats the kubelet's
module graph and couples it to code it never runs. A lean, explicitly kubelet-scoped library
module lets the kubelet depend only on what it uses.