mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-16 20:08:09 +00:00
Remove use of batch
in NodeMessages (#60)
This commit is contained in:
@ -35,7 +35,9 @@ def delete(req: func.HttpRequest) -> func.HttpResponse:
|
||||
if isinstance(request, Error):
|
||||
return not_ok(request, context="NodeCommandDelete")
|
||||
|
||||
NodeMessage.delete_messages(request.machine_id, [request.message_id])
|
||||
message = NodeMessage.get(request.machine_id, request.message_id)
|
||||
if message:
|
||||
message.delete()
|
||||
return ok(BoolResult(result=True))
|
||||
|
||||
|
||||
|
@ -40,7 +40,6 @@ from .azure.creds import get_fuzz_storage
|
||||
from .azure.image import get_os
|
||||
from .azure.network import Network
|
||||
from .azure.queue import create_queue, delete_queue, peek_queue, queue_object
|
||||
from .azure.table import get_client
|
||||
from .azure.vmss import (
|
||||
UnableToUpdate,
|
||||
create_vmss,
|
||||
@ -231,21 +230,11 @@ class NodeMessage(ORMMixin):
|
||||
)
|
||||
return entries
|
||||
|
||||
@classmethod
|
||||
def delete_messages(cls, agent_id: UUID, message_ids: List[str]) -> None:
|
||||
client = get_client(table=cls.table_name())
|
||||
batch = client.batch(table_name=cls.table_name())
|
||||
|
||||
for message_id in message_ids:
|
||||
batch.delete_entity(agent_id, message_id)
|
||||
|
||||
client.commit_batch(cls.table_name(), batch)
|
||||
|
||||
@classmethod
|
||||
def clear_messages(cls, agent_id: UUID) -> None:
|
||||
messages = cls.get_messages(agent_id)
|
||||
message_ids = [m.message_id for m in messages]
|
||||
cls.delete_messages(agent_id, message_ids)
|
||||
for message in messages:
|
||||
message.delete()
|
||||
|
||||
|
||||
class Pool(BASE_POOL, ORMMixin):
|
||||
|
@ -19,7 +19,7 @@ VERSION=$(../ci/get-version.sh)
|
||||
../ci/set-versions.sh
|
||||
|
||||
# clean up any previously built onefuzztypes packages
|
||||
rm __app__/onefuzztypes*.whl
|
||||
rm -f __app__/onefuzztypes*.whl
|
||||
|
||||
# build a local copy of onefuzztypes
|
||||
rm -rf local-pytypes
|
||||
@ -38,7 +38,7 @@ TYPELIB=$(ls onefuzztypes*.whl)
|
||||
sed -i s,.*onefuzztypes.*,./${TYPELIB}, requirements.txt
|
||||
func azure functionapp publish ${TARGET} --python
|
||||
sed -i s,./onefuzztypes.*,onefuzztypes==0.0.0, requirements.txt
|
||||
rm onefuzztypes*.whl
|
||||
rm -f onefuzztypes*.whl
|
||||
popd
|
||||
|
||||
../ci/unset-versions.sh
|
||||
|
Reference in New Issue
Block a user