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

fix(api): emulator proxy client uri logic #12778

Merged
merged 3 commits into from
May 24, 2023

Conversation

DerekMaggio
Copy link
Contributor

@DerekMaggio DerekMaggio commented May 24, 2023

Overview

The emulator proxy was failing when calling socket.gethostname() when the proxy was not running inside of Docker.

It was fixed to be hard-coded to 127.0.0.1 but this broke opentrons-emulation's usage of the proxy.

To fix, added use_local_host flag to ProxySettings. This flag is defaulted to True.
When set to True the emulator proxy defaults to using 127.0.0.1 as its host name.
When set to False it calls socket.gethostname() and it's internal IP address inside of the Docker network

When running the proxy outside of Docker this flag does not need to be changed.
But when running inside of Docker (i.e. opentrons-emulation) it needs to be set to False.

Test Plan

  • Make sure G-Code CI tests pass with no changes to their configuration
  • Make sure, inside of opentrons-emulation, that the emulator proxy now resolves it's hostname sucessfully when it sets OT_EMULATOR_use_local_host="False"

Review requests

No

Risk assessment

Low, not changing any major functionality. Just adding a simple conditional, whose default value only breaks emulation. Therefore, since I am the main dev for emulation, that's on me to handle.

Derek Maggio added 2 commits May 24, 2023 09:37
- Add `use_local_host` flag to ProxySettings, default to True
- All applications that utilize the proxy directly on the host machine will use localhost.
  - This addresses issues with G-Code tests dying because it cannot resolve the host name
- opentrons-emulation will override this value to `False` in an environment variable cause the host names to be set to the container names. When referencing the container names inside of the docker network these resolve to the internal docker IPs of the emulators.
@codecov
Copy link

codecov bot commented May 24, 2023

Codecov Report

Merging #12778 (1461df1) into edge (baec102) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             edge   #12778   +/-   ##
=======================================
  Coverage   73.49%   73.49%           
=======================================
  Files        2261     2261           
  Lines       62003    62003           
  Branches     6705     6705           
=======================================
  Hits        45570    45570           
  Misses      14835    14835           
  Partials     1598     1598           
Flag Coverage Δ
g-code-testing 96.44% <ø> (ø)
notify-server 89.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
.../src/opentrons/hardware_control/emulation/proxy.py 91.66% <ø> (ø)
...c/opentrons/hardware_control/emulation/settings.py 100.00% <ø> (ø)

@DerekMaggio DerekMaggio marked this pull request as ready for review May 24, 2023 17:17
@DerekMaggio DerekMaggio requested a review from a team as a code owner May 24, 2023 17:17
@DerekMaggio DerekMaggio self-assigned this May 24, 2023
@DerekMaggio
Copy link
Contributor Author

DerekMaggio commented May 24, 2023

Currently working on validating emulation will run successfully with the env var set

@DerekMaggio DerekMaggio changed the title Fix emulator proxy client uri logic fix(api): emulator proxy client uri logic May 24, 2023
@DerekMaggio DerekMaggio force-pushed the fix-emulator-proxy-client-uri-logic branch from 0d353a2 to 63ccbf4 Compare May 24, 2023 18:28
Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@DerekMaggio DerekMaggio merged commit a639572 into edge May 24, 2023
17 of 23 checks passed
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.

None yet

2 participants