1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix: the API verifies a backup and shows what was found; Docker's health check reads /healthz

The backups API had every backup action but Verify, and did not show a
backup's verified_at and damage: a script restoring through it got no sign
of a damaged chain. Docker's health check asked for the login page, so a
hung job worker left the container healthy; it now reads /healthz.
This commit is contained in:
catborise 2026-11-19 20:45:09 +03:00
parent fc6ad4e8ca
commit 7b23c75bf5
5 changed files with 42 additions and 6 deletions

View file

@ -20,8 +20,8 @@ def _accepted(request, op):
class BackupViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.GenericViewSet):
"""VM backups: list, read, back a VM up and delete a backup (jobs,
answered 202)."""
"""VM backups: list, read, back a VM up, verify, restore and delete a
backup (jobs, answered 202)."""
permission_classes = [IsSuperUser]
serializer_class = BackupSerializer
@ -45,6 +45,15 @@ class BackupViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.G
key = serializer.validated_data["submission_key"]
return _accepted(request, jobs.submit("backup.delete", request.user, {"backup": str(backup.uuid)}, key))
@extend_schema(request=SubmissionSerializer, responses={202: OperationSerializer, 400: dict, 409: ErrorSerializer})
@action(detail=True, methods=["post"])
def verify(self, request, uuid=None):
backup = self.get_object()
serializer = SubmissionSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
key = serializer.validated_data["submission_key"]
return _accepted(request, jobs.submit("backup.verify", request.user, {"backup": str(backup.uuid)}, key))
@extend_schema(request=RestoreBackupSerializer, responses={202: OperationSerializer, 400: dict, 409: ErrorSerializer})
@action(detail=True, methods=["post"])
def restore(self, request, uuid=None):