-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(agent_install): only install required packages [SMAGENT-6558] #465
Conversation
8aefeef
to
6ee0707
Compare
plugins/filter/agent.py
Outdated
all_packages = { | ||
"draios-agent": False, | ||
"draios-agent-slim": False, | ||
"draios-agent-kmodule": False, | ||
"draios-agent-legacy-ebpf": False, | ||
} | ||
if pinned: | ||
version = to_agent_version(data) | ||
minver = LooseVersion("1.0.0") | ||
maxver = LooseVersion("13.1.0") | ||
older = minver < LooseVersion(version) < maxver | ||
if older: | ||
all_packages ["draios-agent"] = True | ||
else: | ||
dt = to_agent_driver_type(data) | ||
if dt == "universal_ebpf": | ||
all_packages ["draios-agent-slim"] = True | ||
elif dt == "legacy_ebpf": | ||
all_packages ["draios-agent-slim"] = True | ||
all_packages ["draios-agent-legacy-ebpf"] = True | ||
else: | ||
all_packages ["draios-agent"] = True | ||
all_packages ["draios-agent-slim"] = True | ||
all_packages ["draios-agent-kmodule"] = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least to me, keying the package map off of the driver type makes things a bit more straight forward. As an example:
package_map = {
"universal_ebpf": ["draios-agent-slim"],
"legacy_ebpf": ["draios-agent-slim", "draios-agent-legacy-ebpf"],
"kmod": ["draios-agent", "draios-agent-slim", "draios'agent-kmodule"]
}
...
if older:
return ["draios-agent"]
return package_map[to_agent_driver_type(data)]
In this way we don't have to manually "flip the switch" for packages to install for a given driver and also there is a clear mapping between driver type and package.
The to_agent_install_packages()
and to_agent_uninstall_packages()
methods can be simplified to something like this as well:
to_agent_uninstall_packages()
# hacky global. could make better.
AGENT_PACKAGES = ["draios-agent", "draios-agent-legacy-ebpf", "draios-agent-slim", "draios-agent-kmodule"]
...
def to_agent_uninstall_packages(data):
return [p for p in AGENT_PACKAGES if p not in to_agent_packages(data)]
to_agent_install_packages(data):
def to_agent_install_packages(data):
return to_agent_packages(data)
2a3b3c3
to
c4080f7
Compare
rework the role so to only install the packages required by the selected driver (and therefore, the respective dependencies). Also, remove packages which are no longer required by the selected driver type. Notice we need to craft a list augmented with the selected version, if one is present. Most of the selection logic (namely, based on the version) resides in the 'agent' filter which is probably far from ideal but gets the job done.
REVERTME: try to fool envsubst https://stackoverflow.com/a/61259844
c618a61
to
9e6c06a
Compare
4c5af01
to
8314750
Compare
8314750
to
e027784
Compare
rework the role so to only install the packages required by the
selected driver (and therefore, the respective dependencies).
Also, remove packages which are no longer required by the
selected driver type.
Notice we need to craft a list augmented with the selected
version, if one is present.
Most of the selection logic (namely, based on the version)
resides in the 'agent' filter which is probably far from
ideal but gets the job done.
Side changes to make CI pass on this PR: