fix superseded windows defender updates
This commit is contained in:
@@ -332,6 +332,7 @@ class WinUpdater(APIView):
|
|||||||
update.installed = True
|
update.installed = True
|
||||||
update.save(update_fields=["result", "downloaded", "installed"])
|
update.save(update_fields=["result", "downloaded", "installed"])
|
||||||
|
|
||||||
|
agent.delete_superseded_updates()
|
||||||
return Response("ok")
|
return Response("ok")
|
||||||
|
|
||||||
# agent calls this after it's finished installing all patches
|
# agent calls this after it's finished installing all patches
|
||||||
@@ -357,6 +358,7 @@ class WinUpdater(APIView):
|
|||||||
f"{agent.hostname} is rebooting after updates were installed."
|
f"{agent.hostname} is rebooting after updates were installed."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
agent.delete_superseded_updates()
|
||||||
return Response("ok")
|
return Response("ok")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -176,6 +176,7 @@ class NatsWinUpdates(APIView):
|
|||||||
asyncio.run(agent.nats_cmd({"func": "rebootnow"}, wait=False))
|
asyncio.run(agent.nats_cmd({"func": "rebootnow"}, wait=False))
|
||||||
logger.info(f"{agent.hostname} is rebooting after updates were installed.")
|
logger.info(f"{agent.hostname} is rebooting after updates were installed.")
|
||||||
|
|
||||||
|
agent.delete_superseded_updates()
|
||||||
return Response("ok")
|
return Response("ok")
|
||||||
|
|
||||||
def patch(self, request):
|
def patch(self, request):
|
||||||
@@ -199,6 +200,7 @@ class NatsWinUpdates(APIView):
|
|||||||
u.result = "failed"
|
u.result = "failed"
|
||||||
u.save(update_fields=["result"])
|
u.save(update_fields=["result"])
|
||||||
|
|
||||||
|
agent.delete_superseded_updates()
|
||||||
return Response("ok")
|
return Response("ok")
|
||||||
|
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
@@ -233,4 +235,5 @@ class NatsWinUpdates(APIView):
|
|||||||
revision_number=update["revision_number"],
|
revision_number=update["revision_number"],
|
||||||
).save()
|
).save()
|
||||||
|
|
||||||
|
agent.delete_superseded_updates()
|
||||||
return Response("ok")
|
return Response("ok")
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ def auto_approve_updates_task():
|
|||||||
|
|
||||||
agents = Agent.objects.only("pk", "version", "last_seen", "overdue_time")
|
agents = Agent.objects.only("pk", "version", "last_seen", "overdue_time")
|
||||||
for agent in agents:
|
for agent in agents:
|
||||||
|
agent.delete_superseded_updates()
|
||||||
try:
|
try:
|
||||||
agent.approve_updates()
|
agent.approve_updates()
|
||||||
except:
|
except:
|
||||||
@@ -53,6 +54,7 @@ def check_agent_update_schedule_task():
|
|||||||
]
|
]
|
||||||
|
|
||||||
for agent in online:
|
for agent in online:
|
||||||
|
agent.delete_superseded_updates()
|
||||||
install = False
|
install = False
|
||||||
patch_policy = agent.get_patch_policy()
|
patch_policy = agent.get_patch_policy()
|
||||||
|
|
||||||
@@ -126,6 +128,7 @@ def bulk_install_updates_task(pks: List[int]) -> None:
|
|||||||
chunks = (agents[i : i + 40] for i in range(0, len(agents), 40))
|
chunks = (agents[i : i + 40] for i in range(0, len(agents), 40))
|
||||||
for chunk in chunks:
|
for chunk in chunks:
|
||||||
for agent in chunk:
|
for agent in chunk:
|
||||||
|
agent.delete_superseded_updates()
|
||||||
nats_data = {
|
nats_data = {
|
||||||
"func": "installwinupdates",
|
"func": "installwinupdates",
|
||||||
"guids": agent.get_approved_update_guids(),
|
"guids": agent.get_approved_update_guids(),
|
||||||
@@ -142,6 +145,7 @@ def bulk_check_for_updates_task(pks: List[int]) -> None:
|
|||||||
chunks = (agents[i : i + 40] for i in range(0, len(agents), 40))
|
chunks = (agents[i : i + 40] for i in range(0, len(agents), 40))
|
||||||
for chunk in chunks:
|
for chunk in chunks:
|
||||||
for agent in chunk:
|
for agent in chunk:
|
||||||
|
agent.delete_superseded_updates()
|
||||||
asyncio.run(agent.nats_cmd({"func": "getwinupdates"}, wait=False))
|
asyncio.run(agent.nats_cmd({"func": "getwinupdates"}, wait=False))
|
||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
time.sleep(15)
|
time.sleep(15)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ def get_win_updates(request, pk):
|
|||||||
@api_view()
|
@api_view()
|
||||||
def run_update_scan(request, pk):
|
def run_update_scan(request, pk):
|
||||||
agent = get_object_or_404(Agent, pk=pk)
|
agent = get_object_or_404(Agent, pk=pk)
|
||||||
|
agent.delete_superseded_updates()
|
||||||
if pyver.parse(agent.version) < pyver.parse("1.3.0"):
|
if pyver.parse(agent.version) < pyver.parse("1.3.0"):
|
||||||
return notify_error("Requires agent version 1.3.0 or greater")
|
return notify_error("Requires agent version 1.3.0 or greater")
|
||||||
|
|
||||||
@@ -32,6 +33,7 @@ def run_update_scan(request, pk):
|
|||||||
@api_view()
|
@api_view()
|
||||||
def install_updates(request, pk):
|
def install_updates(request, pk):
|
||||||
agent = get_object_or_404(Agent, pk=pk)
|
agent = get_object_or_404(Agent, pk=pk)
|
||||||
|
agent.delete_superseded_updates()
|
||||||
if pyver.parse(agent.version) < pyver.parse("1.3.0"):
|
if pyver.parse(agent.version) < pyver.parse("1.3.0"):
|
||||||
return notify_error("Requires agent version 1.3.0 or greater")
|
return notify_error("Requires agent version 1.3.0 or greater")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user