split node and task heartbeats in two nodes (#163)

This commit is contained in:
Cheick Keita
2020-10-15 18:30:03 -07:00
committed by GitHub
parent 458b21f690
commit fa25823342
8 changed files with 50 additions and 10 deletions

View File

@ -95,7 +95,7 @@ def build_pool_config(pool_name: str) -> str:
onefuzz_url=get_instance_url(), onefuzz_url=get_instance_url(),
instrumentation_key=os.environ.get("APPINSIGHTS_INSTRUMENTATIONKEY"), instrumentation_key=os.environ.get("APPINSIGHTS_INSTRUMENTATIONKEY"),
heartbeat_queue=get_queue_sas( heartbeat_queue=get_queue_sas(
"heartbeat", "node-heartbeat",
account_id=os.environ["ONEFUZZ_FUNC_STORAGE"], account_id=os.environ["ONEFUZZ_FUNC_STORAGE"],
add=True, add=True,
), ),

View File

@ -180,7 +180,7 @@ def build_task_config(
instrumentation_key=os.environ.get("APPINSIGHTS_INSTRUMENTATIONKEY"), instrumentation_key=os.environ.get("APPINSIGHTS_INSTRUMENTATIONKEY"),
telemetry_key=os.environ.get("ONEFUZZ_TELEMETRY"), telemetry_key=os.environ.get("ONEFUZZ_TELEMETRY"),
heartbeat_queue=get_queue_sas( heartbeat_queue=get_queue_sas(
"heartbeat", "task-heartbeat",
account_id=os.environ["ONEFUZZ_FUNC_STORAGE"], account_id=os.environ["ONEFUZZ_FUNC_STORAGE"],
add=True, add=True,
), ),

View File

@ -25,7 +25,7 @@ def set_config(pool: Pool) -> Pool:
instrumentation_key=os.environ.get("APPINSIGHTS_INSTRUMENTATIONKEY"), instrumentation_key=os.environ.get("APPINSIGHTS_INSTRUMENTATIONKEY"),
telemetry_key=os.environ.get("ONEFUZZ_TELEMETRY"), telemetry_key=os.environ.get("ONEFUZZ_TELEMETRY"),
heartbeat_queue=get_queue_sas( heartbeat_queue=get_queue_sas(
"heartbeat", "node-heartbeat",
account_id=os.environ["ONEFUZZ_FUNC_STORAGE"], account_id=os.environ["ONEFUZZ_FUNC_STORAGE"],
add=True, add=True,
), ),

View File

@ -9,7 +9,7 @@ import logging
import azure.functions as func import azure.functions as func
from ..onefuzzlib.dashboard import get_event from ..onefuzzlib.dashboard import get_event
from ..onefuzzlib.heartbeat import NodeHeartbeat, TaskHeartbeat from ..onefuzzlib.heartbeat import NodeHeartbeat
def main(msg: func.QueueMessage, dashboard: func.Out[str]) -> None: def main(msg: func.QueueMessage, dashboard: func.Out[str]) -> None:
@ -18,10 +18,7 @@ def main(msg: func.QueueMessage, dashboard: func.Out[str]) -> None:
raw = json.loads(body) raw = json.loads(body)
if TaskHeartbeat.try_add(raw): NodeHeartbeat.try_add(raw)
pass
elif NodeHeartbeat.try_add(raw):
pass
event = get_event() event = get_event()
if event: if event:

View File

@ -5,7 +5,7 @@
"name": "msg", "name": "msg",
"type": "queueTrigger", "type": "queueTrigger",
"direction": "in", "direction": "in",
"queueName": "heartbeat", "queueName": "node-heartbeat",
"connection": "AzureWebJobsStorage" "connection": "AzureWebJobsStorage"
}, },
{ {

View File

@ -0,0 +1,25 @@
#!/usr/bin/env python
#
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import json
import logging
import azure.functions as func
from ..onefuzzlib.dashboard import get_event
from ..onefuzzlib.heartbeat import TaskHeartbeat
def main(msg: func.QueueMessage, dashboard: func.Out[str]) -> None:
body = msg.get_body()
logging.info("heartbeat: %s", body)
raw = json.loads(body)
TaskHeartbeat.try_add(raw)
event = get_event()
if event:
dashboard.set(event)

View File

@ -0,0 +1,18 @@
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "msg",
"type": "queueTrigger",
"direction": "in",
"queueName": "task-heartbeat",
"connection": "AzureWebJobsStorage"
},
{
"type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
}
]
}

View File

@ -367,7 +367,7 @@ class Client:
account_url=account_url, account_url=account_url,
credential={"account_name": name, "account_key": key}, credential={"account_name": name, "account_key": key},
) )
for queue in ["file-changes", "heartbeat", "proxy", "update-queue"]: for queue in ["file-changes", "task-heartbeat", "node-heartbeat", "proxy", "update-queue"]:
try: try:
client.create_queue(queue) client.create_queue(queue)
except ResourceExistsError: except ResourceExistsError: