| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # maint/live-preflight — look at the project namespace before a live DBIO test | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # run, and say whether a suite started now would run against what it expects. | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # The live databases of the family stand in one namespace of the HQ cluster | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # (dev-dbio) and are reached from the test machine through one LoadBalancer | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # address. This script looks at that namespace with the project account, which | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # sees nothing else: no nodes, no other namespace. It checks four things, each | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # of which has cost a run or a host before: | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # 1. every container in the namespace carries a cpu and a memory limit. An | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # uncapped database container once OOM-rebooted the host it ran on. In | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # dev-dbio the LimitRange fills in a missing limit, so the check is for | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # every other namespace and for the day that LimitRange is gone; | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # 2. every database (label role=dbio-test-db) is Ready. A suite against one | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # that is not fails with connection errors that read like a driver bug. | ||||||||||||||||||||||||||||||||||||||||||
| 17 | # The ones that are Ready are listed -- several at once is the normal | ||||||||||||||||||||||||||||||||||||||||||
| 18 | # state, and a database nobody expected should be seen; | ||||||||||||||||||||||||||||||||||||||||||
| 19 | # 3. no object of a DBIO::Test::Kubernetes run is left over. Such a run puts | ||||||||||||||||||||||||||||||||||||||||||
| 20 | # its pods into this namespace and removes them at its end; one that was | ||||||||||||||||||||||||||||||||||||||||||
| 21 | # interrupted leaves them, holding quota until somebody deletes them; | ||||||||||||||||||||||||||||||||||||||||||
| 22 | # 4. the route from this machine to the LoadBalancer address does not go into | ||||||||||||||||||||||||||||||||||||||||||
| 23 | # a docker bridge. A local docker network whose range covers the address | ||||||||||||||||||||||||||||||||||||||||||
| 24 | # takes the route, and every database then looks dead from here while it | ||||||||||||||||||||||||||||||||||||||||||
| 25 | # is fine. Nothing on the database side points at it (dbio-mssql karr k20 | ||||||||||||||||||||||||||||||||||||||||||
| 26 | # was this failure, there on the pod range of a cluster on the same host). | ||||||||||||||||||||||||||||||||||||||||||
| 27 | # | ||||||||||||||||||||||||||||||||||||||||||
| 28 | # The quota of the namespace is printed as used/hard. A used-up quota is a | ||||||||||||||||||||||||||||||||||||||||||
| 29 | # warning, not a failure: it does not touch a suite against a standing | ||||||||||||||||||||||||||||||||||||||||||
| 30 | # database, and a run that starts pods is told by the API at its first create. | ||||||||||||||||||||||||||||||||||||||||||
| 31 | # | ||||||||||||||||||||||||||||||||||||||||||
| 32 | # What it does not check: that nobody else is running a suite against the same | ||||||||||||||||||||||||||||||||||||||||||
| 33 | # database ("one run per database at a time"). It cannot see that. | ||||||||||||||||||||||||||||||||||||||||||
| 34 | # | ||||||||||||||||||||||||||||||||||||||||||
| 35 | # Run it before any live suite: | ||||||||||||||||||||||||||||||||||||||||||
| 36 | # | ||||||||||||||||||||||||||||||||||||||||||
| 37 | # maint/live-preflight && maint/capped-test prove -lr t/ | ||||||||||||||||||||||||||||||||||||||||||
| 38 | # | ||||||||||||||||||||||||||||||||||||||||||
| 39 | # Access: DBIO_TEST_KUBECONFIG, else KUBECONFIG, else ~/.kube/cihq-dev-dbio.yaml | ||||||||||||||||||||||||||||||||||||||||||
| 40 | # if it is there, else whatever kubectl uses by itself. The namespace is the | ||||||||||||||||||||||||||||||||||||||||||
| 41 | # one of that kubeconfig's context. | ||||||||||||||||||||||||||||||||||||||||||
| 42 | # | ||||||||||||||||||||||||||||||||||||||||||
| 43 | # Exit status: 0 all clear, 1 something is wrong (details on stderr), 2 the | ||||||||||||||||||||||||||||||||||||||||||
| 44 | # checks could not be run at all (no kubectl, cluster not reachable, token | ||||||||||||||||||||||||||||||||||||||||||
| 45 | # expired). A 2 is NOT a pass. | ||||||||||||||||||||||||||||||||||||||||||
| 46 | # | ||||||||||||||||||||||||||||||||||||||||||
| 47 | # It reads. It never changes anything — no pod is started, stopped or deleted, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | # no network is removed. Every finding is reported with the command that deals | ||||||||||||||||||||||||||||||||||||||||||
| 49 | # with it, for a human to run. | ||||||||||||||||||||||||||||||||||||||||||
| 50 | # | ||||||||||||||||||||||||||||||||||||||||||
| 51 | # See the "Live testing" section of .claude/rules/dbio-rules.md, which names | ||||||||||||||||||||||||||||||||||||||||||
| 52 | # this script as the step before a live run. | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 44 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 44 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 44 | ▶ | use FindBin (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 44 | ▶ | use File::Temp (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 44 | ▶ | use JSON::PP (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 44 | ▶ | use POSIX (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | # The access of the DBIO project to its namespace, and how its token (valid | ||||||||||||||||||||||||||||||||||||||||||
| 63 | # for seven days) is renewed. | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 44 | my $PROJECT_ACCESS = '.kube/cihq-dev-dbio.yaml'; | |||||||||||||||||||||||||||||||||||||||||
| 65 | # The cihq-ocp checkout: CIHQ_OCP, else the one next to the DBIO family | ||||||||||||||||||||||||||||||||||||||||||
| 66 | # directory (maint/ -> repo -> family directory -> its parent). | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 44 | ▶ | my $CIHQ_OCP = $ENV{CIHQ_OCP} // "$FindBin::Bin/../../../cihq-ocp"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{"CIHQ_OCP"} // "$FindBin::Bin/../../../cihq-ocp"
MC/DC0%0/1
$ENV{"CIHQ_OCP"} // "$FindBin::Bin/../../../cihq-ocp"
$ENV{"CIHQ_OCP"}
Truth table50%1/2
A
A= $ENV{"CIHQ_OCP"}
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 44 | my $RENEW_TOKEN = "$CIHQ_OCP/bin/cihq-dev token dbio"; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 44 | my $DBIO_DB = "$CIHQ_OCP/umgebungen/dbio/dbio-db"; | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 44 | my $failures = 0; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 44 | my $warnings = 0; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 44 | my $checks = 0; | |||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 9 | ▶ | sub fail { $failures++; print STDERR "FAIL $_[0]\n" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fail: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 4 | ▶ | sub warn_ { $warnings++; print STDERR "WARN $_[0]\n" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
warn_: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 77 | ▶ | sub ok { print STDERR "ok $_[0]\n" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ok: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 93 | ▶ | sub note { print STDERR " $_[0]\n" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
note: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 3 | ▶ | sub cannot_check { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cannot_check: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 3 | my ($why, @notes) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | print STDERR "? $why -- cannot check anything\n"; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | note $_ for @notes; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 3 | note 'this is NOT a pass; fix the access or skip the live run'; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 3 | exit 2; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | # run(@command): what it wrote to stdout and to stderr, and its exit status -- | ||||||||||||||||||||||||||||||||||||||||||
| 89 | # 127 when it could not be started at all. | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 68 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=7 SCAR=19.8
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 68 | my (@command) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 68 | my $stderr = File::Temp->new; | |||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 68 | my $pid = open my $stdout, '-|'; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 68 | ▶ | die "live-preflight: cannot fork: $!\n" unless defined $pid; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 68 | ▶ | if (!$pid) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 28 | ▶ | open STDERR, '>&', $stderr or POSIX::_exit(127); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 44 | ▶ | { no warnings 'exec'; exec { $command[0] } @command } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | POSIX::_exit(127); | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 40 | my $out = do { local $/; <$stdout> }; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 40 | close $stdout; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 40 | my $status = $?; | |||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 40 | seek $stderr, 0, 0; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 40 | my $err = do { local $/; <$stderr> }; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 40 | ▶ | return ($out // '', $err // '', ($status & 127) ? 128 + ($status & 127) : $status >> 8); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%2/4
$out // ""
$err // ""
MC/DC0%0/1
$out // ""
$out
MC/DC0%0/1
$err // ""
$err
Truth table50%1/2
A
A= $out
Truth table50%1/2
A
A= $err
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | # A Kubernetes quantity as a number: 2600m, 8, 6784Mi, 32Gi. | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 96 | ▶ | sub quantity { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quantity: called CC=5 SCAR=16.7
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 96 | my ($text) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 96 | my %factor = ( | |||||||||||||||||||||||||||||||||||||||||
| 114 | m => 1e-3, k => 1e3, M => 1e6, G => 1e9, T => 1e12, | ||||||||||||||||||||||||||||||||||||||||||
| 115 | Ki => 2**10, Mi => 2**20, Gi => 2**30, Ti => 2**40, | ||||||||||||||||||||||||||||||||||||||||||
| 116 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 96 | ▶ | my ($number, $unit) = ($text // '') =~ /^([0-9.]+)([A-Za-z]*)$/ or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$text // ""
MC/DC0%0/1
$text // ""
$text
Truth table50%1/2
A
A= $text
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 96 | ▶ | return $number unless length $unit; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 60 | ▶ | return exists $factor{$unit} ? $number * $factor{$unit} : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | # -------------------------------------------------------------- the access | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 44 | ▶ | my ($kubeconfig) = grep { defined and length } @ENV{qw(DBIO_TEST_KUBECONFIG KUBECONFIG)}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $_ && length $_
MC/DC50%1/2
defined $_ && length $_
defined $_
length $_
Truth table66%2/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 44 | ▶ | if (!defined $kubeconfig and defined $ENV{HOME} and -f "$ENV{HOME}/$PROJECT_ACCESS") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not defined $kubeconfig and defined $ENV{"HOME"} and -f qq[$ENV{"HOME"}/$PROJECT_ACCESS]
not defined $kubeconfig and defined $ENV{"HOME"}
MC/DC66%2/3
not defined $kubeconfig and defined $ENV{"HOME"} and -f qq[$ENV{"HOME"}/$PROJECT_ACCESS]
not defined $kubeconfig
defined $ENV{"HOME"}
-f qq[$ENV{"HOME"}/$PROJECT_ACCESS]
Truth table75%3/4
not(A) and B and C
A= not defined $kubeconfigB= defined $ENV{"HOME"}C= -f qq[$ENV{"HOME"}/$PROJECT_ACCESS]
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 3 | $kubeconfig = "$ENV{HOME}/$PROJECT_ACCESS"; | |||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 44 | ▶ | $ENV{KUBECONFIG} = $kubeconfig if defined $kubeconfig; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | # One request for everything, in the namespace of the context: no -n, no -A. | ||||||||||||||||||||||||||||||||||||||||||
| 131 | # The project account may list nothing outside its namespace, and what is | ||||||||||||||||||||||||||||||||||||||||||
| 132 | # outside is not ours to judge. | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 44 | my ($listing, $error, $status) = run( | |||||||||||||||||||||||||||||||||||||||||
| 134 | 'kubectl', '--request-timeout=15s', 'get', 'pods,services,jobs,resourcequotas', '-o', 'json', | ||||||||||||||||||||||||||||||||||||||||||
| 135 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 28 | ▶ | cannot_check('kubectl is not in PATH') if $status == 127; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 27 | ▶ | if ($status != 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 2 | chomp $error; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | ▶ | cannot_check( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$kubeconfig // "kubectl's default"
MC/DC0%0/1
$kubeconfig // "kubectl's default"
$kubeconfig
Truth table50%1/2
A
A= $kubeconfig
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | "kubectl could not list the namespace (exit $status)", | ||||||||||||||||||||||||||||||||||||||||||
| 143 | ( split /\n/, $error ), | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 'access used: ' . ( $kubeconfig // "kubectl's default" ), | ||||||||||||||||||||||||||||||||||||||||||
| 145 | ( $error =~ /Unauthorized|provide credentials/i | ||||||||||||||||||||||||||||||||||||||||||
| 146 | ? "the token is not accepted (it lasts seven days) -- renew it: $RENEW_TOKEN" | ||||||||||||||||||||||||||||||||||||||||||
| 147 | : () ), | ||||||||||||||||||||||||||||||||||||||||||
| 148 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 25 | my $items = eval { JSON::PP->new->utf8->decode($listing)->{items} }; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 25 | ▶ | cannot_check('kubectl answered with something that is not a list of objects') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | unless ref $items eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 25 | my %of_kind; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 25 | push @{ $of_kind{ $_->{kind} } }, $_ for @$items; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 25 | ▶ | my @pods = @{ $of_kind{Pod} // [] }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$of_kind{"Pod"} // []
MC/DC100%1/1
$of_kind{"Pod"} // []
$of_kind{"Pod"}
Truth table100%2/2
A
A= $of_kind{"Pod"}
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 25 | ▶ | my ($namespace) = map { $_->{metadata}{namespace} // () } @$items; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$_->{"metadata"}{"namespace"} // ()
MC/DC0%0/2
$_->{"metadata"}{"namespace"} // ()
$_->{"metadata"}{"namespace"}
()
Truth table33%1/3
A // B
A= $_->{"metadata"}{"namespace"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 25 | ▶ | my $kubectl = 'kubectl' . ( defined $namespace ? " -n $namespace" : '' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 25 | ▶ | note 'access: ' . ( $kubeconfig // "kubectl's default" ) | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$kubeconfig // "kubectl's default"
$namespace // "(empty -- the one of its context)"
MC/DC100%1/1
$kubeconfig // "kubectl's default"
$kubeconfig
MC/DC100%1/1
$namespace // "(empty -- the one of its context)"
$namespace
Truth table100%2/2
A
A= $kubeconfig
Truth table100%2/2
A
A= $namespace
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | . ', namespace ' . ( $namespace // '(empty -- the one of its context)' ); | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 624 | ▶ | sub name { $_[0]{metadata}{name} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | # ------------------------------------------------ 1. every container capped | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 25 | $checks++; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 25 | my @uncapped; | |||||||||||||||||||||||||||||||||||||||||
| 171 | 25 | for my $pod (@pods) { | |||||||||||||||||||||||||||||||||||||||||
| 172 | 202 | ▶ | for my $container (@{ $pod->{spec}{containers} // [] }) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$pod->{"spec"}{"containers"} // []
MC/DC0%0/1
$pod->{"spec"}{"containers"} // []
$pod->{"spec"}{"containers"}
Truth table50%1/2
A
A= $pod->{"spec"}{"containers"}
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 204 | ▶ | my $limits = $container->{resources}{limits} // {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$container->{"resources"}{"limits"} // {}
MC/DC0%0/1
$container->{"resources"}{"limits"} // {}
$container->{"resources"}{"limits"}
Truth table50%1/2
A
A= $container->{"resources"}{"limits"}
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 204 | ▶ | my @missing = grep { !length( $limits->{$_} // '' ) } qw(cpu memory); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$limits->{$_} // ""
MC/DC100%1/1
$limits->{$_} // ""
$limits->{$_}
Truth table100%2/2
A
A= $limits->{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 204 | ▶ | push @uncapped, [ name($pod), "$container->{name}: no " . join(' and no ', @missing) . ' limit' ] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | if @missing; | ||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 25 | ▶ | if (@uncapped) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | my %seen; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | my @names = grep { !$seen{$_}++ } map { $_->[0] } @uncapped; | |||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | fail scalar(@names) . ' pod(s) with a container that carries no cpu+memory limit'; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | note "$_->[0] ($_->[1])" for @uncapped; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 2 | note 'an uncapped database is what OOM-rebooted a host before. Fix the'; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 2 | note 'manifest it came from, then remove the pod:'; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 2 | note " $kubectl delete pod $_" for @names; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 23 | ok scalar(@pods) . ' pod(s), every container carries a cpu and a memory limit'; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | # --------------------------------------------------- 2. the databases Ready | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 25 | $checks++; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 25 | ▶ | my @databases = grep { ( $_->{metadata}{labels}{role} // '' ) eq 'dbio-test-db' } @pods; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_->{"metadata"}{"labels"}{"role"} // ""
MC/DC100%1/1
$_->{"metadata"}{"labels"}{"role"} // ""
$_->{"metadata"}{"labels"}{"role"}
Truth table100%2/2
A
A= $_->{"metadata"}{"labels"}{"role"}
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 396 | ▶ | sub is_ready { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_ready: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 396 | my ($pod) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 396 | ▶ | return 0 if $pod->{metadata}{deletionTimestamp}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 784 | ▶ | return scalar grep { $_->{type} eq 'Ready' and $_->{status} eq 'True' } | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$_->{'type'} eq 'Ready' && $_->{'status'} eq 'True'
MC/DC100%2/2
$_->{'type'} eq 'Ready' && $_->{'status'} eq 'True'
$_->{'type'} eq 'Ready'
$_->{'status'} eq 'True'
Truth table100%3/3
A && B
A= $_->{'type'} eq 'Ready'B= $_->{'status'} eq 'True'
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 392 | ▶ | @{ $pod->{status}{conditions} // [] }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$pod->{"status"}{"conditions"} // []
MC/DC0%0/1
$pod->{"status"}{"conditions"} // []
$pod->{"status"}{"conditions"}
Truth table50%1/2
A
A= $pod->{"status"}{"conditions"}
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 25 | my @ready = map { name($_) } grep { is_ready($_) } @databases; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 25 | my @unready = grep { !is_ready($_) } @databases; | |||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 25 | ▶ | if (@unready) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | fail scalar(@unready) . ' database(s) not Ready -- a suite against one fails for no reason of its own'; | |||||||||||||||||||||||||||||||||||||||||
| 210 | note name($_) . ' (' . ( $_->{metadata}{deletionTimestamp} ? 'Terminating' : $_->{status}{phase} // '?' ) . ')' | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | ▶ | for @unready; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$_->{"status"}{"phase"} // "?"
MC/DC0%0/1
$_->{"status"}{"phase"} // "?"
$_->{"status"}{"phase"}
Truth table50%1/2
A
A= $_->{"status"}{"phase"}
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | note "see why, then bring it back up ($DBIO_DB up <db>):"; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | note " $kubectl describe pod " . name($_) for @unready; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 25 | ▶ | if (@ready) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 24 | my $line = scalar(@ready) . ' database(s) Ready: ' . join(', ', sort @ready); | |||||||||||||||||||||||||||||||||||||||||
| 218 | 24 | ▶ | @unready ? note $line : ok $line; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | elsif (!@unready) { | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 1 | warn_ 'no database (label role=dbio-test-db) in this namespace -- nothing here'; | |||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | note "for a suite to run against. Start one: $DBIO_DB up <db>"; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 1 | note 'if they are up in another namespace, this access looks at the wrong one'; | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | # ------------------------------- 3. leftovers of a DBIO::Test::Kubernetes run | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 25 | $checks++; | |||||||||||||||||||||||||||||||||||||||||
| 229 | # In an existing namespace every object of such a run is named | ||||||||||||||||||||||||||||||||||||||||||
| 230 | # dbio-test-<run>-..., and carries the label dbio-test-run (pods, services and | ||||||||||||||||||||||||||||||||||||||||||
| 231 | # jobs alike, since k329). The name pattern stays for the leftovers of runs | ||||||||||||||||||||||||||||||||||||||||||
| 232 | # made before the services and jobs were labelled. | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 398 | ▶ | sub of_test_run { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
of_test_run: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 398 | my ($object) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 235 | 398 | ▶ | return 1 if exists( ( $object->{metadata}{labels} // {} )->{'dbio-test-run'} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$object->{"metadata"}{"labels"} // {}
MC/DC100%1/1
$object->{"metadata"}{"labels"} // {}
$object->{"metadata"}{"labels"}
Truth table100%2/2
A
A= $object->{"metadata"}{"labels"}
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 396 | return name($object) =~ /^dbio-test-[a-z0-9]{8}-/; | |||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | # An object that has an owner goes with it (the pod of a job), so it is not | ||||||||||||||||||||||||||||||||||||||||||
| 240 | # named in the delete. | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 6 | my @leftovers = map { lc( $_->{kind} ) . '/' . name($_) } | |||||||||||||||||||||||||||||||||||||||||
| 242 | 398 | ▶ | grep { of_test_run($_) and !@{ $_->{metadata}{ownerReferences} // [] } } | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
of_test_run($_) && !@{$_->{'metadata'}{'ownerReferences'} // [];}
$_->{"metadata"}{"ownerReferences"} // []
MC/DC100%2/2
of_test_run($_) && !@{$_->{'metadata'}{'ownerReferences'} // [];}
of_test_run($_)
!@{$_->{'metadata'}{'ownerReferences'} // [];}
MC/DC100%1/1
$_->{"metadata"}{"ownerReferences"} // []
$_->{"metadata"}{"ownerReferences"}
Truth table100%3/3
A && not(B)
A= of_test_run($_)B= !@{$_->{'metadata'}{'ownerReferences'} // [];}
Truth table100%2/2
A
A= $_->{"metadata"}{"ownerReferences"}
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 25 | ▶ | map { @{ $of_kind{$_} // [] } } qw(Pod Service Job); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$of_kind{$_} // []
MC/DC100%1/1
$of_kind{$_} // []
$of_kind{$_}
Truth table100%2/2
A
A= $of_kind{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 25 | ▶ | if (@leftovers) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 2 | fail scalar(@leftovers) . ' object(s) of a DBIO::Test::Kubernetes run in the namespace'; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 2 | note 'if that run is still going (another session), wait for it. If it was'; | |||||||||||||||||||||||||||||||||||||||||
| 248 | 2 | note 'interrupted, these hold quota until they are deleted:'; | |||||||||||||||||||||||||||||||||||||||||
| 249 | 2 | note " $kubectl delete @leftovers"; | |||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 23 | ok 'nothing left over from a DBIO::Test::Kubernetes run'; | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | # ----------------------------- 4. the route to the address of the databases | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 25 | $checks++; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 25 | my %address; | |||||||||||||||||||||||||||||||||||||||||
| 259 | 25 | ▶ | for my $service (@{ $of_kind{Service} // [] }) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$of_kind{"Service"} // []
MC/DC100%1/1
$of_kind{"Service"} // []
$of_kind{"Service"}
Truth table100%2/2
A
A= $of_kind{"Service"}
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | $address{ $_->{ip} } = 1 | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 194 | ▶ | for grep { defined $_->{ip} } @{ $service->{status}{loadBalancer}{ingress} // [] }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$service->{"status"}{"loadBalancer"}{"ingress"} // []
MC/DC100%1/1
$service->{"status"}{"loadBalancer"}{"ingress"} // []
$service->{"status"}{"loadBalancer"}{"ingress"}
Truth table100%2/2
A
A= $service->{"status"}{"loadBalancer"}{"ingress"}
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 25 | ▶ | warn_ 'no LoadBalancer address in this namespace -- route check skipped' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | unless %address; | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 25 | for my $ip (sort keys %address) { | |||||||||||||||||||||||||||||||||||||||||
| 268 | 24 | my ($route, $route_error, $route_status) = run('ip', 'route', 'get', $ip); | |||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 12 | ▶ | if ($route_status == 127) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | warn_ "ip(8) is not in PATH -- route to $ip not checked"; | |||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | ▶ | elsif ($route_status != 0 or $route !~ /\bdev\s+(\S+)/) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$route_status != 0 or not $route =~ /\bdev\s+(\S+)/
MC/DC50%1/2
$route_status != 0 or not $route =~ /\bdev\s+(\S+)/
$route_status != 0
not $route =~ /\bdev\s+(\S+)/
Truth table66%2/3
A or not(B)
A= $route_status != 0B= not $route =~ /\bdev\s+(\S+)/
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 1 | chomp $route_error; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 1 | fail "no route to $ip from this machine"; | |||||||||||||||||||||||||||||||||||||||||
| 276 | 1 | note $_ for split /\n/, $route_error; | |||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | elsif ((my $dev = $1) =~ /^(?:br-|docker)/) { | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 2 | fail "route to $ip goes via $dev, a docker bridge, not to the cluster"; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 2 | note 'a local docker network covers the address, so every database behind'; | |||||||||||||||||||||||||||||||||||||||||
| 281 | 2 | note 'it looks dead from here while it is fine.'; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 2 | ▶ | if ($dev =~ /^br-([0-9a-f]{12})$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 1 | note "that network: docker network inspect $1"; | |||||||||||||||||||||||||||||||||||||||||
| 284 | 1 | note "remove it: docker network rm $1"; | |||||||||||||||||||||||||||||||||||||||||
| 285 | 1 | note "and give its stack a subnet that does not cover $ip"; | |||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 1 | note 'it is the default bridge: set "bip" in /etc/docker/daemon.json to a'; | |||||||||||||||||||||||||||||||||||||||||
| 289 | 1 | note "range that does not cover $ip, then restart docker"; | |||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 9 | ok "route to $ip goes via $dev"; | |||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | # ------------------------------------------------------------- the quota | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 13 | ▶ | for my $quota (@{ $of_kind{ResourceQuota} // [] }) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$of_kind{"ResourceQuota"} // []
MC/DC100%1/1
$of_kind{"ResourceQuota"} // []
$of_kind{"ResourceQuota"}
Truth table100%2/2
A
A= $of_kind{"ResourceQuota"}
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 12 | ▶ | my ($hard, $used) = @{ $quota->{status} // {} }{qw(hard used)}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$quota->{"status"} // {}
MC/DC0%0/1
$quota->{"status"} // {}
$quota->{"status"}
Truth table50%1/2
A
A= $quota->{"status"}
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | 12 | ▶ | my @resources = sort keys %{ $hard // {} }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$hard // {}
MC/DC0%0/1
$hard // {}
$hard
Truth table50%1/2
A
A= $hard
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | 12 | ▶ | next unless @resources; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | note 'quota ' . name($quota) . ': ' | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 12 | ▶ | . join(', ', map { "$_ " . ( $used->{$_} // '?' ) . "/$hard->{$_}" } @resources); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$used->{$_} // "?"
MC/DC0%0/1
$used->{$_} // "?"
$used->{$_}
Truth table50%1/2
A
A= $used->{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 12 | for my $resource (@resources) { | |||||||||||||||||||||||||||||||||||||||||
| 308 | 48 | my ($u, $h) = map { quantity($_) } $used->{$resource}, $hard->{$resource}; | |||||||||||||||||||||||||||||||||||||||||
| 309 | 48 | ▶ | next unless defined $u and defined $h and $u >= $h; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $u and defined $h and $u >= $h
defined $u and defined $h
MC/DC33%1/3
defined $u and defined $h and $u >= $h
defined $u
defined $h
$u >= $h
Truth table50%2/4
A and B and C
A= defined $uB= defined $hC= $u >= $h
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 2 | warn_ 'quota ' . name($quota) . ": $resource is used up ($used->{$resource} of $hard->{$resource})"; | |||||||||||||||||||||||||||||||||||||||||
| 311 | 2 | note "nothing that needs it can be started; $DBIO_DB down <db> frees some"; | |||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | # ------------------------------------------------------------------- verdict | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 13 | print STDERR "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 13 | ▶ | if ($failures) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 6 | print STDERR "PREFLIGHT FAILED -- $failures finding(s) in $checks checks. Do NOT start a live run.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 320 | 6 | exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 7 | ▶ | if ($warnings) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 2 | print STDERR "preflight clear ($checks checks, $warnings warning(s)) -- no finding, but read the\n" | |||||||||||||||||||||||||||||||||||||||||
| 324 | . "warnings before starting a live run.\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 2 | exit 0; | |||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 5 | print STDERR "preflight clear ($checks checks) -- live run is safe to start.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 328 | 5 | exit 0; | |||||||||||||||||||||||||||||||||||||||||