Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optional more specific return codes #7928

Closed
wants to merge 21 commits into from

Commits on Dec 2, 2023

  1. BORG_EXIT_CODES=modern can be set to get more specific process exit c…

    …odes
    
    If not set, it will default to "legacy" (always return 2 for errors).
    
    This commit only changes the Error exception class and its subclasses.
    
    The more specific exit codes need to be defined via .exit_mcode in the subclasses.
    ThomasWaldmann committed Dec 2, 2023
    Configuration menu
    Copy the full SHA
    adbb1d5 View commit details
    Browse the repository at this point in the history
  2. scripts/errorlist.py: improve error list docs generation

    - also output modern rc and traceback yes/no
    - recursive list of Error subclasses
    ThomasWaldmann committed Dec 2, 2023
    Configuration menu
    Copy the full SHA
    c147818 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    2a6d86d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6fb61d0 View commit details
    Browse the repository at this point in the history
  5. refactor set_ec usage

    - _export_tar: remove unneeded call to set_ec
      print_warning() already sets the exit code to EXIT_WARNING.
    
    - msgpack version check: raise Error instead of calling set_ec
    ThomasWaldmann committed Dec 2, 2023
    Configuration menu
    Copy the full SHA
    9b62016 View commit details
    Browse the repository at this point in the history
  6. fix dealing with remote repo Locking Exceptions

    previously, this was handled in RPCError handler and always resulted in rc 2.
    
    now re-raise Lock Exceptions locally, so it gives rc 2 (legacy) or 7x (modern).
    ThomasWaldmann committed Dec 2, 2023
    Configuration menu
    Copy the full SHA
    32d0fbe View commit details
    Browse the repository at this point in the history
  7. shorten TAMRequiredError error msg

    Users using recently created repos (after borg 1.0.9) or
    who followed the upgrade procedure of 1.0.9 or >1.2.4 will
    never see this error msg.
    
    So, have it as short as and similar to the ArchiveTAMRequiredError.
    ThomasWaldmann committed Dec 2, 2023
    Configuration menu
    Copy the full SHA
    c6bde98 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    b31b630 View commit details
    Browse the repository at this point in the history

Commits on Dec 15, 2023

  1. new warnings infrastructure to support modern exit codes

    - implement updating exit code based on severity, including modern codes
    - extend print_warning with kwargs wc (warning code) and wt (warning type)
    - update a global warnings_list with warning_info elements
    - create a class hierarchy below BorgWarning class similar to Error class
    - diff: change harmless warnings about speed to rc == 0
    - delete --force --force: change harmless warnings to rc == 0
    
    Also:
    
    - have BackupRaceConditionError as a more precise subclass of BackupError
    ThomasWaldmann committed Dec 15, 2023
    Configuration menu
    Copy the full SHA
    bd2136f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b179dd1 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f77b6a7 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    f88fac4 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    df168f4 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    af30559 View commit details
    Browse the repository at this point in the history
  7. add NotFoundWarning

    ThomasWaldmann committed Dec 15, 2023
    Configuration menu
    Copy the full SHA
    d13d98c View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    7316d10 View commit details
    Browse the repository at this point in the history
  9. BackupErrors get caught and give warning RCs

    also: use more union operators rather than .union()
    ThomasWaldmann committed Dec 15, 2023
    Configuration menu
    Copy the full SHA
    d3a11fb View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    5d7eb08 View commit details
    Browse the repository at this point in the history
  11. do not return the rc from Archiver methods

    this is not needed and getting rid of it makes
    the code / behaviour simpler to understand:
    
    if a fatal error is detected, we throw an exception.
    
    if we encounter something warning worthy, we emit and collect the warning.
    
    in a few cases, we directly call set_ec to set the
    exit code as needed, e.g. if passing it through
    from a subprocess.
    
    also:
    - get rid of Archiver.exit_code
    - assert that return value of archiver methods is None
    - fix a print_warning call to use the correct formatting method
    ThomasWaldmann committed Dec 15, 2023
    Configuration menu
    Copy the full SHA
    330b350 View commit details
    Browse the repository at this point in the history
  12. refactor (re-)init of exit_code and warnings_list globals

    stop directly accessing the variables from other modules.
    
    prefix with underscore to indicate that these shall
    only be used within this module and every other user
    shall call the respective functions.
    ThomasWaldmann committed Dec 15, 2023
    Configuration menu
    Copy the full SHA
    38cb364 View commit details
    Browse the repository at this point in the history
  13. use get_reset_ec to internally re-init ec/warnings

    if we do multiple calls to Archiver.do_something(),
    we need to reset the ec / warnings after each call,
    otherwise they will keep growing (in severity, in length).
    ThomasWaldmann committed Dec 15, 2023
    Configuration menu
    Copy the full SHA
    3a18393 View commit details
    Browse the repository at this point in the history