]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
aws_cloud_driver: Fix #10604 upload() might not exit with correct error code
authornorbert.bizet <norbert.bizet@baculasystems.com>
Mon, 11 Dec 2023 15:23:26 +0000 (10:23 -0500)
committerEric Bollengier <eric@baculasystems.com>
Tue, 13 Feb 2024 09:36:03 +0000 (10:36 +0100)
bacula/scripts/aws_cloud_driver.in
bacula/src/stored/generic_driver.c

index e598cb5293c64878173c4c125b80f0d686a5a840..3ef7113364c97d9b3b24295c509820a1ef34064b 100755 (executable)
@@ -155,6 +155,7 @@ def upload():
       # sort out only exception errors since progress is reported into stderr (yuck!)
       if err:
          sys.stderr.write(err)
+      ret = proc.returncode
       cmd = ["aws", "s3", "ls", os.path.join(cloud_path, volume, part)]
       if endpoint_url:
          cmd += ["--endpoint-url", endpoint_url]
@@ -179,7 +180,8 @@ def upload():
          # forward out stds
          logging.info("ls outputing {0}".format(output))
          sys.stdout.write(output)
-      return proc.returncode
+      ret = ret + proc.returncode
+      return ret
    except Exception as e:
       exc = traceback.format_exception_only(type(e), e)[0]
       sys.stderr.write(exc)
@@ -197,7 +199,6 @@ def move():
       proc = Popen( cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
       output,err = proc.communicate()
       logging.debug("move proc communicate output:{0} , err:{1}".format(output,err))
-      ret = proc.returncode
       if not err:
          sys.stdout.write("{0}\0".format(local_part))
          return 0
@@ -207,6 +208,7 @@ def move():
             return 0
          logging.error("move got error {0}".format(err))
          sys.stderr.write(err)
+      return proc.returncode
    except Exception as e:
       exc = traceback.format_exception_only(type(e), e)[0]
       sys.stderr.write(exc)
index abde8b341e8499353b0a783b4e589a71b5e67bc5..6cae0bc9542e5d16ba6370e31f926b29c0b46240 100644 (file)
@@ -286,6 +286,8 @@ bool generic_driver::init(CLOUD *cloud, POOLMEM *&err) {
 }
 
 /* helper to handler close_bpipe error code */
+/* be.code(stat) extracts the actual error code returned by the driver script */
+/* the pipe-specific errors are concated to the err string */
 int handle_error(int stat, POOLMEM *&err)
 {
    berrno be;