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

Enable MITM proxy for requestor probes #535

Merged
merged 10 commits into from
Aug 19, 2021
Merged

Conversation

azawlocki
Copy link
Contributor

@azawlocki azawlocki commented Aug 13, 2021

Resolves #429

This was meant to be a small PR that adds use_proxy = True to the specification of the requestor node in the default goth config file and checks that the communication between the requestor agent (running on Docker host) and the requestor daemon passes through the MITM proxy.

Changes:

  1. Ports 6000-6100 on proxy-nginx are mapped to ports 16000-16100 on the host. This is to make ports 6000-6100 on proxy-nginx reachable via localhost (127.0.0.1) and is important for some non-Linux systems, where the Docker compose network is not reachable directly. On such a system, an agent running on Docker host may reach the daemon by sending a request to an address such as 127.0.0.1:16001. Such request is then forwarded to proxy-nginx:6001 in the Docker network (according to port mapping defined in docker-compose.yml) and then to the MITM proxy (by nginx).

  2. ComposeNetworkManager.start_network() and run_compose_network() context manager return a dictionary with information on the containers started by Docker compose. This information is stored by the Runner and is used to determine the address of the proxy-nginx container. This is not really needed, since thanks to port mapping defined in 1., ports on proxy-nginx assigned to specific daemons are mapped to ports on the Docker host.

  3. Using proxy is turned on for Market API. For some reason, it was turned off, even if calls to Activity API and to Payment API were made through proxy.

@azawlocki azawlocki force-pushed the az/enable-proxy-for-requestor branch from 8f4c6e0 to 92f41c4 Compare August 13, 2021 15:58
@azawlocki azawlocki marked this pull request as draft August 13, 2021 16:10
@azawlocki azawlocki self-assigned this Aug 16, 2021
@azawlocki azawlocki marked this pull request as ready for review August 16, 2021 13:53
@azawlocki azawlocki requested a review from kmazurek August 16, 2021 14:22
Copy link
Contributor

@kmazurek kmazurek left a comment

Choose a reason for hiding this comment

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

The logic looks good! I'd insist on performing some of the cleaning I mentioned.

@@ -13,7 +13,7 @@ services:
# harness on the host machine
image: proxy-nginx
ports:
- "6000:6000"
- "16000-16100:6000-6100"
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps it would be a good idea to add a short comment about why this port mapping is necessary here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (318fb5f)

goth/api_monitor/router_addon.py Outdated Show resolved Hide resolved
goth/runner/__init__.py Outdated Show resolved Hide resolved
nginx_containers = [
info.address
for name, info in self._container_info.items()
if "nginx" in name
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd change this to use the exact name as defined in the default compose file, that is: proxy-nginx. In theory, the compose file may be modified by the user (it's part of the default assets) and it could define another nginx* container.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (318fb5f)

goth/runner/__init__.py Outdated Show resolved Hide resolved
@@ -106,7 +119,12 @@ async def start_network(self, log_dir: Path, force_build: bool = False) -> None:

self._start_log_monitors(log_dir)
await self._wait_for_containers()
self._log_running_containers()
Copy link
Contributor

Choose a reason for hiding this comment

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

We can safely remove this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (318fb5f)

async def start_network(self, log_dir: Path, force_build: bool = False) -> None:
async def start_network(
self, log_dir: Path, force_build: bool = False
) -> Dict[str, ContainerInfo]:
"""Start the compose network based on this manager's compose file.

This step may include (re)building the network's docker images.
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's mention the newly-added return value here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (318fb5f)

@@ -225,6 +238,22 @@ async def _start_container(self) -> None:
)
self._logger.info("IP address: %s", self.ip_address)
Copy link
Contributor

Choose a reason for hiding this comment

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

With the below log lines added I think we can remove this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (318fb5f)

@azawlocki azawlocki requested a review from kmazurek August 18, 2021 17:02
Copy link
Contributor

@kmazurek kmazurek left a comment

Choose a reason for hiding this comment

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

lgtm

@azawlocki azawlocki merged commit 4e5acd2 into master Aug 19, 2021
@azawlocki azawlocki deleted the az/enable-proxy-for-requestor branch August 19, 2021 12:57
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.

Re-enable proxy for requestor
2 participants