Repository: ClickHouse/ClickHouse
File: ci/praktika/utils.py (Python)

Code before:
                        return 0

                    if retries == 1:
                        break

                    if verbose:
                        print(
                            f"Retry {retry+1}/{retries}: command failed, exit code: {proc.returncode}"
                        )

                    if not retry_errors:
                        continue # No retry errors specified, just retry on any failure

                    should_retry = False
                    for err in retry_errors:
                        if any(err in err_line for err_line in err_output):
                            print(
                                f"Retryable error occurred: [{err}], [{retry+1}/{retries}]"
                            )
                            should_retry = True
                            break
                    if not should_retry:
                        print(
                            f"No retryable errors found, stopping retry attempts"
                        )
                        break
            except Exception as e:
                if verbose:
                    if retries == 1:
                        print(
                            f"ERROR: exception {e}"
                        )
                    else:
                        print(
                            f"Retry {retry+1}/{retries}: exception {e}"
                        )
                        if retry == retries - 1:
                            print(f"ERROR: Final attempt failed, no more retries left.")
                if proc:
                    proc.kill()
                if retry == retries - 1:
                    if strict:
                        raise e
                    else:
                        return 1  # Return non-zero for failure

        if verbose:
            if retries == 1:
                print(
                    f"ERROR: command failed, exit code: {proc.returncode}"
                )

Review comment (suggestion):
These retry-status messages are printed even when `verbose=False` (`Retryable error occurred...` / `No retryable errors found...`). If the goal is to avoid noisy output on successful runs, consider emitting these only under `verbose` (or at least only when `retry_errors` is set and `verbose=True`).

Code after:

                if proc.returncode == 0:
                    return 0

                if verbose and retries > 1:
                    print(
                        f"Retry {retry+1}/{retries}: command failed, exit code: {proc.returncode}"
                    )

                if not retry_errors:
                    continue  # No retry errors specified, just retry on any failure

                if not any(
                    err in err_line for err_line in err_output for err in retry_errors
                ):
                    if verbose:
                        print(f"No retryable errors found, stopping retries")
                    break

                if verbose:
                    matched = next(
                        (
                            err
                            for err in retry_errors
                            if any(err in line for line in err_output)
                        ),
                        "",
                    )
                    print(
                        f"Retryable error [{matched}] found, retry {retry+1}/{retries}"
                    )
            except Exception as e:
                if verbose:
                    if retries == 1:
                        print(f"ERROR: exception {e}")
                    else:
                        print(f"Retry {retry+1}/{retries}: exception {e}")
                        if retry == retries - 1:
                            print(f"ERROR: Final attempt failed, no more retries left.")
                if proc:
                    proc.kill()
                if retry == retries - 1:
                    if strict:
                        raise
                    else:
                        return 1  # Return non-zero for failure

        if verbose:
            print(
                f"ERROR: command failed after {retry+1}/{retries} attempt(s), exit code: {proc.returncode}"
            )