mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-18 20:58:06 +00:00
Refactoring proxy lifetime to only shutdown when proxy is out-of-date. (#839)
## 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](https://cla.opensource.microsoft.com/microsoft/onefuzz) and sign the CLI. * [ ] Tests added/passed * [ ] Requires documentation to be updated * [x] 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.
This commit is contained in:
6
src/pytypes/extra/generate-docs.py
Normal file → Executable file
6
src/pytypes/extra/generate-docs.py
Normal file → Executable file
@ -156,10 +156,11 @@ def main() -> None:
|
||||
state=TaskState.init,
|
||||
config=task_config,
|
||||
),
|
||||
EventProxyCreated(region=Region("eastus")),
|
||||
EventProxyDeleted(region=Region("eastus")),
|
||||
EventProxyCreated(region=Region("eastus"), proxy_id=UUID(int=0)),
|
||||
EventProxyDeleted(region=Region("eastus"), proxy_id=UUID(int=0)),
|
||||
EventProxyFailed(
|
||||
region=Region("eastus"),
|
||||
proxy_id=UUID(int=0),
|
||||
error=Error(code=ErrorCode.PROXY_FAILED, errors=["example error message"]),
|
||||
),
|
||||
EventPoolCreated(
|
||||
@ -272,7 +273,6 @@ def main() -> None:
|
||||
)
|
||||
|
||||
result = ""
|
||||
|
||||
result += layer(
|
||||
1,
|
||||
"Webhook Events",
|
||||
|
@ -121,14 +121,17 @@ class EventPoolCreated(BaseEvent):
|
||||
|
||||
class EventProxyCreated(BaseEvent):
|
||||
region: Region
|
||||
proxy_id: Optional[UUID]
|
||||
|
||||
|
||||
class EventProxyDeleted(BaseEvent):
|
||||
region: Region
|
||||
proxy_id: Optional[UUID]
|
||||
|
||||
|
||||
class EventProxyFailed(BaseEvent):
|
||||
region: Region
|
||||
proxy_id: Optional[UUID]
|
||||
error: Error
|
||||
|
||||
|
||||
|
@ -432,6 +432,7 @@ class ProxyConfig(BaseModel):
|
||||
url: str
|
||||
notification: str
|
||||
region: Region
|
||||
proxy_id: UUID
|
||||
forwards: List[Forward]
|
||||
instance_telemetry_key: Optional[str]
|
||||
microsoft_telemetry_key: Optional[str]
|
||||
@ -440,6 +441,7 @@ class ProxyConfig(BaseModel):
|
||||
|
||||
class ProxyHeartbeat(BaseModel):
|
||||
region: Region
|
||||
proxy_id: UUID
|
||||
forwards: List[Forward]
|
||||
timestamp: datetime = Field(default_factory=datetime.utcnow)
|
||||
|
||||
|
Reference in New Issue
Block a user