mirror of
https://github.com/netinvent/npbackup.git
synced 2025-09-21 20:35:51 +08:00
Don't upload metrics when dry-run is set
This commit is contained in:
parent
98ba896c48
commit
f806d571d4
1 changed files with 6 additions and 3 deletions
|
@ -29,7 +29,7 @@ from npbackup import configuration
|
|||
logger = logging.getLogger(__intname__)
|
||||
|
||||
|
||||
def metric_writer(config_dict: dict, restic_result: bool, result_string: str):
|
||||
def metric_writer(config_dict: dict, restic_result: bool, result_string: str, dry_run: bool):
|
||||
try:
|
||||
labels = {}
|
||||
if config_dict["prometheus"]["metrics"]:
|
||||
|
@ -110,7 +110,10 @@ def metric_writer(config_dict: dict, restic_result: bool, result_string: str):
|
|||
except KeyError:
|
||||
logger.info("No metrics authentication present.")
|
||||
authentication = None
|
||||
upload_metrics(destination, authentication, no_cert_verify, metrics)
|
||||
if not dry_run:
|
||||
upload_metrics(destination, authentication, no_cert_verify, metrics)
|
||||
else:
|
||||
logger.info("Not uploading metrics in dry run mode")
|
||||
else:
|
||||
try:
|
||||
with open(destination, "w") as file_handle:
|
||||
|
@ -609,7 +612,7 @@ class NPBackupRunner:
|
|||
additional_parameters=additional_parameters,
|
||||
)
|
||||
logger.debug("Restic output:\n{}".format(result_string))
|
||||
metric_writer(self.config_dict, result, result_string)
|
||||
metric_writer(self.config_dict, result, result_string, self.restic_runner.dry_run)
|
||||
|
||||
if post_exec_command:
|
||||
exit_code, output = command_runner(
|
||||
|
|
Loading…
Add table
Reference in a new issue