mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-01 08:26:03 +00:00
fix: worker warnings and CPU windows do not depend on a wall clock
The job panel warned "Worker unavailable" when the worker's last heartbeat was more than 60 s older than the browser's clock: a browser set two minutes ahead warned about a worker that had just beaten, and one behind hid a worker that had stopped. The server now says whether the worker is gone (worker_gone in the job panel's answer), by the same rule as the Jobs page. A host's CPU graph measured its averaging window with time.time(): a clock set back between two polls gave a negative window. It now uses time.monotonic(), as a VM's usage already does; a sample from before the server restarted is measured over a second again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
25e49c2aa2
commit
e83bdcbd44
9 changed files with 55 additions and 21 deletions
|
|
@ -70,3 +70,4 @@ class ResourceJobsSerializer(serializers.Serializer):
|
|||
others = OperationSummarySerializer(many=True)
|
||||
short_operation = serializers.BooleanField()
|
||||
worker_last_seen = serializers.DateTimeField(allow_null=True)
|
||||
worker_gone = serializers.BooleanField()
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from rest_framework.pagination import PageNumberPagination
|
|||
from rest_framework.response import Response
|
||||
|
||||
from operations import jobs
|
||||
from operations.models import Claim, Operation, last_seen
|
||||
from operations.models import Claim, Operation, last_seen, worker_gone
|
||||
from operations.utils import may_see, summary, visible
|
||||
|
||||
from .serializers import OperationSerializer, ResourceJobsSerializer
|
||||
|
|
@ -52,7 +52,9 @@ class OperationViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewset
|
|||
active = list(Operation.objects.filter(claims__resource=key, state__in=SHOWN_STATES).distinct())
|
||||
mine = [op for op in active if may_see(op, request.user)]
|
||||
others = [summary(op, request.user) for op in active if not may_see(op, request.user)]
|
||||
seen = last_seen()
|
||||
short = Claim.objects.filter(resource=key, operation__isnull=True, expires_at__gt=timezone.now()).exists()
|
||||
return Response(ResourceJobsSerializer(
|
||||
{"jobs": mine, "others": others, "short_operation": short, "worker_last_seen": last_seen()},
|
||||
{"jobs": mine, "others": others, "short_operation": short, "worker_last_seen": seen,
|
||||
"worker_gone": worker_gone(seen)},
|
||||
context={"request": request}).data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue