diff --git a/cg/meta/backup/pdc.py b/cg/meta/backup/pdc.py index 7f63745498..d45d5b05a3 100644 --- a/cg/meta/backup/pdc.py +++ b/cg/meta/backup/pdc.py @@ -23,6 +23,7 @@ SERVER = "hasta" NO_FILE_FOUND_ANSWER = "ANS1092W" +MAX_NR_OF_DSMC_PROCESSES: int = 3 class PdcAPI: @@ -39,14 +40,17 @@ def validate_is_dsmc_running(cls) -> bool: Exception: for all non-exit exceptions. """ is_dsmc_running: bool = False + dsmc_process_count: int = 0 try: for process in psutil.process_iter(): - if "dsmc" in process.name(): - is_dsmc_running = True + LOG.debug(process.name()) + if "dsmc" == process.name(): + dsmc_process_count += 1 except Exception as error: LOG.debug(f"{error}") - if is_dsmc_running: - LOG.debug("A Dsmc process is already running") + if dsmc_process_count >= MAX_NR_OF_DSMC_PROCESSES: + is_dsmc_running = True + LOG.debug("Too many Dsmc processes are already running") return is_dsmc_running def archive_file_to_pdc(self, file_path: str) -> None: @@ -93,7 +97,7 @@ def validate_is_flow_cell_backup_possible( FlowCellEncryptionError if encryption is not complete. """ if self.validate_is_dsmc_running(): - raise DsmcAlreadyRunningError("A Dsmc process is already running") + raise DsmcAlreadyRunningError("Too many Dsmc processes are already running") if db_flow_cell and db_flow_cell.has_backup: raise FlowCellAlreadyBackedUpError( f"Flow cell: {db_flow_cell.name} is already backed-up" diff --git a/tests/cli/backup/test_backup_command.py b/tests/cli/backup/test_backup_command.py index a1b8b17685..d7417eaa50 100644 --- a/tests/cli/backup/test_backup_command.py +++ b/tests/cli/backup/test_backup_command.py @@ -63,8 +63,8 @@ def test_backup_flow_cells_when_dsmc_is_running( # THEN exits without any errors assert result.exit_code == EXIT_SUCCESS - # THEN communicate Dsmc process is already running - assert "A Dsmc process is already running" in caplog.text + # THEN communicate too many Dsmc processes are already running + assert "Too many Dsmc processes are already running" in caplog.text def test_backup_flow_cells_when_flow_cell_already_has_backup(