Skip to content
  • Steve Xuereb's avatar
    Use cached IP for google driver · bd580896
    Steve Xuereb authored
    `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
    bd580896