summaryrefslogtreecommitdiff
path: root/scripts/lib/perl5/QtQA/Proc/Reliable/Strategy/Git.pm
blob: e1dde9a3416fc1ea3328aeb8255c696aced22c08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Copyright (C) 2017 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

package QtQA::Proc::Reliable::Strategy::Git;
use strict;
use warnings;

use base qw( QtQA::Proc::Reliable::Strategy::SSH );

use Readonly;

Readonly my @JUNK_STDERR_PATTERNS => (

    # This error message can be caused by a wide range of errors on both the
    # client and server side.  It is not _always_ a junk error, but usually
    # is if the test script is written correctly.
    #
    # An example client-side error: trying to push to a read-only URL
    # (e.g. using git:// instead of git@)
    #
    # An example server-side error: server-side process is killed by OOM killer,
    # or someone manually restarting it, or similar issues during the git operation.
    #
    qr{^fatal: The remote end hung up unexpectedly$}msi,

    # Unknown host, could be temporary DNS outage:
    #
    #   $ git clone git://foo.bar.baz/quux >/dev/null
    #   fatal: Unable to look up foo.bar.baz (port 9418) (Name or service not known)
    #
    qr{^fatal: Unable to look up .*\(Name or service not known\)$}msi,

    # `unable to connect a socket' could be various kinds of temporary outage:
    #
    #   $ git clone git://128.0.0.1/quux >/dev/null
    #   128.0.0.1[0: 128.0.0.1]: errno=No route to host
    #   fatal: unable to connect a socket (No route to host)
    #
    #   $ git clone git://example.com/quux >/dev/null
    #   example.com[0: 192.0.32.10]: errno=Connection timed out
    #   example.com[0: 2620:0:2d0:200::10]: errno=Network is unreachable
    #   fatal: unable to connect a socket (Network is unreachable)
    #
    qr{^fatal: unable to connect a socket }msi,

    # all of the above class of error are also possible for HTTP and SSH clones:
    #
    #   HTTP - not yet handled (because we do not use this in practice)
    #   SSH  - handled by subclassing the SSH strategy
    #
);

sub new
{
    my ($class) = @_;

    my $self = $class->SUPER::new( );
    $self->push_stderr_patterns( @JUNK_STDERR_PATTERNS );

    return bless $self, $class;
}

=head1 NAME

QtQA::Proc::Reliable::Strategy::Git - reliable strategy for git command

=head1 DESCRIPTION

Attempts to recover from various forms of network issues when performing
git commands which access a remote host.

=head1 SEE ALSO

L<QtQA::Proc::Reliable::Strategy>

=cut

1;