Repository navigation
Description
Describe the bug
When the monkey agent starts, it performs a check to see if it has access to the internet. If the agent does not have internet access, this can cause the monkey agent to hang for 30-60 seconds, which adds significant delay to the blackbox test suite. It also slows down the overall propagation of the monkey and delays user feedback.
We've attempted to prevent this check from running by removing the URLs/IPs from the internet_services config field (#1371), but this did not stop the checks. This is because these checks are run before the agent contacts the island to receive a new configuration. The agent uses the default configuration, which includes the URLs and performs the checks.
As far as I can tell, the agent checks for internet access so it can send this information to the island. However, this information is never used. Below are all of the references to internet_access that I could find:
monkey/monkey/infection_monkey/monkey.py
Lines 119 to 120 in 33aa8d1
| ControlClient.wakeup(parent=self._parent) | |
| ControlClient.load_control_config() |
monkey/monkey/infection_monkey/control.py
Lines 43 to 70 in 33aa8d1
| def wakeup(parent=None, has_internet_access=None): | |
| if parent: | |
| LOG.debug("parent: %s" % (parent,)) | |
| hostname = gethostname() | |
| if not parent: | |
| parent = GUID | |
| if has_internet_access is None: | |
| has_internet_access = check_internet_access(WormConfiguration.internet_services) | |
| monkey = { | |
| "guid": GUID, | |
| "hostname": hostname, | |
| "ip_addresses": local_ips(), | |
| "description": " ".join(platform.uname()), | |
| "internet_access": has_internet_access, | |
| "config": WormConfiguration.as_dict(), | |
| "parent": parent, | |
| "launch_time": str(datetime.now().strftime(DEFAULT_TIME_FORMAT)), | |
| } | |
| if ControlClient.proxies: | |
| monkey["tunnel"] = ControlClient.proxies.get("https") | |
| requests.post( # noqa: DUO123 | |
| "https://%s/api/monkey" % (WormConfiguration.current_server,), | |
| data=json.dumps(monkey), |
| internet_access = BooleanField() |
I have been unable to find any code that uses the internet_access field from the monkey model.
To Reproduce
See #1371 for more information
Suggested solutions
I recommend we remove this capability, as it causes delays in monkey propagation and adds no value.
Tasks
- Remove dead code, build binaries, run blackbox tests. Compare before and after runtimes for the whole test suite. (0d) @mssalvatore
- Run a test and inspect reports to ensure nothing broke. (0d) @mssalvatore
Activity
Agent: Remove internet access check
Island; Remove "internet_access" and "internet_services"
Update changelog for issue #1402
Update changelog for issue #1402