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):
|
if isinstance(request, Error):
|
||||||
return not_ok(request, context="NodeCommandDelete")
|
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))
|
return ok(BoolResult(result=True))
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@ from .azure.creds import get_fuzz_storage
|
|||||||
from .azure.image import get_os
|
from .azure.image import get_os
|
||||||
from .azure.network import Network
|
from .azure.network import Network
|
||||||
from .azure.queue import create_queue, delete_queue, peek_queue, queue_object
|
from .azure.queue import create_queue, delete_queue, peek_queue, queue_object
|
||||||
from .azure.table import get_client
|
|
||||||
from .azure.vmss import (
|
from .azure.vmss import (
|
||||||
UnableToUpdate,
|
UnableToUpdate,
|
||||||
create_vmss,
|
create_vmss,
|
||||||
@ -231,21 +230,11 @@ class NodeMessage(ORMMixin):
|
|||||||
)
|
)
|
||||||
return entries
|
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
|
@classmethod
|
||||||
def clear_messages(cls, agent_id: UUID) -> None:
|
def clear_messages(cls, agent_id: UUID) -> None:
|
||||||
messages = cls.get_messages(agent_id)
|
messages = cls.get_messages(agent_id)
|
||||||
message_ids = [m.message_id for m in messages]
|
for message in messages:
|
||||||
cls.delete_messages(agent_id, message_ids)
|
message.delete()
|
||||||
|
|
||||||
|
|
||||||
class Pool(BASE_POOL, ORMMixin):
|
class Pool(BASE_POOL, ORMMixin):
|
||||||
|
@ -19,7 +19,7 @@ VERSION=$(../ci/get-version.sh)
|
|||||||
../ci/set-versions.sh
|
../ci/set-versions.sh
|
||||||
|
|
||||||
# clean up any previously built onefuzztypes packages
|
# clean up any previously built onefuzztypes packages
|
||||||
rm __app__/onefuzztypes*.whl
|
rm -f __app__/onefuzztypes*.whl
|
||||||
|
|
||||||
# build a local copy of onefuzztypes
|
# build a local copy of onefuzztypes
|
||||||
rm -rf local-pytypes
|
rm -rf local-pytypes
|
||||||
@ -38,8 +38,8 @@ TYPELIB=$(ls onefuzztypes*.whl)
|
|||||||
sed -i s,.*onefuzztypes.*,./${TYPELIB}, requirements.txt
|
sed -i s,.*onefuzztypes.*,./${TYPELIB}, requirements.txt
|
||||||
func azure functionapp publish ${TARGET} --python
|
func azure functionapp publish ${TARGET} --python
|
||||||
sed -i s,./onefuzztypes.*,onefuzztypes==0.0.0, requirements.txt
|
sed -i s,./onefuzztypes.*,onefuzztypes==0.0.0, requirements.txt
|
||||||
rm onefuzztypes*.whl
|
rm -f onefuzztypes*.whl
|
||||||
popd
|
popd
|
||||||
|
|
||||||
../ci/unset-versions.sh
|
../ci/unset-versions.sh
|
||||||
cat __app__/onefuzzlib/build.id
|
cat __app__/onefuzzlib/build.id
|
||||||
|
Reference in New Issue
Block a user