From 3d84850a1c5783335cbc26feb18777b1de1b19b3 Mon Sep 17 00:00:00 2001 From: Son Roy Almerol Date: Mon, 13 Jan 2025 12:19:16 -0500 Subject: [PATCH] ensure to restore ownership on error paths as well --- internal/backend/backup/jobrun.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/backend/backup/jobrun.go b/internal/backend/backup/jobrun.go index 417bc40..89846c1 100644 --- a/internal/backend/backup/jobrun.go +++ b/internal/backend/backup/jobrun.go @@ -108,6 +108,10 @@ func RunBackup(job *store.Job, storeInstance *store.Store) (*store.Task, error) if err := cmd.Start(); err != nil { monitorCancel() // Cancel monitoring since backup failed to start + if currOwner != "" { + _ = SetDatastoreOwner(job, storeInstance, currOwner) + } + stderr.Close() stdout.Close() @@ -121,6 +125,10 @@ func RunBackup(job *store.Job, storeInstance *store.Store) (*store.Task, error) stderr.Close() stdout.Close() + if currOwner != "" { + _ = SetDatastoreOwner(job, storeInstance, currOwner) + } + _ = cmd.Process.Kill() return nil, fmt.Errorf("RunBackup: no task created") } @@ -129,6 +137,9 @@ func RunBackup(job *store.Job, storeInstance *store.Store) (*store.Task, error) if err := updateJobStatus(job, task, storeInstance); err != nil { stderr.Close() stdout.Close() + if currOwner != "" { + _ = SetDatastoreOwner(job, storeInstance, currOwner) + } return task, fmt.Errorf("RunBackup: failed to update job status: %w", err) }