Skip to content
Snippets Groups Projects
Unverified Commit bd580896 authored by Steve Azzopardi's avatar Steve Azzopardi
Browse files

Use cached IP for google driver

`GetIP` gets called every time `GetSSHHostname` is called which is
called to run every ssh command to the machine. `GetIP` is sending a
request to the API every time we request it.

Check if the in-memory IP is available before sending a request to the
API, and save it at the end as well if it's not present.

Adding tests is quite difficult here since the client for accessing the
Google API is created within `GetIP` so it's not something that can be
mocked easily. To make it testable we require a lot of changes to the
google driver which will be riskier the not adding tests.

Below are some metrics on how many times we used to call the API for the
IP address when creating and removing a machine:

**Before Patch:**
Number of `GetIP` Calls: 21
Number of `Instance.Get` Calls: 21

**After Patch:**
Number of `GetIP` Calls: 21
Number of `Instance.Get` Calls: 1
parent 220f80f7
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment