Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Refactoring proxy lifetime to only shutdown when proxy is out-of-date. #839

Merged
120 commits merged into from
May 20, 2021

Conversation

nharper285
Copy link
Contributor

@nharper285 nharper285 commented Apr 29, 2021

Summary of the Pull Request

What is this about?
We'd like to refactor the proxy lifecycle to only delete when the proxy is out-of-date - i.e. when the proxy is older than 7 days or a mismatched version. I've changed two files, proxy.py and timer_daily\init.py to check for the version and timestamp before stopping a live proxy.

PR Checklist

  • Applies to work item: #xxx
  • CLA signed. If not, go over here and sign the CLI.
  • Tests added/passed
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

Info on Pull Request

What does this include?
Changes to two files:
proxy.py:

  • get_or_create() edited to check if timestamp is >7 days.
  • Created is_outdated() to check version and timestamp for out-of-date proxy.
    timer_daily/init.py
  • Proxy check now includes is_outdated() before determining if a proxy should be shutdown.

Validation Steps Performed

Deploying test instance to determine if proxy lives past a single day.

@nharper285
Copy link
Contributor Author

Question about how the proxy is initially deployed:
Currently a proxy won't be deployed until a request comes in. Similarly, if a proxy is deleted due to being out-of-date, do we want to immediately create a new proxy or wait until another forward request comes in?

@nharper285
Copy link
Contributor Author

Exception while executing function: Functions.proxy Result: Failure
Exception: TypeError: can't compare offset-naive and offset-aware datetimes
Stack: File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/dispatcher.py", line 402, in _handle__invocation_request
invocation_id, fi_context, fi.func, args)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/dispatcher.py", line 604, in _run_sync_func
func)(params)
File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/extension.py", line 215, in _raw_invocation_wrapper
result = function(**args)
File "/home/site/wwwroot/proxy/init.py", line 121, in main
result = call_if_user(req, method)
File "/home/site/wwwroot/onefuzzlib/endpoint_authorization.py", line 88, in call_if_user
return call_if(req, method, allow_user=True)
File "/home/site/wwwroot/onefuzzlib/endpoint_authorization.py", line 81, in call_if
return method(req)
File "/home/site/wwwroot/proxy/init.py", line 80, in post
proxy = Proxy.get_or_create(scaleset.region)
File "/home/site/wwwroot/onefuzzlib/proxy.py", line 290, in get_or_create
if proxy_timestamp < (datetime.datetime.now() - datetime.timedelta(7)):

@ghost
Copy link

ghost commented May 20, 2021

Hello @bmc-msft!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 2f81c44 into microsoft:main May 20, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jun 19, 2021
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants