Skip to content

Commit

Permalink
Remove use of batch in NodeMessages (microsoft#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmc-msft authored and anshuman-goel committed Oct 1, 2020
1 parent e188e97 commit bf01dbd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
4 changes: 3 additions & 1 deletion src/api-service/__app__/agent_commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down
15 changes: 2 additions & 13 deletions src/api-service/__app__/onefuzzlib/pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
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,
Expand Down Expand Up @@ -231,21 +230,11 @@ def get_messages(
)
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):
Expand Down
6 changes: 3 additions & 3 deletions src/api-service/dev-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,8 +38,8 @@ 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
cat __app__/onefuzzlib/build.id
cat __app__/onefuzzlib/build.id

0 comments on commit bf01dbd

Please sign in to comment.