Skip to content

Timeout / max retries for sync command #56

Description

@nickvergessen

I'm currently writing smashbox based functional tests for our locking backend.
My first try was to sync and it is hanging infinite until 2.1 (to be released), due to the cmd retrying infinite times: owncloud/client#4037

Now I wrote a new method that sets a timeout:

    try:
        run_ocsync_timeout(d, seconds=10)
    except TimeoutError as err:
        # FIXME Issue raised https://github.com/owncloud/client/issues/4037
        logger.warning(err.message)

[...]


#  TODO move the block below into cernbox
class TimeoutError(Exception):
    pass


def handler(signum, frame):
    raise TimeoutError('Sync client did not terminate in time')


def run_ocsync_timeout(local_folder, remote_folder="", n=None, user_num=None, seconds=None):
    if seconds is not None:
        signal.signal(signal.SIGALRM, handler)
        signal.alarm(seconds)

    # This run_ocsync() may hang indefinitely
    run_ocsync(local_folder, remote_folder, n, user_num)

    if seconds is not None:
        signal.alarm(0)

Now my questions:

  1. Do you think it makes sense to add the timeout option to the default sync command?
  2. For new client versions --max-sync-retries support would be very nice to have. Can we add that to run_ocsync as well or should this be part of oc_sync_cmd? We can check if the client supports it by looking at --help:
    cmd = config.oc_sync_cmd
    if max_sync_retries is not None:
        help_cmd = cmd
        if help_cmd[0 - len(' --trust'):] == ' --trust':
            help_cmd = help_cmd[:0 - len(' --trust')]
        returncode, stdout, stderr = runcmd(help_cmd + ' --help', ignore_exitcode=True)

        try:
            if stdout.index('--max-sync-retries') is not None:
                cmd += ' --max-sync-retries %i' % max_sync_retries
        except ValueError:
            logger.warning('max-sync-retries ignored, because the client does not support it')

@moscicki

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions