| 1 | package Kubernetes::Comb; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: A self-contained micro collection of Kubernetes parts as a live Perl instance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 17 | our $VERSION = '0.002'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 17 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 17 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 17 | ▶ | use Digest::SHA qw( sha256_hex ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 17 | ▶ | use Future; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 17 | ▶ | use Future::Utils qw( fmap_void ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 17 | ▶ | use IO::K8s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 17 | ▶ | use JSON::MaybeXS qw( JSON is_bool ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 17 | ▶ | use Module::Runtime qw( use_module use_package_optimistically ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 17 | ▶ | use POSIX qw( strftime ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 17 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 17 | ▶ | use Socket qw( AF_INET AF_INET6 inet_ntop inet_pton ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 17 | ▶ | use Types::Common::Numeric qw( PositiveInt ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 17 | ▶ | use Types::Standard qw( ArrayRef CodeRef ConsumerOf HashRef InstanceOf Maybe Object Str ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 17 | ▶ | use Kubernetes::Comb::CRD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 17 | ▶ | use Kubernetes::Comb::CRD::Comb; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 17 | ▶ | use Kubernetes::Comb::Client::Sync; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 17 | ▶ | use Kubernetes::Comb::Endpoint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 17 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # group/Kind of the workloads, each with the paths below the object where it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # keeps the templates of what it creates. The Comb labels go there too, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # the Pods (and a CronJob's Jobs) carry them. [] would be the object itself, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # which is always labelled; a bare Pod has nothing else. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 17 | my %WORKLOAD_TEMPLATES = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | '/Pod' => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | '/ReplicationController' => [ [qw( spec template )] ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 'apps/Deployment' => [ [qw( spec template )] ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 'apps/StatefulSet' => [ [qw( spec template )] ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 'apps/DaemonSet' => [ [qw( spec template )] ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 'apps/ReplicaSet' => [ [qw( spec template )] ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 'batch/Job' => [ [qw( spec template )] ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 'batch/CronJob' => [ [qw( spec jobTemplate )], [qw( spec jobTemplate spec template )] ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # Workloads that report ready replicas against spec.replicas. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 17 | my %REPLICATED = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | /ReplicationController apps/Deployment apps/StatefulSet apps/ReplicaSet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # What L</stop> brings to rest, with the spec field that says so. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 17 | my %STOPPABLE = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 'apps/Deployment' => 'replicas', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 'apps/StatefulSet' => 'replicas', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 'batch/CronJob' => 'suspend' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | # What L</restart> rolls through its Pod template annotation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 17 | my %RESTARTABLE = map { $_ => 1 } qw( apps/Deployment apps/StatefulSet apps/DaemonSet ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # Container waiting reasons that do not go away by waiting. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 17 | my %FAILURE_REASONS = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | CrashLoopBackOff ImagePullBackOff ErrImagePull ErrImageNeverPull InvalidImageName | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | CreateContainerConfigError CreateContainerError RunContainerError | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 17 | my %ENDPOINT_KEYS = map { $_ => 1 } qw( name port protocol service cluster external ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | #### Attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 17 | has k8s => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | isa => ConsumerOf['Kubernetes::Comb::Role::Client'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | ▶ | sub _build_k8s { Kubernetes::Comb::Client::Sync->new } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_k8s: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 17 | has resolver => ( is => 'ro', isa => CodeRef, predicate => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # init_arg upstream, but no `upstream` reader: a Comb class may define a plain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # `upstream` method (SPEC ยง5, source 3), and whether it does must stay visible | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # to can(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 17 | has _upstream => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | isa => Maybe[ CodeRef | HashRef | ArrayRef | Object ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | init_arg => 'upstream', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | predicate => 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 17 | has crd => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | is => 'rwp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | isa => InstanceOf['Kubernetes::Comb::CRD::Comb'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | predicate => 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 17 | has crd_class => ( is => 'lazy', isa => Str, predicate => '_has_crd_class' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 174 | ▶ | sub _build_crd_class { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_crd_class: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 174 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 174 | ▶ | return $self->has_crd ? ref $self->crd : 'Kubernetes::Comb::CRD::Comb'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 17 | has namespace => ( is => 'lazy', isa => Str ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 36 | ▶ | sub _build_namespace { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_namespace: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 36 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 36 | ▶ | my $meta = $self->has_crd ? $self->crd->metadata : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 36 | ▶ | my $namespace = $meta ? $meta->namespace : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 36 | ▶ | croak ref($self).' has no namespace: pass namespace, or a crd with metadata.namespace' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $namespace and length $namespace
MC/DC50%1/2
defined $namespace and length $namespace
defined $namespace
length $namespace
Truth table66%2/3
A and B
A= defined $namespaceB= length $namespace
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | unless defined $namespace && length $namespace; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 33 | return $namespace; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 17 | has config => ( is => 'lazy', isa => HashRef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 7 | ▶ | sub _build_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_config: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 7 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 7 | ▶ | my $spec = $self->has_crd ? $self->crd->spec : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 7 | ▶ | return $spec && $spec->config ? { %{ $spec->config } } : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$spec and $spec->config
MC/DC100%2/2
$spec and $spec->config
$spec
$spec->config
Truth table100%3/3
A and B
A= $specB= $spec->config
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 17 | has label_prefix => ( is => 'ro', isa => Str, default => 'comb.internal/' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 17 | has managed_by => ( is => 'ro', isa => Str, default => 'kubernetes-comb' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 17 | has max_upstream_depth => ( is => 'ro', isa => PositiveInt, default => 16 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 17 | has cluster_domain => ( is => 'ro', isa => Str, default => 'cluster.local' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 17 | has io_k8s => ( is => 'lazy', isa => InstanceOf['IO::K8s'] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 161 | ▶ | sub _build_io_k8s { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_io_k8s: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 161 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 161 | return IO::K8s->new( with => [ Kubernetes::Comb::CRD->new( crd_class => $self->crd_class ) ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 17 | has stub_of => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | isa => InstanceOf['Kubernetes::Comb'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | predicate => 'is_stub' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # The recorded status without a CR (with one it is crd->status). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 17 | has _memory_status => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | isa => Maybe[ InstanceOf['Kubernetes::Comb::CRD::CombStatus'] ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | init_arg => undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # Canonical, so the same manifest always encodes to the same bytes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 17 | has _digest_encoder => ( is => 'lazy', init_arg => undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 149 | ▶ | sub _build__digest_encoder { JSON->new->utf8->canonical } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build__digest_encoder: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 341 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 341 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 341 | ▶ | croak ref($self).': crd is a '.ref( $self->crd ).', not a '.$self->crd_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$self->has_crd and $self->_has_crd_class and not $self->crd->isa($self->crd_class)
$self->has_crd and $self->_has_crd_class
MC/DC100%3/3
$self->has_crd and $self->_has_crd_class and not $self->crd->isa($self->crd_class)
$self->has_crd
$self->_has_crd_class
not $self->crd->isa($self->crd_class)
Truth table100%4/4
A and B and not(C)
A= $self->has_crdB= $self->_has_crd_classC= not $self->crd->isa($self->crd_class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | if $self->has_crd && $self->_has_crd_class && !$self->crd->isa( $self->crd_class ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 340 | $self->_check_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 334 | ▶ | my $original = $self->is_stub ? $self->stub_of : $self->_original_by_name($args); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 334 | ▶ | $self->_check_stub_contract($original) if $original; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # The name is a label value on every resource of the Comb. A Comb that has | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | # no name yet fails its operations instead, not its construction. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 340 | ▶ | sub _check_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_name: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 340 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 340 | my ( $name ) = eval { $self->name }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 340 | ▶ | return unless defined $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 327 | ▶ | croak ref($self).": the name '".$name."' cannot be a label value, and it is one on every resource" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
length $name <= 63 and $name =~ /\A[A-Za-z0-9](?:[-A-Za-z0-9_.]*[A-Za-z0-9])?\z/
MC/DC100%2/2
length $name <= 63 and $name =~ /\A[A-Za-z0-9](?:[-A-Za-z0-9_.]*[A-Za-z0-9])?\z/
length $name <= 63
$name =~ /\A[A-Za-z0-9](?:[-A-Za-z0-9_.]*[A-Za-z0-9])?\z/
Truth table100%3/3
A and B
A= length $name <= 63B= $name =~ /\A[A-Za-z0-9](?:[-A-Za-z0-9_.]*[A-Za-z0-9])?\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | .' (at most 63 characters: letters, digits, -, _ and ., alphanumeric at both ends)' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | unless length $name <= 63 && $name =~ /\A[A-Za-z0-9](?:[-A-Za-z0-9_.]*[A-Za-z0-9])?\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # Foo::Stub that is a Foo stands in for a Foo, however it was selected: the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # Foo built from the same arguments, to check the contract against. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 326 | ▶ | sub _original_by_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_original_by_name: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 326 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 326 | my ( $original ) = ref($self) =~ /\A(.+)::Stub\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 326 | ▶ | return unless defined $original && $self->isa($original) && $original->isa(__PACKAGE__); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $original and $self->isa($original) and $original->isa(__PACKAGE__)
defined $original and $self->isa($original)
MC/DC66%2/3
defined $original and $self->isa($original) and $original->isa(__PACKAGE__)
defined $original
$self->isa($original)
$original->isa(__PACKAGE__)
Truth table75%3/4
A and B and C
A= defined $originalB= $self->isa($original)C= $original->isa(__PACKAGE__)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 3 | return $original->new(%$args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 11 | ▶ | sub _check_stub_contract { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_stub_contract: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 11 | my ( $self, $original ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 11 | my %own = map { $_ => 1 } $self->_endpoint_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 11 | my @missing = grep { !$own{$_} } $original->_endpoint_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 11 | ▶ | croak ref($self).' does not keep the contract of '.ref($original) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | .': missing endpoint(s) '.join( ', ', @missing ) if @missing; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | #### Contract | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 234 | ▶ | sub name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 234 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 234 | ▶ | my $meta = $self->has_crd ? $self->crd->metadata : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 234 | ▶ | return $meta->name if $meta && defined $meta->name && length $meta->name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$meta and defined $meta->name and length $meta->name
$meta and defined $meta->name
MC/DC33%1/3
$meta and defined $meta->name and length $meta->name
$meta
defined $meta->name
length $meta->name
Truth table50%2/4
A and B and C
A= $metaB= defined $meta->nameC= length $meta->name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 15 | croak ref($self).' has no name: override name, or build it from a Comb custom resource'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 224 | ▶ | sub depends_on { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
depends_on: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 224 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 224 | ▶ | my $spec = $self->has_crd ? $self->crd->spec : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 224 | ▶ | return $spec ? @{ $spec->dependsOn // [] } : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$spec->dependsOn // []
MC/DC100%1/1
$spec->dependsOn // []
$spec->dependsOn
Truth table100%2/2
A
A= $spec->dependsOn
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 4 | ▶ | sub endpoints { return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
endpoints: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 3 | ▶ | sub manifests { return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
manifests: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 2 | ▶ | sub check { return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 2 | ▶ | sub optional { 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
optional: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 61 | ▶ | sub bridge_manifests { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bridge_manifests: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 61 | my ( $self, @endpoints ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 61 | my %declared = map { ( $_->{name} => $_ ) } $self->_declared_endpoints; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 61 | my ( @services, %of ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 61 | for my $endpoint (@endpoints) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 68 | ▶ | my $declared = $declared{ $endpoint->name } // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$declared{$endpoint->name} // {}
MC/DC0%0/1
$declared{$endpoint->name} // {}
$declared{$endpoint->name}
Truth table50%1/2
A
A= $declared{$endpoint->name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 68 | ▶ | my $service = $declared->{service} // $self->name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$declared->{"service"} // $self->name
MC/DC0%0/2
$declared->{"service"} // $self->name
$declared->{"service"}
$self->name
Truth table66%2/3
A // B
A= $declared->{"service"}B= $self->name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 68 | ▶ | push @services, $service unless $of{$service}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 68 | push @{ $of{$service} }, $endpoint; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 61 | my ( @manifests, @problems ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 61 | for my $service (@services) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 59 | my ( $manifests, $problems ) = $self->_bridge_service( $service, @{ $of{$service} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 59 | push @manifests, @$manifests; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 59 | push @problems, @$problems; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 61 | ▶ | return @problems ? Future->fail( join( '; ', @problems ), 'bridge' ) : Future->done(@manifests); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 8 | ▶ | sub stub_class { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stub_class: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 8 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 8 | ▶ | my $stub = ( ref $self || $self ).'::Stub'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table66%2/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 8 | ▶ | use_package_optimistically($stub) unless $stub->can('new'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 8 | ▶ | return $stub->can('new') ? $stub : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 293 | ▶ | sub endpoint_class { 'Kubernetes::Comb::Endpoint' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
endpoint_class: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | #### Construction from the CR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 20 | ▶ | sub from_crd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_crd: called CC=11 SCAR=24.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 20 | my ( $self, $crd, %opts ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 20 | ▶ | my $base = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 20 | ▶ | croak $base.'->from_crd needs a Comb custom resource object' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($crd) and $crd->isa("Kubernetes::Comb::CRD::Comb")
MC/DC50%1/2
builtin::blessed($crd) and $crd->isa("Kubernetes::Comb::CRD::Comb")
builtin::blessed($crd)
$crd->isa("Kubernetes::Comb::CRD::Comb")
Truth table66%2/3
A and B
A= builtin::blessed($crd)B= $crd->isa("Kubernetes::Comb::CRD::Comb")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | unless blessed $crd && $crd->isa('Kubernetes::Comb::CRD::Comb'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 19 | ▶ | croak $base.'->from_crd: the custom resource has no spec.class' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$crd->spec and $crd->spec->class
MC/DC0%0/2
$crd->spec and $crd->spec->class
$crd->spec
$crd->spec->class
Truth table33%1/3
A and B
A= $crd->specB= $crd->spec->class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | unless $crd->spec && $crd->spec->class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 19 | my $stub = delete $opts{stub}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 19 | ▶ | croak $base.'->from_crd: stub must be a coderef' if defined $stub && ref $stub ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $stub and ref $stub ne "CODE"
MC/DC100%2/2
defined $stub and ref $stub ne "CODE"
defined $stub
ref $stub ne "CODE"
Truth table100%3/3
A and B
A= defined $stubB= ref $stub ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 18 | my $class = $self->_load_comb_class( $crd->spec->class, $base ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 15 | my $comb = $class->new( %opts, crd => $crd ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 13 | ▶ | return $comb unless $stub && $stub->($comb); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$stub and &$stub($comb)
MC/DC100%2/2
$stub and &$stub($comb)
$stub
&$stub($comb)
Truth table100%3/3
A and B
A= $stubB= &$stub($comb)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 5 | my $stub_class = $comb->stub_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 5 | ▶ | croak $base.'->from_crd: a stub was asked for '.$comb->name.', but '.$class.' has no stub class' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | unless defined $stub_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 4 | return $self->_load_comb_class( $stub_class, __PACKAGE__ ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | ->new( %opts, crd => $crd, stub_of => $comb ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 22 | ▶ | sub _load_comb_class { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_comb_class: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 22 | my ( $self, $class, $base ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 22 | ▶ | use_module($class) unless $class->can('new'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 21 | ▶ | croak( ( ref $self || $self ).'->from_crd: '.$class.' is not a '.$base ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | unless $class->isa($base); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 19 | return $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | #### Labels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 1056 | ▶ | sub comb_label { shift->label_prefix.'comb' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
comb_label: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 783 | ▶ | sub comb_namespace_label { shift->label_prefix.'comb-namespace' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
comb_namespace_label: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 495 | ▶ | sub comb_labels { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
comb_labels: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 495 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 495 | $self->comb_label => $self->name, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | $self->comb_namespace_label => $self->namespace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 'app.kubernetes.io/managed-by' => $self->managed_by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 188 | ▶ | sub label_selector { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
label_selector: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 188 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 188 | return $self->comb_label.'='.$self->name.','.$self->comb_namespace_label.'='.$self->namespace; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 17 | ▶ | sub restart_annotation { shift->label_prefix.'restartedAt' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
restart_annotation: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 580 | ▶ | sub applied_digest_annotation { shift->label_prefix.'applied-digest' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
applied_digest_annotation: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | #### Lifecycle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 229 | ▶ | sub reconcile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reconcile: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 229 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 229 | my $r = { previous => $self->recorded_status, conditions => {} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 229 | ▶ | return Future->call( sub { $self->_reconcile_steps($r) } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | ->else( sub { $self->_finish( $r, Error => ReconcileFailed => $self->_message( $_[0] ) ) } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 229 | ▶ | ->then( sub { $self->_publish_endpoints($r) } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 229 | ▶ | ->then( sub { $self->_record($r) } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 229 | ▶ | ->else( sub { Future->done( $self->_last_resort( $_[0] ) ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 2 | ▶ | sub rendered_resources { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rendered_resources: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 2 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 2 | ▶ | return $self->_planned_items->then( sub { Future->done( map { $_->{manifest} } @_ ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 8 | ▶ | sub plan { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
plan: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 8 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 7 | ▶ | return $self->_planned_items->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 7 | my @items = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 7 | ▶ | return $self->_fetch_live(@items)->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 7 | my @desired = map { $self->_resource_of($_) } @items; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 7 | my %changed = map { ( $_ => 1 ) } $self->_changed_items(@items); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 7 | my @previous = $self->_previous_resources( { previous => $self->recorded_status } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | return Future->done( { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 2 | create => [ map { $self->_resource_of($_) } grep { !$_->{live} } @items ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 1 | ▶ | update => [ map { $self->_resource_of($_) } grep { $_->{live} && $changed{$_} } @items ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$_->{'live'} && $changed{$_}
MC/DC100%2/2
$_->{'live'} && $changed{$_}
$_->{'live'}
$changed{$_}
Truth table100%3/3
A && B
A= $_->{'live'}B= $changed{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 7 | delete => [ grep { !$self->_cluster_scoped($_) } $self->_orphans( \@previous, \@desired ) ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 7 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 8 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 55 | ▶ | sub deploy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deploy: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 55 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 55 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 55 | ▶ | $self->_render->then( sub { $self->_apply(@_) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 55 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 61 | ▶ | sub status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 61 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 61 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 61 | ▶ | $self->_resolve_upstream->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 61 | my ( $upstream ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 61 | ▶ | return $upstream ? $self->_borrowed_status($upstream) : $self->_local_status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 61 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 61 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 9 | ▶ | sub healthy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
healthy: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 9 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 9 | ▶ | return $self->status->then( sub { Future->done( $_[0]{healthy} ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 8 | ▶ | sub logs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logs: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 8 | my ( $self, %args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 8 | ▶ | my $lines = $args{lines} // 100; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"lines"} // 100
MC/DC100%1/1
$args{"lines"} // 100
$args{"lines"}
Truth table100%2/2
A
A= $args{"lines"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 8 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 7 | ▶ | $self->_pods->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 7 | my @streams = map { $self->_log_streams($_) } @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 20 | ▶ | return Future->needs_all( map { $self->_log_text( $_, $lines ) } @streams )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 7 | my @texts = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 7 | ▶ | my $headers = @streams > 1 || grep { $_->{previous} } @streams; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
@streams > 1 || grep({$_->{'previous'};} @streams)
MC/DC50%1/2
@streams > 1 || grep({$_->{'previous'};} @streams)
@streams > 1
grep({$_->{'previous'};} @streams)
Truth table66%2/3
A || B
A= @streams > 1B= grep({$_->{'previous'};} @streams)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | return Future->done( join "\n", map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 7 | ▶ | ( $headers ? '==> '.$streams[$_]{label}.' <=='."\n" : '' ).$texts[$_] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | } 0 .. $#streams ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 7 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 8 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 8 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 5 | ▶ | sub restart { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
restart: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 5 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 5 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 5 | my $patch = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | spec => { template => { metadata => { annotations => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | $self->restart_annotation => $self->_now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } } } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 5 | ▶ | my $roll = sub { $self->k8s->patch( $_[0], patch => $patch, type => 'merge' ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 5 | return $self->_each_workload( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | [ 'apps/v1/Deployment' => $roll ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | [ 'apps/v1/StatefulSet' => $roll ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | [ 'apps/v1/DaemonSet' => $roll ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | [ 'batch/v1/Job' => $self->_delete_job ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 5 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 9 | ▶ | sub stop { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stop: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 9 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 9 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 9 | ▶ | my $scale = sub { $self->k8s->patch( $_[0], patch => { spec => { replicas => 0 } }, type => 'merge' ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | return $self->_each_workload( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | [ 'apps/v1/Deployment' => $scale ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | [ 'apps/v1/StatefulSet' => $scale ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 4 | ▶ | [ 'batch/v1/CronJob' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 4 | $self->k8s->patch( $_[0], patch => { spec => { suspend => JSON->true } }, type => 'merge' ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 9 | } ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | [ 'batch/v1/Job' => $self->_delete_job ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 9 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 6 | ▶ | sub describe { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 6 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 6 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 6 | my $recorded = $self->recorded_status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 6 | ▶ | my %describe = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | name => $self->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | class => ref $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | namespace => $self->namespace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | depends_on => [ $self->depends_on ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | ( $self->is_stub ? ( stub_of => ref $self->stub_of ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | ( $recorded ? ( recorded => $recorded->TO_JSON ) : () ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 5 | ▶ | return $self->_resolve_endpoints->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 5 | $describe{endpoints} = [ map { $_->to_crd->TO_JSON } @_ ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 5 | return $self->status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 4 | ▶ | } )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 4 | $describe{status} = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 4 | return Future->done( \%describe ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 5 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 6 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 13 | ▶ | sub endpoint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
endpoint: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 13 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 13 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 13 | ▶ | croak ref($self).'->endpoint needs a name' unless defined $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 8 | ▶ | return $self->_resolve_endpoints->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 8 | my ( $endpoint ) = grep { $_->name eq $name } @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 8 | ▶ | return Future->done($endpoint) if $endpoint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | return Future->fail( ref($self).'->endpoint: '.$self->name.' has no endpoint '.$name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 2 | ▶ | .' (it has: '.( join( ', ', map { $_->name } @_ ) || 'none' ).')' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
join(', ', map({$_->name;} @_)) || 'none'
MC/DC0%0/1
join(', ', map({$_->name;} @_)) || 'none'
join(', ', map({$_->name;} @_))
Truth table50%1/2
A
A= join(', ', map({$_->name;} @_))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 12 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 13 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 254 | ▶ | sub recorded_status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recorded_status: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 254 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 254 | ▶ | return $self->has_crd ? $self->crd->status : $self->_memory_status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | #### Internals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | # Future of the items a reconcile that gets as far as deploying would apply: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | # the rendered manifests, or the bridge of the upstream it borrows from. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 10 | ▶ | sub _planned_items { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_planned_items: called CC=1 SCAR=1.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 10 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 10 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 10 | ▶ | return $self->_resolve_upstream->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=12.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 10 | my ( $upstream ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 10 | ▶ | return $self->_render unless defined $upstream; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | return $self->_observe_upstream($upstream)->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | my ( $o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | return Future->fail( $o->{stop}[2], upstream => $o->{stop}[1] ) if $o->{stop}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | return Future->done( @{ $o->{items} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 10 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 10 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | # A contract method whose result may be a list or one Future of it, as a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | # Future; whatever it dies with becomes the failure. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 716 | ▶ | sub _hook { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hook: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 716 | my ( $self, $method, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 716 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 716 | my @result = $self->$method(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 693 | ▶ | return @result == 1 && blessed $result[0] && $result[0]->isa('Future') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@result == 1 and builtin::blessed($result[0]) and $result[0]->isa("Future")
@result == 1 and builtin::blessed($result[0])
MC/DC100%3/3
@result == 1 and builtin::blessed($result[0]) and $result[0]->isa("Future")
@result == 1
builtin::blessed($result[0])
$result[0]->isa("Future")
Truth table100%4/4
A and B and C
A= @result == 1B= builtin::blessed($result[0])C= $result[0]->isa("Future")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | ? $result[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | : Future->done(@result); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 716 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | # Fails with category manifests, so a broken manifest stays apart from a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | # failing request further down the chain. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 261 | ▶ | sub _render { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_render: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 261 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | return $self->_hook('manifests') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 249 | ▶ | ->then( sub { Future->done( $self->_items(@_) ) } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 261 | ▶ | ->else( sub { Future->fail( $_[0], 'manifests' ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 311 | ▶ | sub _items { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_items: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 311 | my ( $self, @manifests ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 311 | return map { $self->_item($_) } @manifests; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | # One manifest, ready to apply -- labelled, namespace set, a copy of what the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | # class returned -- plus what the Comb needs to know about it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 498 | ▶ | sub _item { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_item: called CC=20 SCAR=30.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 498 | my ( $self, $manifest ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 498 | my $class = blessed $manifest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 498 | ▶ | my $data = $class ? $manifest->TO_JSON : $manifest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 498 | ▶ | croak ref($self).': a manifest is an IO::K8s object or a hashref, got ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
ref $manifest || 'a plain scalar'
MC/DC0%0/1
ref $manifest || 'a plain scalar'
ref $manifest
Truth table50%1/2
A
A= ref $manifest
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | .( ref $manifest || 'a plain scalar' ) unless ref $data eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 497 | my $kind = $data->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 497 | ▶ | croak ref($self).': a manifest has no kind' unless defined $kind && length $kind; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $kind and length $kind
MC/DC50%1/2
defined $kind and length $kind
defined $kind
length $kind
Truth table66%2/3
A and B
A= defined $kindB= length $kind
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 495 | ▶ | my $name = ref $data->{metadata} eq 'HASH' ? $data->{metadata}{name} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 495 | ▶ | croak ref($self).': manifest '.$kind.' has no metadata.name' unless defined $name && length $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $name and length $name
MC/DC50%1/2
defined $name and length $name
defined $name
length $name
Truth table66%2/3
A and B
A= defined $nameB= length $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 493 | my $labels = $self->comb_labels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 492 | my $object = $self->_merged_meta( $data, [], labels => $labels ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 492 | ▶ | $object->{apiVersion} //= $self->_api_version_of($kind); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$object->{"apiVersion"} //= $self->_api_version_of($kind)
MC/DC0%0/2
$object->{"apiVersion"} //= $self->_api_version_of($kind)
$object->{"apiVersion"}
$self->_api_version_of($kind)
Truth table66%2/3
A //= B
A= $object->{"apiVersion"}B= $self->_api_version_of($kind)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 491 | my ( $group ) = $object->{apiVersion} =~ m{\A(.+)/[^/]+\z}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 491 | ▶ | $group //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$group //= ""
MC/DC100%1/1
$group //= ""
$group
Truth table100%2/2
A
A= $group
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 491 | my $templates = $WORKLOAD_TEMPLATES{ $group.'/'.$kind }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 491 | ▶ | $object = $self->_merged_meta( $object, $_, labels => $labels ) for @{ $templates // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$templates // []
MC/DC100%1/1
$templates // []
$templates
Truth table100%2/2
A
A= $templates
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 491 | my $namespace = $object->{metadata}{namespace}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 491 | ▶ | $object->{metadata}{namespace} = $namespace = $self->namespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not defined $namespace && length $namespace and $self->_namespaced($class, $object)
defined $namespace && length $namespace
MC/DC66%2/3
not defined $namespace && length $namespace and $self->_namespaced($class, $object)
defined $namespace
length $namespace
$self->_namespaced($class, $object)
Truth table60%3/5
not(A && B) and C
A= defined $namespaceB= length $namespaceC= $self->_namespaced($class, $object)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | if !( defined $namespace && length $namespace ) && $self->_namespaced( $class, $object ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | # Of the manifest as it stands here: what the class rendered plus what the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | # Comb adds to every one. The annotation itself comes after it, and so does | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | # what deploy carries over from the live object (_restart_kept). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 491 | my $digest = $self->_digest_of( $object, $kind.' '.$name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 489 | $object = $self->_merged_meta( $object, [], annotations => { $self->applied_digest_annotation => $digest } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | manifest => $class ? $class->FROM_HASH($object) : $object, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | data => $object, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | digest => $digest, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | class => $class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | apiVersion => $object->{apiVersion}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | kind => $kind, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | group => $group, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | namespace => $namespace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | resource => $class && $class ne 'IO::K8s::Unstructured' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | ? '+'.$class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 489 | ▶ | : $object->{apiVersion}.'/'.$kind, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
$class and $class ne "IO::K8s::Unstructured"
MC/DC50%1/2
$class and $class ne "IO::K8s::Unstructured"
$class
$class ne "IO::K8s::Unstructured"
Truth table66%2/3
A and B
A= $classB= $class ne "IO::K8s::Unstructured"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | workload => $templates ? 1 : 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | # A copy of $node with $values merged into metadata.$field (labels, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # annotations) at $path below it, copying only what it changes. A path that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | # does not exist is left alone. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 2021 | ▶ | sub _merged_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_merged_meta: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 2021 | my ( $self, $node, $path, $field, $values ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 2021 | my %copy = %$node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 2021 | ▶ | if ( my ( $key, @rest ) = @$path ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 704 | ▶ | $copy{$key} = $self->_merged_meta( $copy{$key}, \@rest, $field, $values ) if ref $copy{$key} eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 704 | return \%copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 1317 | ▶ | my %meta = ref $copy{metadata} eq 'HASH' ? %{ $copy{metadata} } : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 1317 | ▶ | $meta{$field} = { %{ $meta{$field} // {} }, %$values }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$meta{$field} // {}
MC/DC100%1/1
$meta{$field} // {}
$meta{$field}
Truth table100%2/2
A
A= $meta{$field}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 1317 | $copy{metadata} = \%meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 1317 | return \%copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | # The digest of a manifest, as the annotation holds it. A digest the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | # manifest brings along -- rendered from a live object, say -- is left out. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 491 | ▶ | sub _digest_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_digest_of: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 491 | my ( $self, $object, $what ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 491 | my $plain = $self->_digestable( $object, $what ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 489 | my $meta = $plain->{metadata}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 489 | ▶ | if ( ref $meta eq 'HASH' && ref $meta->{annotations} eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $meta eq "HASH" and ref $meta->{"annotations"} eq "HASH"
MC/DC50%1/2
ref $meta eq "HASH" and ref $meta->{"annotations"} eq "HASH"
ref $meta eq "HASH"
ref $meta->{"annotations"} eq "HASH"
Truth table66%2/3
A and B
A= ref $meta eq "HASH"B= ref $meta->{"annotations"} eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 5 | delete $meta->{annotations}{ $self->applied_digest_annotation }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 5 | ▶ | delete $meta->{annotations} unless %{ $meta->{annotations} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 489 | return 'sha256:'.sha256_hex( $self->_digest_encoder->encode($plain) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | # A copy of the value that encodes the same whatever Perl did to its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | # scalars: a number that was used as a string encodes as a string from then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | # on, and the other way round, and the manifest of a class is read more than | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | # once. So every leaf is a string, but for undef and the JSON booleans (\1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | # and \0 too). Dies on what no manifest holds. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 10987 | ▶ | sub _digestable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_digestable: called CC=13 SCAR=27.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 10987 | my ( $self, $value, $what ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 10987 | ▶ | return $value unless defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 10987 | my $ref = ref $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 10987 | ▶ | return ''.$value unless $ref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 4844 | ▶ | if ( blessed $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 2 | ▶ | return $value ? JSON->true : JSON->false if is_bool($value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | croak ref($self).': manifest '.$what.' cannot be digested: it holds a '.$ref.' object' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | unless $value->can('TO_JSON'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | return $self->_digestable( $value->TO_JSON, $what ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 4842 | ▶ | return { map { ( $_ => $self->_digestable( $value->{$_}, $what ) ) } keys %$value } if $ref eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 491 | ▶ | return [ map { $self->_digestable( $_, $what ) } @$value ] if $ref eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 7 | ▶ | return $$value ? JSON->true : JSON->false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
$ref eq "SCALAR" and defined $$value and $$value =~ /\A[01]\z/
$ref eq "SCALAR" and defined $$value
MC/DC33%1/3
$ref eq "SCALAR" and defined $$value and $$value =~ /\A[01]\z/
$ref eq "SCALAR"
defined $$value
$$value =~ /\A[01]\z/
Truth table50%2/4
A and B and C
A= $ref eq "SCALAR"B= defined $$valueC= $$value =~ /\A[01]\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | if $ref eq 'SCALAR' && defined $$value && $$value =~ /\A[01]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 2 | croak ref($self).': manifest '.$what.' cannot be digested: it holds a '.$ref.' reference'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | # The spec the item renders, {} when it has none. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 196 | ▶ | sub _rendered_spec { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rendered_spec: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 196 | my ( $self, $item ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 196 | my $spec = $item->{data}{spec}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 196 | ▶ | return ref $spec eq 'HASH' ? $spec : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 3 | ▶ | sub _api_version_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_api_version_of: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 3 | my ( $self, $kind ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 3 | my $io = $self->io_k8s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 3 | my $class = eval { my $c = $io->expand_class($kind); $io->load_class($c); $c }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 3 | ▶ | croak ref($self).': manifest '.$kind.' has no apiVersion, and '.$kind.' is no Kind IO::K8s knows' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$class and $class->can("api_version")
MC/DC50%1/2
$class and $class->can("api_version")
$class
$class->can("api_version")
Truth table66%2/3
A and B
A= $classB= $class->can("api_version")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | unless $class && $class->can('api_version'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 2 | return $class->api_version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | # A Kind io_k8s does not know counts as namespaced: the parts of a Comb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | # nearly always are, and the API server drops the namespace of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | # cluster-scoped object anyway. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 506 | ▶ | sub _namespaced { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_namespaced: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 506 | my ( $self, $class, $object ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 506 | ▶ | unless ( $class && $class ne 'IO::K8s::Unstructured' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$class and $class ne "IO::K8s::Unstructured"
MC/DC50%1/2
$class and $class ne "IO::K8s::Unstructured"
$class
$class ne "IO::K8s::Unstructured"
Truth table66%2/3
A and B
A= $classB= $class ne "IO::K8s::Unstructured"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 485 | $class = $self->io_k8s->expand_class( $object->{kind}, $object->{apiVersion} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 485 | ▶ | return 1 unless defined $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 484 | $self->io_k8s->load_class($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 505 | ▶ | return $class->does('IO::K8s::Role::Namespaced') ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | # Sequentially, so a Namespace or a CRD comes before what needs it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 165 | ▶ | sub _apply { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_apply: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 165 | my ( $self, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 165 | my @applied; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 1 | ▶ | return $self->_keep_restarts(@items)->else( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 1 | Future->fail( 'reading the live workloads failed: '.$self->_message( $_[0] ), deploy => { applied => [] } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 164 | ▶ | } )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 164 | my @kept = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 260 | ▶ | return ( fmap_void { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 260 | my ( $item ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | $self->k8s->ensure( $item->{manifest} )->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 257 | ▶ | sub { push @applied, $_[0]; Future->done }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 3 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | Future->fail( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 'ensure '.$item->{kind}.' '.$item->{name}.': '.$_[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | deploy => { applied => [@applied], failed => $item->{manifest} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 260 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 164 | ▶ | } foreach => \@kept, concurrent => 1 )->then( sub { Future->done(@applied) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 165 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | # Future of the items, each Deployment, StatefulSet and DaemonSet with the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | # restart annotation of its live Pod template: ensure replaces the object, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | # and without it the Pods would roll once more -- or a rolling restart would | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | # be undone. Reads the live objects the items do not have yet. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 165 | ▶ | sub _keep_restarts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_keep_restarts: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 165 | my ( $self, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 165 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 165 | ▶ | my @unread = grep { $RESTARTABLE{ $_->{group}.'/'.$_->{kind} } && !exists $_->{live} } @items; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$RESTARTABLE{$_->{'group'} . '/' . $_->{'kind'}} && !exists $_->{'live'}
MC/DC100%2/2
$RESTARTABLE{$_->{'group'} . '/' . $_->{'kind'}} && !exists $_->{'live'}
$RESTARTABLE{$_->{'group'} . '/' . $_->{'kind'}}
!exists $_->{'live'}
Truth table100%3/3
A && not(B)
A= $RESTARTABLE{$_->{'group'} . '/' . $_->{'kind'}}B= !exists $_->{'live'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 164 | ▶ | return ( @unread ? $self->_fetch_live(@unread) : Future->done )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 164 | Future->done( map { $self->_restart_kept($_) } @items ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 165 | ▶ | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 165 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 262 | ▶ | sub _restart_kept { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_restart_kept: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 262 | my ( $self, $item ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 262 | ▶ | return $item unless $RESTARTABLE{ $item->{group}.'/'.$item->{kind} } && $item->{live}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$RESTARTABLE{$item->{"group"} . '/' . $item->{"kind"}} and $item->{"live"}
MC/DC100%2/2
$RESTARTABLE{$item->{"group"} . '/' . $item->{"kind"}} and $item->{"live"}
$RESTARTABLE{$item->{"group"} . '/' . $item->{"kind"}}
$item->{"live"}
Truth table100%3/3
A and B
A= $RESTARTABLE{$item->{"group"} . '/' . $item->{"kind"}}B= $item->{"live"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 34 | my $template = $item->{live}->TO_JSON->{spec}{template}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 34 | ▶ | my $meta = ref $template eq 'HASH' ? $template->{metadata} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | my $at = ref $meta eq 'HASH' && ref $meta->{annotations} eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 34 | ▶ | ? $meta->{annotations}{ $self->restart_annotation } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $meta eq "HASH" and ref $meta->{"annotations"} eq "HASH"
MC/DC50%1/2
ref $meta eq "HASH" and ref $meta->{"annotations"} eq "HASH"
ref $meta eq "HASH"
ref $meta->{"annotations"} eq "HASH"
Truth table66%2/3
A and B
A= ref $meta eq "HASH"B= ref $meta->{"annotations"} eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 34 | ▶ | return $item unless defined $at; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 5 | my $data = $self->_merged_meta( $item->{data}, [qw( spec template )], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | annotations => { $self->restart_annotation => $at } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 5 | ▶ | return { %$item, data => $data, manifest => $item->{class} ? $item->{class}->FROM_HASH($data) : $data }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | # What status says of a Comb that runs its own resources. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 51 | ▶ | sub _local_status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_local_status: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 51 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 51 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 51 | ▶ | $self->_render->then( sub { $self->_observe_local(@_) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 51 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | # Future of what status says of the rendered @items; each item gets its live | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | # object (or undef) in $item->{live}. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 190 | ▶ | sub _observe_local { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_observe_local: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 190 | my ( $self, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 190 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 190 | ▶ | return Future->done( $self->_status_of( \@items, [] ) ) unless @items; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 178 | ▶ | return $self->_fetch_live(@items)->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | return Future->done( $self->_status_of( \@items, [] ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 178 | ▶ | unless grep { $_->{workload} && $_->{live} } @items; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_->{'workload'} && $_->{'live'}
MC/DC100%2/2
$_->{'workload'} && $_->{'live'}
$_->{'workload'}
$_->{'live'}
Truth table100%3/3
A && B
A= $_->{'workload'}B= $_->{'live'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 100 | ▶ | return $self->_pods->then( sub { Future->done( $self->_status_of( \@items, [@_] ) ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 186 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 190 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | # What status says of a Comb that borrows from $upstream. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 10 | ▶ | sub _borrowed_status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_borrowed_status: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 10 | my ( $self, $upstream ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 10 | ▶ | return $self->_observe_upstream($upstream)->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 10 | my ( $o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 10 | my %upstream = ( upstream => $self->_upstream_record($o) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 10 | ▶ | if ( my $stop = $o->{stop} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 2 | my ( $phase, $reason, $message ) = @$stop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | return Future->done( { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 2 | %{ $self->_verdict( $phase, [ { severity => 'error', reason => $reason, message => $message } ], [] ) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | %upstream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 8 | my @items = @{ $o->{items} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 8 | ▶ | return $self->_fetch_live(@items)->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | my @problems = map { +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | severity => 'pending', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | reason => 'ResourcesMissing', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 1 | message => $_->{kind}.' '.$_->{name}.' is missing' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 8 | } } grep { !$_->{live} } @items; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 8 | my ( $phase, $reason, $message ) = $self->_borrowed_verdict($o); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 8 | ▶ | push @problems, { severity => 'pending', reason => $reason, message => $message } if $phase ne 'Running'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | $phase = !@problems ? 'Running' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 8 | ▶ | : @items && !grep( { $_->{live} } @items ) ? 'NotDeployed' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
@items and not grep({$_->{"live"};} @items)
MC/DC50%1/2
@items and not grep({$_->{"live"};} @items)
@items
not grep({$_->{"live"};} @items)
Truth table66%2/3
A and not(B)
A= @itemsB= not grep({$_->{"live"};} @items)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | : 'Pending'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 8 | return Future->done( { %{ $self->_verdict( $phase, \@problems, [] ) }, %upstream } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 8 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 10 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | # Puts the live object (or undef) of every item into $item->{live}: one list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | # per resource and namespace, by label, so a missing object is an empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | # answer rather than an error to tell apart from others. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 236 | ▶ | sub _fetch_live { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fetch_live: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 236 | my ( $self, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 236 | my %groups; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 236 | ▶ | push @{ $groups{ $_->{resource} }{ $_->{namespace} // '' } }, $_ for @items; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_->{"namespace"} // ""
MC/DC100%1/1
$_->{"namespace"} // ""
$_->{"namespace"}
Truth table100%2/2
A
A= $_->{"namespace"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | return Future->needs_all( map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 236 | my $resource = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 373 | my ( $namespace, $members ) = ( $_, $groups{$resource}{$_} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | # By the name label alone: a same-named Comb of another namespace that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | # renders the same resource may have applied it last, and requiring | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | # the namespace label here would make both deploy it every step. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | $self->k8s->list( $resource, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | ( length $namespace ? ( namespace => $namespace ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | labelSelector => $self->comb_label.'='.$self->name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 359 | ▶ | )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 359 | ▶ | my %live = map { ( $_->metadata->name => $_ ) } @{ $_[0]->items // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0]->items // []
MC/DC0%0/1
$_[0]->items // []
$_[0]->items
Truth table50%1/2
A
A= $_[0]->items
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 359 | $_->{live} = $live{ $_->{name} } for @$members; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 359 | return Future->done; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 373 | ▶ | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 373 | } sort keys %{ $groups{$resource} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | } sort keys %groups ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 108 | ▶ | sub _pods { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pods: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 108 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | return $self->k8s->list( 'v1/Pod', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | namespace => $self->namespace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | labelSelector => $self->label_selector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 107 | ▶ | )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 107 | ▶ | return Future->done( sort { $a->metadata->name cmp $b->metadata->name } @{ $_[0]->items // [] } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0]->items // []
MC/DC0%0/1
$_[0]->items // []
$_[0]->items
Truth table50%1/2
A
A= $_[0]->items
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 108 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 182 | ▶ | sub _status_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_status_of: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 182 | my ( $self, $items, $pods ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 182 | my ( @pods, @problems ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 182 | for my $pod (@$pods) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 21 | my ( $state, $problem ) = $self->_pod_state($pod); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 21 | push @pods, $state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 21 | ▶ | push @problems, $problem if $problem; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 182 | ▶ | return $self->_verdict( Running => [], \@pods ) unless @$items; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | return $self->_verdict( NotDeployed => [ { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | severity => 'pending', reason => 'NotDeployed', message => 'not deployed' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 178 | ▶ | } ], \@pods ) unless grep { $_->{live} } @$items; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 116 | ▶ | return $self->_verdict( Stopped => [ { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | severity => 'pending', reason => 'Stopped', message => 'stopped' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | } ], \@pods ) if $self->_stopped($items); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | unshift @problems, map { +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | severity => 'pending', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | reason => 'ResourcesMissing', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 8 | message => $_->{kind}.' '.$_->{name}.' is missing' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 110 | } } grep { !$_->{live} } @$items; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 110 | ▶ | push @problems, map { $self->_workload_problem($_) } grep { $_->{workload} && $_->{live} } @$items; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$_->{'workload'} && $_->{'live'}
MC/DC100%2/2
$_->{'workload'} && $_->{'live'}
$_->{'workload'}
$_->{'live'}
Truth table100%3/3
A && B
A= $_->{'workload'}B= $_->{'live'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 110 | ▶ | my $phase = ( grep { $_->{severity} eq 'error' } @problems ) ? 'Error' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | : @problems ? 'Pending' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | : 'Running'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 110 | return $self->_verdict( $phase, \@problems, \@pods ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 192 | ▶ | sub _verdict { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_verdict: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 192 | my ( $self, $phase, $problems, $pods ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 192 | my ( $first ) = ( ( grep { $_->{severity} eq 'error' } @$problems ), @$problems ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | phase => $phase, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | healthy => $phase eq 'Running' ? JSON->true : JSON->false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | ( $first ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | reason => $first->{reason}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 192 | ▶ | message => join( '; ', map { $_->{message} } @$problems ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | pods => $pods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | # What L</stop> leaves: every Deployment/StatefulSet at 0, every CronJob | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | # suspended -- at least one of them against its manifest. The workloads stop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | # does not bring to rest (a DaemonSet, a ReplicaSet, a bare Pod) do not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | # count either way, its Jobs it deletes. A manifest that says 0 or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | # suspended itself is at rest as rendered, not stopped. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 116 | ▶ | sub _stopped { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stopped: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 116 | my ( $self, $items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 116 | my $against = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 116 | for my $item ( grep { $_->{live} } @$items ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 154 | ▶ | my $field = $STOPPABLE{ $item->{group}.'/'.$item->{kind} } or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 100 | ▶ | my $live = $item->{live}->TO_JSON->{spec} // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$item->{"live"}->TO_JSON->{"spec"} // {}
MC/DC0%0/1
$item->{"live"}->TO_JSON->{"spec"} // {}
$item->{"live"}->TO_JSON->{"spec"}
Truth table50%1/2
A
A= $item->{"live"}->TO_JSON->{"spec"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 100 | my $want = $self->_rendered_spec($item); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 100 | ▶ | if ( $field eq 'suspend' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 4 | ▶ | return 0 unless $live->{suspend}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 3 | ▶ | $against++ unless $want->{suspend}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 96 | ▶ | return 0 if ( $live->{replicas} // 1 ) != 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$live->{"replicas"} // 1
MC/DC100%1/1
$live->{"replicas"} // 1
$live->{"replicas"}
Truth table100%2/2
A
A= $live->{"replicas"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 11 | ▶ | $against++ if ( $want->{replicas} // 1 ) != 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$want->{"replicas"} // 1
MC/DC100%1/1
$want->{"replicas"} // 1
$want->{"replicas"}
Truth table100%2/2
A
A= $want->{"replicas"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 30 | ▶ | return $against ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 126 | ▶ | sub _workload_problem { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_workload_problem: called CC=24 SCAR=32.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 126 | my ( $self, $item ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 126 | my $live = $item->{live}->TO_JSON; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 126 | ▶ | my $spec = $live->{spec} // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$live->{"spec"} // {}
MC/DC0%0/1
$live->{"spec"} // {}
$live->{"spec"}
Truth table50%1/2
A
A= $live->{"spec"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 126 | ▶ | my $status = $live->{status} // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$live->{"status"} // {}
MC/DC100%1/1
$live->{"status"} // {}
$live->{"status"}
Truth table100%2/2
A
A= $live->{"status"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 126 | my $what = $item->{kind}.' '.$item->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 126 | my $key = $item->{group}.'/'.$item->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 126 | ▶ | if ( $key eq 'batch/Job' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 12 | my %true = map { ( $_->{type} => $_ ) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 17 | ▶ | grep { ( $_->{status} // '' ) eq 'True' } @{ $status->{conditions} // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
$_->{"status"} // ""
$status->{"conditions"} // []
MC/DC0%0/1
$_->{"status"} // ""
$_->{"status"}
MC/DC100%1/1
$status->{"conditions"} // []
$status->{"conditions"}
Truth table50%1/2
A
A= $_->{"status"}
Truth table100%2/2
A
A= $status->{"conditions"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 17 | ▶ | if ( my $failed = $true{Failed} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | severity => 'error', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | reason => $failed->{reason} // 'JobFailed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 2 | ▶ | message => $what.' failed'.( $failed->{message} ? ': '.$failed->{message} : '' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$failed->{"reason"} // "JobFailed"
MC/DC0%0/1
$failed->{"reason"} // "JobFailed"
$failed->{"reason"}
Truth table50%1/2
A
A= $failed->{"reason"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 15 | ▶ | return if $true{Complete} || ( $status->{succeeded} // 0 ) >= ( $spec->{completions} // 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition57%4/7
$true{"Complete"} or ($status->{"succeeded"} // 0) >= ($spec->{"completions"} // 1)
$status->{"succeeded"} // 0
$spec->{"completions"} // 1
MC/DC50%1/2
$true{"Complete"} or ($status->{"succeeded"} // 0) >= ($spec->{"completions"} // 1)
$true{"Complete"}
$status->{"succeeded"}
MC/DC0%0/1
$spec->{"completions"} // 1
$spec->{"completions"}
Truth table66%2/3
A or B
A= $true{"Complete"}B= $status->{"succeeded"}
Truth table50%1/2
A
A= $spec->{"completions"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 5 | return { severity => 'pending', reason => 'JobNotComplete', message => $what.' has not completed' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 109 | my ( $ready, $desired, $scaled_down ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 109 | ▶ | if ( $key eq 'apps/DaemonSet' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 6 | ▶ | ( $ready, $desired ) = ( $status->{numberReady} // 0, $status->{desiredNumberScheduled} // 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$status->{"numberReady"} // 0
$status->{"desiredNumberScheduled"} // 0
MC/DC100%1/1
$status->{"numberReady"} // 0
$status->{"numberReady"}
MC/DC100%1/1
$status->{"desiredNumberScheduled"} // 0
$status->{"desiredNumberScheduled"}
Truth table100%2/2
A
A= $status->{"numberReady"}
Truth table100%2/2
A
A= $status->{"desiredNumberScheduled"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | elsif ( $REPLICATED{$key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | # Scaled below what the manifest says -- deploy sets that, default 1 -- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | # by stop or by hand is short of replicas; scaled beyond it (by hand, an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | # autoscaler), the scale counts. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 96 | ▶ | my $scaled = $spec->{replicas} // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$spec->{"replicas"} // 1
MC/DC100%1/1
$spec->{"replicas"} // 1
$spec->{"replicas"}
Truth table100%2/2
A
A= $spec->{"replicas"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 96 | ▶ | my $wanted = $self->_rendered_spec($item)->{replicas} // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->_rendered_spec($item)->{"replicas"} // 1
MC/DC100%1/1
$self->_rendered_spec($item)->{"replicas"} // 1
$self->_rendered_spec($item)->{"replicas"}
Truth table100%2/2
A
A= $self->_rendered_spec($item)->{"replicas"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 96 | ▶ | $scaled_down = $scaled < $wanted ? $scaled : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 96 | ▶ | ( $ready, $desired ) = ( $status->{readyReplicas} // 0, $scaled < $wanted ? $wanted : $scaled ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$status->{"readyReplicas"} // 0
MC/DC100%1/1
$status->{"readyReplicas"} // 0
$status->{"readyReplicas"}
Truth table100%2/2
A
A= $status->{"readyReplicas"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 7 | return; # a bare Pod speaks for itself, a CronJob has nothing to wait for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 102 | ▶ | return if $ready >= $desired; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 29 | ▶ | severity => 'pending', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | reason => 'ReplicasNotReady', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | message => $what.': '.$ready.' of '.$desired.' ready' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | .( defined $scaled_down ? ' (scaled to '.$scaled_down.')' : '' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | # The public view of a Pod, and the problem it is for the Comb, if any. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 21 | ▶ | sub _pod_state { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pod_state: called CC=43 SCAR=39.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 21 | my ( $self, $pod ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 21 | my $data = $pod->TO_JSON; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 21 | ▶ | my $status = $data->{status} // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$data->{"status"} // {}
MC/DC0%0/1
$data->{"status"} // {}
$data->{"status"}
Truth table50%1/2
A
A= $data->{"status"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 21 | ▶ | my $phase = $status->{phase} // 'Unknown'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$status->{"phase"} // "Unknown"
MC/DC0%0/1
$status->{"phase"} // "Unknown"
$status->{"phase"}
Truth table50%1/2
A
A= $status->{"phase"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 21 | ▶ | my @containers = @{ $status->{containerStatuses} // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$status->{"containerStatuses"} // []
MC/DC0%0/1
$status->{"containerStatuses"} // []
$status->{"containerStatuses"}
Truth table50%1/2
A
A= $status->{"containerStatuses"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 21 | ▶ | my @all = ( @{ $status->{initContainerStatuses} // [] }, @containers ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$status->{"initContainerStatuses"} // []
MC/DC100%1/1
$status->{"initContainerStatuses"} // []
$status->{"initContainerStatuses"}
Truth table100%2/2
A
A= $status->{"initContainerStatuses"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 21 | my $restarts = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 21 | ▶ | $restarts += $_->{restartCount} // 0 for @all; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_->{"restartCount"} // 0
MC/DC0%0/1
$_->{"restartCount"} // 0
$_->{"restartCount"}
Truth table50%1/2
A
A= $_->{"restartCount"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 21 | ▶ | my $ready = $phase eq 'Running' && @containers && !grep { !$_->{ready} } @containers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
$phase eq 'Running' && @containers && !grep({not $_->{'ready'};} @containers)
$phase eq "Running" and @containers
MC/DC66%2/3
$phase eq 'Running' && @containers && !grep({not $_->{'ready'};} @containers)
$phase eq "Running"
@containers
!grep({not $_->{'ready'};} @containers)
Truth table75%3/4
A and B && not(C)
A= $phase eq "Running"B= @containersC= !grep({not $_->{'ready'};} @containers)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | my %state = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | name => $data->{metadata}{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 21 | ▶ | phase => $phase, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | ready => $ready ? JSON->true : JSON->false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | restarts => $restarts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 21 | ▶ | return \%state if $phase eq 'Succeeded' || $ready; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$phase eq "Succeeded" or $ready
MC/DC100%2/2
$phase eq "Succeeded" or $ready
$phase eq "Succeeded"
$ready
Truth table100%3/3
A or B
A= $phase eq "Succeeded"B= $ready
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 12 | my ( $severity, $reason, $message ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | my ( $container ) = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 12 | ▶ | $_->{state}{waiting} || ( $_->{state}{terminated} && ( $_->{state}{terminated}{exitCode} // 0 ) != 0 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition87%7/8
$_->{'state'}{'waiting'} || $_->{'state'}{'terminated'} && ($_->{'state'}{'terminated'}{'exitCode'} // 0) != 0
$_->{"state"}{"terminated"} and ($_->{"state"}{"terminated"}{"exitCode"} // 0) != 0
$_->{"state"}{"terminated"}{"exitCode"} // 0
MC/DC66%2/3
$_->{'state'}{'waiting'} || $_->{'state'}{'terminated'} && ($_->{'state'}{'terminated'}{'exitCode'} // 0) != 0
$_->{'state'}{'waiting'}
$_->{"state"}{"terminated"}
$_->{"state"}{"terminated"}{"exitCode"}
Truth table75%3/4
A || B and C
A= $_->{'state'}{'waiting'}B= $_->{"state"}{"terminated"}C= $_->{"state"}{"terminated"}{"exitCode"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | } @all; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | my ( $unscheduled ) = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 1 | ▶ | $_->{type} eq 'PodScheduled' && ( $_->{status} // '' ) eq 'False' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$_->{'type'} eq 'PodScheduled' && ($_->{'status'} // '') eq 'False'
$_->{"status"} // ""
MC/DC0%0/2
$_->{'type'} eq 'PodScheduled' && ($_->{'status'} // '') eq 'False'
$_->{'type'} eq 'PodScheduled'
$_->{"status"}
Truth table33%1/3
A && B
A= $_->{'type'} eq 'PodScheduled'B= $_->{"status"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 12 | ▶ | } @{ $status->{conditions} // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$status->{"conditions"} // []
MC/DC100%1/1
$status->{"conditions"} // []
$status->{"conditions"}
Truth table100%2/2
A
A= $status->{"conditions"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 12 | ▶ | if ( $phase eq 'Failed' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 3 | ▶ | my $terminated = $container ? $container->{state}{terminated} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 3 | ▶ | $reason = $status->{reason} // ( $terminated ? $terminated->{reason} : undef ) // 'Failed'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
($status->{"reason"} // ($terminated ? $terminated->{"reason"} : undef)) // "Failed"
$status->{"reason"} // ($terminated ? $terminated->{"reason"} : undef)
MC/DC0%0/2
($status->{"reason"} // ($terminated ? $terminated->{"reason"} : undef)) // "Failed"
$status->{"reason"}
($terminated ? $terminated->{"reason"} : undef)
Truth table66%2/3
A // B
A= $status->{"reason"}B= ($terminated ? $terminated->{"reason"} : undef)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 3 | ▶ | $message = $status->{message} // ( $terminated ? $self->_exit_message($terminated) : undef ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$status->{"message"} // ($terminated ? $self->_exit_message($terminated) : undef)
MC/DC0%0/2
$status->{"message"} // ($terminated ? $self->_exit_message($terminated) : undef)
$status->{"message"}
($terminated ? $self->_exit_message($terminated) : undef)
Truth table66%2/3
A // B
A= $status->{"message"}B= ($terminated ? $self->_exit_message($terminated) : undef)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 3 | ▶ | $severity = @{ $data->{metadata}{ownerReferences} // [] } ? undef : 'error'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$data->{"metadata"}{"ownerReferences"} // []
MC/DC100%1/1
$data->{"metadata"}{"ownerReferences"} // []
$data->{"metadata"}{"ownerReferences"}
Truth table100%2/2
A
A= $data->{"metadata"}{"ownerReferences"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | elsif ($unscheduled) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 1 | ▶ | ( $severity, $reason, $message ) = ( 'pending', $unscheduled->{reason} // 'Unschedulable', $unscheduled->{message} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$unscheduled->{"reason"} // "Unschedulable"
MC/DC0%0/1
$unscheduled->{"reason"} // "Unschedulable"
$unscheduled->{"reason"}
Truth table50%1/2
A
A= $unscheduled->{"reason"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | ▶ | elsif ( $container && ( my $waiting = $container->{state}{waiting} ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$container and my $waiting = $container->{"state"}{"waiting"}
MC/DC100%2/2
$container and my $waiting = $container->{"state"}{"waiting"}
$container
my $waiting = $container->{"state"}{"waiting"}
Truth table100%3/3
A and B
A= $containerB= my $waiting = $container->{"state"}{"waiting"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 5 | ▶ | $reason = $waiting->{reason} // 'Waiting'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$waiting->{"reason"} // "Waiting"
MC/DC0%0/1
$waiting->{"reason"} // "Waiting"
$waiting->{"reason"}
Truth table50%1/2
A
A= $waiting->{"reason"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 5 | $message = $waiting->{message}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 5 | ▶ | $severity = $FAILURE_REASONS{$reason} ? 'error' : 'pending'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | elsif ($container) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 1 | my $terminated = $container->{state}{terminated}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 1 | ▶ | ( $severity, $reason, $message ) = ( 'error', $terminated->{reason} // 'Error', $self->_exit_message($terminated) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$terminated->{"reason"} // "Error"
MC/DC0%0/1
$terminated->{"reason"} // "Error"
$terminated->{"reason"}
Truth table50%1/2
A
A= $terminated->{"reason"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | elsif ( $phase eq 'Unknown' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 0 | ▶ | ( $severity, $reason, $message ) = ( 'error', $status->{reason} // 'Unknown', $status->{message} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$status->{"reason"} // "Unknown"
MC/DC0%0/1
$status->{"reason"} // "Unknown"
$status->{"reason"}
Truth table0%0/2
A
A= $status->{"reason"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 2 | ▶ | ( $severity, $reason ) = ( 'pending', $phase eq 'Pending' ? 'Pending' : 'ContainersNotReady' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 12 | $state{reason} = $reason; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 12 | ▶ | $state{message} = $message if defined $message; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 12 | ▶ | return \%state unless $severity; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | return ( \%state, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | severity => $severity, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | reason => $reason, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 10 | ▶ | message => 'Pod '.$state{name}.': '.$reason | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $message and length $message
MC/DC50%1/2
defined $message and length $message
defined $message
length $message
Truth table66%2/3
A and B
A= defined $messageB= length $message
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | .( defined $message && length $message ? ': '.$message : '' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | .( $restarts ? ' ('.$restarts.' restarts)' : '' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 3 | ▶ | sub _exit_message { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exit_message: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 3 | my ( $self, $terminated ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | return 'exit code '.( $terminated->{exitCode} // '?' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 3 | ▶ | .( $terminated->{message} ? ': '.$terminated->{message} : '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$terminated->{"exitCode"} // "?"
MC/DC0%0/1
$terminated->{"exitCode"} // "?"
$terminated->{"exitCode"}
Truth table50%1/2
A
A= $terminated->{"exitCode"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 13 | ▶ | sub _log_streams { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_log_streams: called CC=9 SCAR=22.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 13 | my ( $self, $pod ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 13 | my $data = $pod->TO_JSON; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 13 | my $name = $data->{metadata}{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 23 | my %status = map { ( $_->{name} => $_ ) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 13 | ▶ | @{ $data->{status}{containerStatuses} // [] }, @{ $data->{status}{initContainerStatuses} // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
$data->{"status"}{"containerStatuses"} // []
$data->{"status"}{"initContainerStatuses"} // []
MC/DC0%0/1
$data->{"status"}{"containerStatuses"} // []
$data->{"status"}{"containerStatuses"}
MC/DC100%1/1
$data->{"status"}{"initContainerStatuses"} // []
$data->{"status"}{"initContainerStatuses"}
Truth table50%1/2
A
A= $data->{"status"}{"containerStatuses"}
Truth table100%2/2
A
A= $data->{"status"}{"initContainerStatuses"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 13 | ▶ | my @containers = map { $_->{name} } @{ $data->{spec}{containers} // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$data->{"spec"}{"containers"} // []
MC/DC0%0/1
$data->{"spec"}{"containers"} // []
$data->{"spec"}{"containers"}
Truth table50%1/2
A
A= $data->{"spec"}{"containers"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | my @init = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 6 | ▶ | my $terminated = $status{$_} && $status{$_}{state} ? $status{$_}{state}{terminated} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$status{$_} and $status{$_}{"state"}
MC/DC0%0/2
$status{$_} and $status{$_}{"state"}
$status{$_}
$status{$_}{"state"}
Truth table33%1/3
A and B
A= $status{$_}B= $status{$_}{"state"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | !( $terminated && !$terminated->{exitCode} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 13 | ▶ | } map { $_->{name} } @{ $data->{spec}{initContainers} // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
$terminated && !$terminated->{'exitCode'}
$data->{"spec"}{"initContainers"} // []
MC/DC50%1/2
$terminated && !$terminated->{'exitCode'}
$terminated
!$terminated->{'exitCode'}
MC/DC100%1/1
$data->{"spec"}{"initContainers"} // []
$data->{"spec"}{"initContainers"}
Truth table66%2/3
A && not(B)
A= $terminatedB= !$terminated->{'exitCode'}
Truth table100%2/2
A
A= $data->{"spec"}{"initContainers"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 17 | ▶ | return ( map { $self->_log_stream( $name, $_, $status{$_}, $_, @containers > 1 || @init ) } @containers ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
@containers > 1 || @init
MC/DC0%0/2
@containers > 1 || @init
@containers > 1
@init
Truth table66%2/3
A || B
A= @containers > 1B= @init
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 13 | map { $self->_log_stream( $name, $_, $status{$_}, 'init:'.$_, 1 ) } @init; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 20 | ▶ | sub _log_stream { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_log_stream: called CC=8 SCAR=21.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 20 | my ( $self, $pod, $container, $status, $label, $qualify ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 20 | ▶ | my $waiting = $status && $status->{state} ? $status->{state}{waiting} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$status and $status->{"state"}
MC/DC0%0/2
$status and $status->{"state"}
$status
$status->{"state"}
Truth table33%1/3
A and B
A= $statusB= $status->{"state"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 20 | ▶ | my $previous = $waiting && ( $waiting->{reason} // '' ) eq 'CrashLoopBackOff' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
$waiting and ($waiting->{"reason"} // "") eq "CrashLoopBackOff"
$waiting->{"reason"} // ""
MC/DC50%1/2
$waiting and ($waiting->{"reason"} // "") eq "CrashLoopBackOff"
$waiting
$waiting->{"reason"}
Truth table66%2/3
A and B
A= $waitingB= $waiting->{"reason"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | return +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 20 | ▶ | pod => $pod, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | container => $container, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | previous => $previous, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | label => $pod.( $qualify ? '/'.$label : '' ).( $previous ? ' (previous)' : '' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 20 | ▶ | sub _log_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_log_text: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 20 | my ( $self, $stream, $lines ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | return $self->k8s->log( 'v1/Pod', $stream->{pod}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | namespace => $self->namespace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | container => $stream->{container}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | ( $stream->{previous} ? ( previous => 1 ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | tailLines => $lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | )->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 16 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 16 | ▶ | my $text = $_[0] // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0] // ""
MC/DC0%0/1
$_[0] // ""
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 16 | ▶ | $text .= "\n" if length $text && $text !~ /\n\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
length $text and not $text =~ /\n\z/
MC/DC50%1/2
length $text and not $text =~ /\n\z/
length $text
not $text =~ /\n\z/
Truth table66%2/3
A and not(B)
A= length $textB= not $text =~ /\n\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 16 | return Future->done($text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | 4 | ▶ | sub { Future->done( '(no log: '.( $_[0] =~ s/\s+\z//r ).")\n" ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 20 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | # Lists each resource of the Comb by label, runs the action on every object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | # found; Future of the list of what it touched, as Kind/name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 14 | ▶ | sub _each_workload { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_each_workload: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 14 | my ( $self, @actions ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | return Future->needs_all( map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 14 | my ( $resource, $action ) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | $self->k8s->list( $resource, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | namespace => $self->namespace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | labelSelector => $self->label_selector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 52 | ▶ | )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 52 | ▶ | my @objects = sort { $a->metadata->name cmp $b->metadata->name } @{ $_[0]->items // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0]->items // []
MC/DC0%0/1
$_[0]->items // []
$_[0]->items
Truth table50%1/2
A
A= $_[0]->items
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | return Future->needs_all( map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 52 | my $object = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 28 | ▶ | $action->($object)->then( sub { Future->done( $object->kind.'/'.$object->metadata->name ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | } @objects ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 56 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | } @actions ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | # Background: without a propagationPolicy the API server orphans the Pods of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | # a deleted batch/v1 Job. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 14 | ▶ | sub _delete_job { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_delete_job: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 14 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 14 | ▶ | return sub { $self->k8s->delete( $_[0], propagationPolicy => 'Background' ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | # The endpoints as they are reached now: the local ones, or with an active | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | # upstream the redirected ones -- failing with the reason when there are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | # none. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 18 | ▶ | sub _resolve_endpoints { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_endpoints: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 18 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 18 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 18 | ▶ | $self->_resolve_upstream->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 18 | my ( $upstream ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 18 | ▶ | return Future->done( $self->_local_endpoints ) unless $upstream; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 6 | ▶ | return $self->_observe_upstream($upstream)->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 6 | my ( $o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 6 | ▶ | return $o->{endpoints} ? Future->done( @{ $o->{endpoints} } ) : Future->fail( $o->{stop}[2] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 6 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 18 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 18 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 172 | ▶ | sub _local_endpoints { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_local_endpoints: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 172 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 172 | return map { $self->_local_endpoint($_) } $self->_declared_endpoints; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 44 | ▶ | sub _local_endpoint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_local_endpoint: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 44 | my ( $self, $declared ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | return $self->endpoint_class->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | name => $declared->{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | port => $declared->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | ( defined $declared->{protocol} ? ( protocol => $declared->{protocol} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | cluster => $declared->{cluster} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | // ( $declared->{service} // $self->name ).'.'.$self->namespace.'.svc:'.$declared->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 44 | ▶ | ( defined $declared->{external} ? ( external => $declared->{external} ) : () ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition60%3/5
$declared->{"cluster"} // ($declared->{"service"} // $self->name) . '.' . $self->namespace . '.svc:' . $declared->{"port"}
$declared->{"service"} // $self->name
MC/DC0%0/1
$declared->{"cluster"} // ($declared->{"service"} // $self->name) . '.' . $self->namespace . '.svc:' . $declared->{"port"}
$declared->{"cluster"}
Truth table50%1/2
A
A= $declared->{"cluster"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 306 | ▶ | sub _declared_endpoints { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_declared_endpoints: called CC=13 SCAR=27.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 306 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 306 | my ( @declared, %seen ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 306 | for my $endpoint ( $self->endpoints ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 207 | my %declared; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 207 | ▶ | if ( blessed $endpoint && $endpoint->isa('Kubernetes::Comb::Endpoint') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
builtin::blessed($endpoint) and $endpoint->isa("Kubernetes::Comb::Endpoint")
MC/DC50%1/2
builtin::blessed($endpoint) and $endpoint->isa("Kubernetes::Comb::Endpoint")
builtin::blessed($endpoint)
$endpoint->isa("Kubernetes::Comb::Endpoint")
Truth table66%2/3
A and B
A= builtin::blessed($endpoint)B= $endpoint->isa("Kubernetes::Comb::Endpoint")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 8 | ▶ | %declared = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | name => $endpoint->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | port => $endpoint->port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | protocol => $endpoint->protocol, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | ( $endpoint->has_cluster ? ( cluster => $endpoint->cluster ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | ( $endpoint->has_external ? ( external => $endpoint->external ) : () ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | elsif ( ref $endpoint eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 199 | %declared = %$endpoint; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 199 | my @unknown = sort grep { !$ENDPOINT_KEYS{$_} } keys %declared; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 199 | ▶ | croak ref($self).'->endpoints: unknown key(s) '.join( ', ', @unknown ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | .' (known: '.join( ', ', sort keys %ENDPOINT_KEYS ).')' if @unknown; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 0 | ▶ | croak ref($self).'->endpoints: an endpoint is a hashref or a Kubernetes::Comb::Endpoint, got ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
ref $endpoint || 'a plain scalar'
MC/DC0%0/1
ref $endpoint || 'a plain scalar'
ref $endpoint
Truth table0%0/2
A
A= ref $endpoint
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | .( ref $endpoint || 'a plain scalar' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | croak ref($self).'->endpoints: an endpoint has no name' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 205 | ▶ | unless defined $declared{name} && length $declared{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $declared{"name"} and length $declared{"name"}
MC/DC0%0/2
defined $declared{"name"} and length $declared{"name"}
defined $declared{"name"}
length $declared{"name"}
Truth table33%1/3
A and B
A= defined $declared{"name"}B= length $declared{"name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 205 | my $problem = $self->endpoint_class->name_problem( $declared{name} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 205 | ▶ | croak ref($self).'->endpoints: '.$problem if defined $problem; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | croak ref($self).'->endpoints: endpoint '.$declared{name}.' is declared twice' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 203 | ▶ | if $seen{ $declared{name} }++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 203 | push @declared, \%declared; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 302 | return @declared; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 22 | ▶ | sub _endpoint_names { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_endpoint_names: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 22 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 22 | return map { $_->{name} } $self->_declared_endpoints; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | #### Upstream and bridge internals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | # The upstream path up to the bridge, shared by reconcile, status and the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | # endpoints: Future of { upstream, seen (what its status said), via, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | # endpoints (redirected), items (the bridge, ready to apply) } as far as it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | # got, and where it cannot go on stop => [ phase, reason, message ]. Never | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | # fails. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 68 | ▶ | sub _observe_upstream { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_observe_upstream: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 68 | my ( $self, $upstream ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 68 | my %o = ( upstream => $upstream ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 27 | ▶ | my $stop = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 27 | my ( $phase, $reason, $message ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 27 | return Future->fail( $message, stop => $phase, $reason ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 68 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 68 | ▶ | return $self->_hook( sub { $upstream->status( $_[0] ) } )->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 66 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 66 | my ( $seen ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 66 | ▶ | return $stop->( Error => UpstreamFailed => ref($upstream).'->status answered ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
ref $seen || 'a plain scalar'
MC/DC0%0/1
ref $seen || 'a plain scalar'
ref $seen
Truth table50%1/2
A
A= ref $seen
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | .( ref $seen || 'a plain scalar' ).', not a hashref' ) unless ref $seen eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 65 | $o{seen} = $seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 65 | ▶ | my $via = $seen->{via} // []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$seen->{"via"} // []
MC/DC100%1/1
$seen->{"via"} // []
$seen->{"via"}
Truth table100%2/2
A
A= $seen->{"via"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 65 | ▶ | return $stop->( Error => UpstreamFailed => ref($upstream).'->status answered a via that is no arrayref' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | unless ref $via eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | # A chain longer than that is taken for a loop, recorded cut to that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | # length: a loop then records the same via every step, not a growing one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 64 | my @via = @$via; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 64 | my $max = $self->max_upstream_depth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 64 | my $loop = @via > $max; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 64 | ▶ | splice @via, $max if $loop; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 64 | $o{via} = \@via; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 64 | my $label = $self->_upstream_label( \%o ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | return $stop->( Blocked => UpstreamUnreachable => $label.' is unreachable'.$self->_upstream_says( $seen, ': ' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 64 | ▶ | unless $seen->{reachable}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 60 | ▶ | return $stop->( Blocked => UpstreamLoop => $label.' leads through more than '.$max.' layers, a loop? via ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | .join( ', ', @via ) ) if $loop; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 53 | ▶ | return $self->_hook( sub { $upstream->endpoints( $_[0] ) } )->else( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 1 | $stop->( Error => UpstreamFailed => 'reading the endpoints of '.$label.' failed: '.$self->_message( $_[0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 53 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 2 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 2 | $stop->( Error => UpstreamFailed => 'reading the status of '.ref($upstream).' failed: '.$self->_message( $_[0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 52 | ▶ | )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | 52 | ▶ | my @offered = @_ == 1 && ref $_[0] eq 'ARRAY' ? @{ $_[0] } : @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 and ref $_[0] eq "ARRAY"
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "ARRAY"
@_ == 1
ref $_[0] eq "ARRAY"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 52 | ▶ | my @wrong = grep { !( blessed $_ && $_->isa('Kubernetes::Comb::Endpoint') ) } @offered; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
builtin::blessed($_) && $_->isa('Kubernetes::Comb::Endpoint')
MC/DC50%1/2
builtin::blessed($_) && $_->isa('Kubernetes::Comb::Endpoint')
builtin::blessed($_)
$_->isa('Kubernetes::Comb::Endpoint')
Truth table66%2/3
A && B
A= builtin::blessed($_)B= $_->isa('Kubernetes::Comb::Endpoint')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 52 | ▶ | return $stop->( Error => UpstreamFailed => ref($upstream).'->endpoints answered ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
ref $wrong[0] || 'a plain scalar'
MC/DC0%0/1
ref $wrong[0] || 'a plain scalar'
ref $wrong[0]
Truth table50%1/2
A
A= ref $wrong[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | .( ref $wrong[0] || 'a plain scalar' ).', not a Kubernetes::Comb::Endpoint' ) if @wrong; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 51 | my ( $redirected, $missing ) = $self->_redirect(@offered); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 51 | ▶ | if (@$missing) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 6 | my $phase = $o{seen}{phase}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | return $stop->( Blocked => UpstreamEndpointsMissing => $self->_upstream_label( \%o ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | .' offers no reachable address for endpoint(s) '.join( ', ', @$missing ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | .( defined $phase && $phase ne 'Running' ? ' (it is '.$phase.')' : '' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 6 | ▶ | .$self->_upstream_says( $o{seen}, '; ' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $phase and $phase ne "Running"
MC/DC100%2/2
defined $phase and $phase ne "Running"
defined $phase
$phase ne "Running"
Truth table100%3/3
A and B
A= defined $phaseB= $phase ne "Running"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 45 | $o{endpoints} = $redirected; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | return $self->_hook( bridge_manifests => @$redirected ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 42 | ▶ | ->then( sub { Future->done( $self->_items(@_) ) } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 4 | ▶ | ->else( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 4 | my ( $error, $category ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 4 | ▶ | return $stop->( Blocked => BridgeImpossible => 'the upstream cannot be bridged: '.$self->_message($error) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$category // ""
MC/DC100%1/1
$category // ""
$category
Truth table100%2/2
A
A= $category
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | if ( $category // '' ) eq 'bridge'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 2 | return $stop->( Error => BridgeFailed => 'rendering the bridge failed: '.$self->_message($error) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | 45 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | } )->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 41 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 41 | $o{items} = [@_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 41 | return Future->done( \%o ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 27 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 27 | my ( $message, $category, $phase, $reason ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 27 | ▶ | $o{stop} = ( $category // '' ) eq 'stop' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$category // ""
MC/DC0%0/1
$category // ""
$category
Truth table50%1/2
A
A= $category
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | ? [ $phase, $reason, $message ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | : [ Error => UpstreamFailed => 'borrowing from '.ref($upstream).' failed: '.$self->_message($message) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 27 | return Future->done( \%o ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 68 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | # The declared endpoints, each with the address of the upstream's endpoint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | # of that name: ( [ redirected ], [ names the upstream has no address for ] ). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 51 | ▶ | sub _redirect { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_redirect: called CC=11 SCAR=24.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 51 | my ( $self, @offered ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 51 | my %offered = map { ( $_->name => $_ ) } @offered; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 51 | my ( @redirected, @missing ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 51 | for my $declared ( $self->_declared_endpoints ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 50 | my $upstream = $offered{ $declared->{name} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 50 | ▶ | my $address = !$upstream ? undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | : $upstream->has_cluster ? $upstream->cluster | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | : $upstream->has_external ? $upstream->external | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 50 | ▶ | unless ( defined $address && length $address ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $address and length $address
MC/DC50%1/2
defined $address and length $address
defined $address
length $address
Truth table66%2/3
A and B
A= defined $addressB= length $address
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 6 | push @missing, $declared->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 6 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 44 | my ( $host, $port ) = $self->_split_address($address); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | 44 | ▶ | $address = $self->_join_address( $host, $upstream->port ) if defined $host && !defined $port; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $host and not defined $port
MC/DC0%0/2
defined $host and not defined $port
defined $host
not defined $port
Truth table33%1/3
A and not(B)
A= defined $hostB= not defined $port
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | push @redirected, $self->endpoint_class->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | name => $declared->{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | port => $declared->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 44 | ▶ | ( defined $declared->{protocol} ? ( protocol => $declared->{protocol} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | cluster => $address, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | ( $upstream->has_external ? ( external => $upstream->external ) : () ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 51 | return ( \@redirected, \@missing ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 106 | ▶ | sub _upstream_label { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upstream_label: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 106 | my ( $self, $o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 106 | ▶ | my $context = $o->{seen} ? $o->{seen}{context} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | 106 | ▶ | return 'upstream '.ref( $o->{upstream} ).( defined $context ? ' (context '.$context.')' : '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | # The message of the upstream status, as status text behind $glue; else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | # nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | 16 | ▶ | sub _upstream_says { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upstream_says: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 16 | my ( $self, $seen, $glue ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | 16 | ▶ | my $message = $seen && defined $seen->{message} ? $self->_message( $seen->{message} ) : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$seen and defined $seen->{"message"}
MC/DC50%1/2
$seen and defined $seen->{"message"}
$seen
defined $seen->{"message"}
Truth table66%2/3
A and B
A= $seenB= defined $seen->{"message"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 16 | ▶ | return length $message ? $glue.$message : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | # Phase, reason and message of a bridge that is in place: Running when the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | # upstream is, else Pending. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 35 | ▶ | sub _borrowed_verdict { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_borrowed_verdict: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | 35 | my ( $self, $o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 35 | my $label = $self->_upstream_label($o); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 35 | my $phase = $o->{seen}{phase}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | return ( Running => Borrowed => 'borrowed from '.$label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 35 | ▶ | .( @{ $o->{via} } ? ' via '.join( ', ', @{ $o->{via} } ) : '' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $phase and $phase eq "Running"
MC/DC50%1/2
defined $phase and $phase eq "Running"
defined $phase
$phase eq "Running"
Truth table66%2/3
A and B
A= defined $phaseB= $phase eq "Running"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | if defined $phase && $phase eq 'Running'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | return ( Pending => UpstreamNotRunning => $label.' is '.( defined $phase ? $phase : 'in no known phase' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 6 | ▶ | .$self->_upstream_says( $o->{seen}, ': ' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | # status.upstream as far as the upstream answered. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 62 | ▶ | sub _upstream_record { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upstream_record: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 62 | my ( $self, $o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 62 | ▶ | my $seen = $o->{seen} // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$o->{"seen"} // {}
MC/DC100%1/1
$o->{"seen"} // {}
$o->{"seen"}
Truth table100%2/2
A
A= $o->{"seen"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | class => ref $o->{upstream}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | ( defined $seen->{context} ? ( context => ''.$seen->{context} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | ( exists $seen->{reachable} ? ( reachable => $seen->{reachable} ? JSON->true : JSON->false ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | ( defined $seen->{phase} ? ( phase => ''.$seen->{phase} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 62 | ▶ | ( $o->{via} ? ( via => [ map { ''.$_ } @{ $o->{via} } ] ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | observedAt => $self->_now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | # The bridge of one Service: ( [ manifests ], [ why it cannot be ] ). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 59 | ▶ | sub _bridge_service { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bridge_service: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | 59 | my ( $self, $service, @endpoints ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | 59 | my ( @targets, @problems ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | 59 | for my $endpoint (@endpoints) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | 68 | ▶ | my $address = $endpoint->has_cluster ? $endpoint->cluster : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | 68 | ▶ | my ( $host, $port ) = defined $address ? $self->_split_address($address) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | 68 | ▶ | unless ( defined $host && defined $port ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $host and defined $port
MC/DC50%1/2
defined $host and defined $port
defined $host
defined $port
Truth table66%2/3
A and B
A= defined $hostB= defined $port
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 2 | ▶ | push @problems, 'endpoint '.$endpoint->name.' has ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | .( defined $address ? 'the address '.$address.', not host:port' : 'no address' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | 66 | my ( $family, $ip ) = $self->_ip_address($host); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 66 | ▶ | push @targets, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | endpoint => $endpoint, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | host => $family ? $ip : lc $host, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | port => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | family => $family | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 59 | ▶ | return ( [], \@problems ) if @problems; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | 57 | my %families = map { ( $_->{family} => 1 ) } @targets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | 57 | ▶ | if ( keys %families > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | 2 | ▶ | my $what = $families{''} ? 'host names and IP addresses' : 'IPv4 and IPv6 addresses'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | return ( [], [ 'Service '.$service.': its endpoints point at both '.$what.' (' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | 2 | .join( ', ', map { $_->{endpoint}->name.' at '.$_->{host} } @targets ).'), one Service cannot bridge both' ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | 55 | my @ports = map { +{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | name => $_->{endpoint}->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | port => $_->{endpoint}->port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | protocol => $self->_service_protocol( $_->{endpoint}->protocol ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | 62 | } } @targets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | 55 | ▶ | return $families{''} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | ? $self->_bridge_external_name( $service, \@ports, @targets ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | : $self->_bridge_endpoint_slices( $service, \@ports, @targets ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | 48 | ▶ | sub _bridge_external_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bridge_external_name: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | 48 | my ( $self, $service, $ports, @targets ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 48 | my @problems; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | 48 | my %hosts = map { ( $_->{host} => 1 ) } @targets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | push @problems, 'Service '.$service.': an ExternalName Service points at one host, but its endpoints are at ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | 48 | ▶ | .join( ', ', map { $_->{endpoint}->name.' at '.$_->{host} } @targets ) if keys %hosts > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | push @problems, map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | 'Service '.$service.': endpoint '.$_->{endpoint}->name.' is port '.$_->{endpoint}->port.' here but ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | 4 | .$_->{port}.' at '.$_->{host}.', and an ExternalName Service cannot map ports' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | 48 | } grep { $_->{port} != $_->{endpoint}->port } @targets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | 48 | ▶ | return ( [], \@problems ) if @problems; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | 43 | my $host = $targets[0]{host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 43 | ▶ | $host .= '.'.$self->cluster_domain if $host =~ /\.svc\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | return ( [ { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | 43 | apiVersion => 'v1', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | kind => 'Service', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | metadata => { name => $service }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | spec => { type => 'ExternalName', externalName => $host, ports => $ports } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | } ], [] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | # A selector-less Service, and one EndpointSlice per address: the endpoints | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | # of a slice serve all its ports. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | 7 | ▶ | sub _bridge_endpoint_slices { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bridge_endpoint_slices: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | 7 | my ( $self, $service, $ports, @targets ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | 7 | my $family = $targets[0]{family}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | 7 | my ( @addresses, %ports_at ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | 7 | for my $target (@targets) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | 9 | ▶ | push @addresses, $target->{host} unless $ports_at{ $target->{host} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | 9 | push @{ $ports_at{ $target->{host} } }, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | name => $target->{endpoint}->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | port => $target->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | protocol => $self->_service_protocol( $target->{endpoint}->protocol ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 7 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | return ( [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | apiVersion => 'v1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | kind => 'Service', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | metadata => { name => $service }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | spec => { ipFamilies => [ $family ], ipFamilyPolicy => 'SingleStack', ports => $ports } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 7 | map { +{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | apiVersion => 'discovery.k8s.io/v1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | kind => 'EndpointSlice', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | metadata => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | name => $service.'-'.++$n, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | labels => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | 'kubernetes.io/service-name' => $service, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | 'endpointslice.kubernetes.io/managed-by' => $self->managed_by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | addressType => $family, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | 8 | ports => $ports_at{$_}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | endpoints => [ { addresses => [ $_ ] } ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | } } @addresses | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | ], [] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 71 | ▶ | sub _service_protocol { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_service_protocol: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | 71 | my ( $self, $protocol ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | 71 | ▶ | my $upper = uc( $protocol // 'tcp' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$protocol // "tcp"
MC/DC0%0/1
$protocol // "tcp"
$protocol
Truth table50%1/2
A
A= $protocol
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 71 | ▶ | return $upper eq 'UDP' || $upper eq 'SCTP' ? $upper : 'TCP'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$upper eq "UDP" or $upper eq "SCTP"
MC/DC100%2/2
$upper eq "UDP" or $upper eq "SCTP"
$upper eq "UDP"
$upper eq "SCTP"
Truth table100%3/3
A or B
A= $upper eq "UDP"B= $upper eq "SCTP"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | # host:port, [v6]:port, or either without the port: ( host, port or undef ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | # nothing for what is none of these. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | 111 | ▶ | sub _split_address { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_split_address: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | 111 | my ( $self, $address ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | 111 | ▶ | return ( $1, $2 ) if $address =~ /\A\[([^\[\]\s]+)\](?::(\d+))?\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | 109 | ▶ | return ( $1, $2 ) if $address =~ /\A([^:\[\]\s]+)(?::(\d+))?\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | 1 | my ( $family ) = $self->_ip_address($address); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | 1 | ▶ | return ( $address, undef ) if $family eq 'IPv6'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | 0 | ▶ | sub _join_address { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_join_address: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 0 | my ( $self, $host, $port ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | 0 | my ( $family ) = $self->_ip_address($host); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | 0 | ▶ | return ( $family eq 'IPv6' ? '['.$host.']' : $host ).':'.$port; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | # ( IPv4 or IPv6, the address in canonical form ), or ( '' ) for a host name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | 67 | ▶ | sub _ip_address { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ip_address: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | 67 | my ( $self, $host ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 67 | for my $family ( [ IPv4 => AF_INET ], [ IPv6 => AF_INET6 ] ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | 124 | my $packed = inet_pton( $family->[1], $host ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 124 | ▶ | return ( $family->[0], inet_ntop( $family->[1], $packed ) ) if defined $packed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | 55 | return (''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | #### Reconcile internals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | # One reconcile step works on $r: previous (the recorded status it started | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | # from), conditions (type => { status, reason, message }), upstream (the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | # resolved one, undef for local; absent while unresolved), then phase, reason | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | # and message, and -- where a step knows them -- managed (resource hashrefs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | # and endpoints (Kubernetes::Comb::Endpoint). established says which path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | # settled what serves: local once the local path is through (healthy, or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | # deployed and pruned), upstream once the upstream path observed its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | # upstream. Each step either finishes $r or hands it to the next; a step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | # whose own work fails finishes it as Error. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | 232 | ▶ | sub _status_class { 'Kubernetes::Comb::CRD::CombStatus' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_status_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | 164 | ▶ | sub _upstream_role { 'Kubernetes::Comb::Role::Upstream' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upstream_role: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | 231 | ▶ | sub _finish { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finish: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | 231 | my ( $self, $r, $phase, $reason, $message ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | 231 | @{$r}{qw( phase reason message )} = ( $phase, $reason, $message ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | 231 | return Future->done($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | 436 | ▶ | sub _condition { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_condition: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | 436 | my ( $self, $r, $type, $status, $reason, $message ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 436 | $r->{conditions}{$type} = { status => $status, reason => $reason, message => $message }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | 436 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | # An error as status text: without the trailing whitespace, and without the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | # " at FILE line N." -- or "..., <FH> line N." -- that die and croak append | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | # when the text has no newline of its own. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | 53 | ▶ | sub _message { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_message: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | 53 | my ( $self, $error ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | 53 | ▶ | return 'unknown error' unless defined $error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | 53 | return ( ''.$error ) =~ s/\s+\z//r | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | =~ s/\s+at (?:\(eval \d+\)|\S+) line \d+(?:, <[^>]*> (?:line|chunk) \d+)?\.\z//r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | # Step 1, then on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | 229 | ▶ | sub _reconcile_steps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reconcile_steps: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | 229 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | return $self->_resolve_upstream->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | 226 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | 226 | ( $r->{upstream} ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | 226 | return $self->_reconcile_enabled($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | 3 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | 3 | $self->_finish( $r, Error => UpstreamFailed => 'resolving the upstream failed: '.$self->_message( $_[0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | 229 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | # Steps 2 and 3. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | 226 | ▶ | sub _reconcile_enabled { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reconcile_enabled: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | 226 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | 226 | my $off = $self->_disabled_because; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | 226 | ▶ | return $self->_finish( $r, Disabled => Disabled => $off ) if defined $off; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | return $self->_unmet_dependencies->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | 221 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | 221 | my @unmet = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | 221 | ▶ | unless (@unmet) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | 212 | $self->_condition( $r, DependenciesReady => True => Healthy => 'all dependencies are healthy' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | 212 | return $self->_reconcile_check($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | 9 | my $message = join '; ', map { $_->{message} } @unmet; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | 9 | $self->_condition( $r, DependenciesReady => False => $unmet[0]{reason}, $message ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | 9 | return $self->_finish( $r, Blocked => $unmet[0]{reason}, $message ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | 0 | $self->_finish( $r, Error => DependenciesFailed => 'reading the dependencies failed: '.$self->_message( $_[0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | 221 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | 226 | ▶ | sub _disabled_because { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_disabled_because: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | 226 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | 226 | ▶ | my $spec = $self->has_crd ? $self->crd->spec : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | 226 | ▶ | my $enabled = $spec ? $spec->enabled : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | 226 | ▶ | return defined $enabled ? ( $enabled ? undef : 'spec.enabled is false' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | : $self->optional ? ref($self).' is optional and spec.enabled is not set' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | # Future of one { reason, message } per dependency that is not there. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | 221 | ▶ | sub _unmet_dependencies { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unmet_dependencies: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | 221 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | 221 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | 221 | my @refs = $self->depends_on; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | 221 | ▶ | return Future->done unless @refs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | 11 | ▶ | return Future->done( { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | reason => 'NoResolver', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | message => 'depends on '.join( ', ', @refs ).', but there is no resolver to find them' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | } ) unless $self->has_resolver; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | 8 | return Future->needs_all( map { $self->_unmet_dependency($_) } @refs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | 221 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | 9 | ▶ | sub _unmet_dependency { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unmet_dependency: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | 9 | my ( $self, $ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | 9 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | 9 | my $dependency = $self->resolver->( $ref, $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | 7 | ▶ | return Future->done( { reason => 'DependencyNotFound', message => 'dependency '.$ref.' not found' } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | unless defined $dependency; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | 5 | ▶ | return Future->done( { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
builtin::blessed($dependency) and $dependency->can("healthy")
ref $dependency || 'a plain scalar'
MC/DC50%1/2
builtin::blessed($dependency) and $dependency->can("healthy")
builtin::blessed($dependency)
$dependency->can("healthy")
MC/DC0%0/1
ref $dependency || 'a plain scalar'
ref $dependency
Truth table66%2/3
A and B
A= builtin::blessed($dependency)B= $dependency->can("healthy")
Truth table50%1/2
A
A= ref $dependency
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | reason => 'DependencyInvalid', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | message => 'the resolver returned '.( ref $dependency || 'a plain scalar' ).' for '.$ref.', not a Comb' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | } ) unless blessed $dependency && $dependency->can('healthy'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | return $dependency->healthy->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | 3 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | 3 | ▶ | return Future->done if $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | 1 | return Future->done( { reason => 'DependencyNotReady', message => 'dependency '.$ref.' is not healthy' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | 1 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | 1 | return Future->done( { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | reason => 'DependencyNotReady', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | message => 'dependency '.$ref.' is not healthy: '.$self->_message( $_[0] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | 2 | ▶ | } )->else( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | 2 | Future->done( { reason => 'ResolverFailed', message => 'looking up '.$ref.' failed: '.$self->_message( $_[0] ) } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | 9 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | # Step 4, then the path. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | 212 | ▶ | sub _reconcile_check { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reconcile_check: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | 212 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | return $self->_hook('check')->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | 204 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | 204 | my @missing = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | 204 | ▶ | if (@missing) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | 7 | my $message = 'missing: '.join( '; ', @missing ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | 7 | $self->_condition( $r, ConfigReady => False => MissingPrerequisites => $message ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | 7 | return $self->_finish( $r, NeedsConfig => MissingPrerequisites => $message ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | 197 | $self->_condition( $r, ConfigReady => True => Complete => 'nothing missing' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | 197 | ▶ | return defined $r->{upstream} ? $self->_reconcile_upstream($r) : $self->_reconcile_local($r); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | 8 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | 8 | my $message = 'check failed: '.$self->_message( $_[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | 8 | $self->_condition( $r, ConfigReady => Unknown => CheckFailed => $message ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | 8 | return $self->_finish( $r, Error => CheckFailed => $message ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | 212 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | # Step 5a. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | 145 | ▶ | sub _reconcile_local { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reconcile_local: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | 145 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | # After borrowing, the bridge may stand where the local resources belong, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | # and look healthy: deploy anyway. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | 145 | ▶ | my $borrowed = $r->{previous} && $r->{previous}->upstream; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$r->{'previous'} && $r->{'previous'}->upstream
MC/DC100%2/2
$r->{'previous'} && $r->{'previous'}->upstream
$r->{'previous'}
$r->{'previous'}->upstream
Truth table100%3/3
A && B
A= $r->{'previous'}B= $r->{'previous'}->upstream
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | return $self->_render->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | 140 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | 140 | my @items = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | return $self->_observe_local(@items)->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | 136 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | 136 | my ( $live ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | 136 | ▶ | return $self->_deploy_and_prune( $r, $live, @items ) if !$live->{healthy} || $borrowed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $live->{"healthy"} or $borrowed
MC/DC100%2/2
not $live->{"healthy"} or $borrowed
not $live->{"healthy"}
$borrowed
Truth table100%3/3
not(A) or B
A= not $live->{"healthy"}B= $borrowed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | 54 | my @changed = $self->_changed_items(@items); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | 54 | ▶ | return $self->_deploy_changed( $r, \@changed, @items ) if @changed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | 47 | ▶ | return $self->_settle_record( $r, @items ) if $self->_record_differs( $r, @items ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | 42 | $r->{established} = 'local'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | 42 | return $self->_finish( $r, Running => Healthy => 'healthy' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | 4 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | 4 | $self->_finish( $r, Error => StatusFailed => 'reading the live status failed: '.$self->_message( $_[0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | 140 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | 5 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | 5 | $self->_finish( $r, Error => ManifestsFailed => 'rendering the manifests failed: '.$self->_message( $_[0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | 145 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | # Whether the rendered items and the recorded managedResources name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | # different resources (by group, kind, namespace, name): something to prune | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | # -- dropped from the manifests, or a delete that failed -- or something | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | # that runs but is not recorded. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | 47 | ▶ | sub _record_differs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_record_differs: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | 47 | my ( $self, $r, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | 47 | my %recorded = map { ( $self->_resource_key($_) => 1 ) } $self->_previous_resources($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | 47 | my %rendered = map { ( $self->_resource_key( $self->_resource_of($_) ) => 1 ) } @items; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | 47 | ▶ | return 1 if keys %recorded != keys %rendered; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | 42 | ▶ | return grep( { !$recorded{$_} } keys %rendered ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | # The items whose live object was applied from another manifest than the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | # one rendered now, or from one without a digest. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | 61 | ▶ | sub _changed_items { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_changed_items: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | 61 | my ( $self, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | return grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | 61 | $self->_digest_counts($_) && ( $self->_live_digest($_) // '' ) ne $_->{digest} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | 102 | ▶ | } @items; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
$self->_digest_counts($_) && ($self->_live_digest($_) // '') ne $_->{'digest'}
$self->_live_digest($_) // ""
MC/DC100%2/2
$self->_digest_counts($_) && ($self->_live_digest($_) // '') ne $_->{'digest'}
$self->_digest_counts($_)
$self->_live_digest($_)
Truth table100%3/3
A && B
A= $self->_digest_counts($_)B= $self->_live_digest($_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | 89 | ▶ | sub _live_digest { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_live_digest: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | 89 | my ( $self, $item ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | 89 | my $annotations = $item->{live}->metadata->annotations; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | 89 | ▶ | return ref $annotations eq 'HASH' ? $annotations->{ $self->applied_digest_annotation } : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | # Whether the digest of the live object says what this Comb applied. Not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | # where another deploy would not change it, or reconcile would deploy every | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | # step: what the client leaves as it is, and what a same-named Comb of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | # another namespace applied last (see _fetch_live) -- its labels, and so its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | # digest, are that Comb's. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | 102 | ▶ | sub _digest_counts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_digest_counts: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | 102 | my ( $self, $item ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | 102 | ▶ | my $live = $item->{live} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | 100 | ▶ | my $owner = ( $live->metadata->labels // {} )->{ $self->comb_namespace_label }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$live->metadata->labels // {}
MC/DC0%0/1
$live->metadata->labels // {}
$live->metadata->labels
Truth table50%1/2
A
A= $live->metadata->labels
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | 100 | ▶ | return 0 if defined $owner && $owner ne $self->namespace; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $owner and $owner ne $self->namespace
MC/DC50%1/2
defined $owner and $owner ne $self->namespace
defined $owner
$owner ne $self->namespace
Truth table66%2/3
A and B
A= defined $ownerB= $owner ne $self->namespace
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | 98 | ▶ | return $self->_kept_by_ensure($item) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | # What ensure of Kubernetes::REST and Net::Async::Kubernetes returns as it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | # found it: a core/v1 PersistentVolumeClaim, and a batch/v1 Job that runs or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | # has succeeded. Any other Job it replaces. By the exact apiVersion, as they | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | # tell. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | 98 | ▶ | sub _kept_by_ensure { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_kept_by_ensure: called CC=6 SCAR=19.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | 98 | my ( $self, $item ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | 98 | my $resource = $item->{apiVersion}.'/'.$item->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | 98 | ▶ | return 1 if $resource eq 'v1/PersistentVolumeClaim'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | 89 | ▶ | return 0 unless $resource eq 'batch/v1/Job'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | 9 | my $status = $item->{live}->TO_JSON->{status}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | 9 | ▶ | return ref $status eq 'HASH' && ( $status->{succeeded} || $status->{active} ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $status eq "HASH" and $status->{"succeeded"} || $status->{"active"}
$status->{"succeeded"} or $status->{"active"}
MC/DC0%0/3
ref $status eq "HASH" and $status->{"succeeded"} || $status->{"active"}
ref $status eq "HASH"
$status->{"succeeded"}
$status->{"active"}
Truth table25%1/4
A and B or C
A= ref $status eq "HASH"B= $status->{"succeeded"}C= $status->{"active"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | # A healthy Comb that renders something else than it applied: deploy and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | # prune. What is live and healthy is what was rendered before, so whether | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | # the Comb is Running is for the next step to see. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | 7 | ▶ | sub _deploy_changed { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_deploy_changed: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | 7 | my ( $self, $r, $changed, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | 7 | my ( @differ, @without ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | 7 | ▶ | push @{ defined $self->_live_digest($_) ? \@differ : \@without }, $_->{kind}.' '.$_->{name} for @$changed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | 7 | ▶ | return $self->_deploy_pending( $r, join( '; ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | ( @differ ? 'rendered differently now: '.join( ', ', @differ ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | ( @without ? 'applied without a digest: '.join( ', ', @without ) : () ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | ), @items ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | # A healthy Comb whose record differs: deploy and prune all the same, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | # the debt is paid while it runs. Everything rendered was live and healthy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | # before, and applied as rendered, so it stays Running. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | 5 | ▶ | sub _settle_record { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_settle_record: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | 5 | my ( $self, $r, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | 5 | ▶ | return $self->_apply_and_prune( $r, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | 5 | $r->{established} = 'local'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | 5 | $self->_finish( $r, Running => Healthy => join '; ', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | 'healthy', 'the record differed from the manifests: applied '.scalar(@items).' resource(s)', @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | 5 | }, @items ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | # Step 5b, the upstream path: upstream status and endpoints, replicate_into, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | # the bridge; it fills phase, managed, endpoints and upstream_status of $r. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | 52 | ▶ | sub _reconcile_upstream { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reconcile_upstream: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | 52 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | 52 | my $upstream = $r->{upstream}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | 52 | ▶ | return $self->_observe_upstream($upstream)->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | 52 | my ( $o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | 52 | $r->{established} = 'upstream'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | 52 | $r->{upstream_status} = $self->_upstream_record($o); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | 52 | ▶ | $r->{endpoints} = $o->{endpoints} if $o->{endpoints}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | 52 | ▶ | return $self->_finish( $r, @{ $o->{stop} } ) if $o->{stop}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | my $replicated = $upstream->can('replicate_into') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | 2 | ▶ | ? $self->_hook( sub { $upstream->replicate_into( $_[0] ) } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | 29 | ▶ | : Future->done; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | return $replicated->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | 28 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | 27 | ▶ | $self->_apply_and_prune( $r, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | 27 | my ( $phase, $reason, $message ) = $self->_borrowed_verdict($o); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | 27 | return $self->_finish( $r, $phase, $reason, join '; ', $message, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | 28 | }, @{ $o->{items} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | 1 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | 1 | $self->_finish( $r, Error => ReplicationFailed => 'replicating from '.$self->_upstream_label($o) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | .' failed: '.$self->_message( $_[0] ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | 29 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | 52 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | 82 | ▶ | sub _deploy_and_prune { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_deploy_and_prune: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | 82 | my ( $self, $r, $live, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | my $state = $live->{healthy} ? 'in place of the bridge' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | 82 | ▶ | : 'not healthy yet'.( $live->{phase} ne 'NotDeployed' && $live->{message} ? ' ('.$live->{message}.')' : '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$live->{"phase"} ne "NotDeployed" and $live->{"message"}
MC/DC50%1/2
$live->{"phase"} ne "NotDeployed" and $live->{"message"}
$live->{"phase"} ne "NotDeployed"
$live->{"message"}
Truth table66%2/3
A and B
A= $live->{"phase"} ne "NotDeployed"B= $live->{"message"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | 82 | return $self->_deploy_pending( $r, $state, @items ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | # Deploy and prune, then Pending, the message saying why it deployed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | 89 | ▶ | sub _deploy_pending { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_deploy_pending: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | 89 | my ( $self, $r, $why, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | 88 | ▶ | return $self->_apply_and_prune( $r, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | 88 | $r->{established} = 'local'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | 88 | $self->_finish( $r, Pending => Deployed => join '; ', 'applied '.scalar(@items).' resource(s), '.$why, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | 89 | }, @items ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | # Applies the items, then prunes what the record has and they do not; sets | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | # managed of $r. $done gets the notes of the pruning and finishes $r; a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | # failed apply finishes it as Error. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | 122 | ▶ | sub _apply_and_prune { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_apply_and_prune: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | 122 | my ( $self, $r, $done, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | 122 | my @previous = $self->_previous_resources($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | 122 | my @desired = map { $self->_resource_of($_) } @items; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | return $self->_apply(@items)->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | 120 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | 120 | ▶ | return $self->_prune( $self->_orphans( \@previous, \@desired ) )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | 120 | my @pruned = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | 120 | $r->{managed} = $self->_union( \@desired, [ map { $_->{resource} } grep { $_->{keep} } @pruned ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | 120 | ▶ | return $done->( map { $_->{note} // () } @pruned ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$_->{"note"} // ()
MC/DC0%0/2
$_->{"note"} // ()
$_->{"note"}
()
Truth table66%2/3
A // B
A= $_->{"note"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | 120 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | 2 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | 2 | my ( $error, $category, $details ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | # _apply goes one after the other: what it applied are the first items | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | my $applied = ( $category // '' ) eq 'deploy' && ref $details eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | 2 | ▶ | ? scalar @{ $details->{applied} // [] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition42%3/7
($category // "") eq "deploy" and ref $details eq "HASH"
$category // ""
$details->{"applied"} // []
MC/DC0%0/2
($category // "") eq "deploy" and ref $details eq "HASH"
$category
ref $details eq "HASH"
MC/DC0%0/1
$details->{"applied"} // []
$details->{"applied"}
Truth table33%1/3
A and B
A= $categoryB= ref $details eq "HASH"
Truth table50%1/2
A
A= $details->{"applied"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | 2 | $r->{managed} = $self->_union( [ @desired[ 0 .. $applied - 1 ] ], \@previous ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | 2 | return $self->_finish( $r, Error => DeployFailed => 'deploy failed: '.$self->_message($error) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | 122 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | 284 | ▶ | sub _previous_resources { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_previous_resources: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | 284 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | 284 | ▶ | my $recorded = $r->{previous} ? $r->{previous}->managedResources : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | return map { +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | 281 | ▶ | apiVersion => $_->apiVersion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | kind => $_->kind, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | ( defined $_->namespace ? ( namespace => $_->namespace ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | name => $_->name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | 284 | ▶ | } } @{ $recorded // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$recorded // []
MC/DC100%1/1
$recorded // []
$recorded
Truth table100%2/2
A
A= $recorded
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | 262 | ▶ | sub _resource_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resource_of: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | 262 | my ( $self, $item ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | apiVersion => $item->{apiVersion}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | kind => $item->{kind}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | ( defined $item->{namespace} ? ( namespace => $item->{namespace} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | name => $item->{name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | 262 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | # The recorded resources the desired ones no longer name, by identity: what | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | # the pruning is about. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | 127 | ▶ | sub _orphans { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_orphans: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | 127 | my ( $self, $previous, $desired ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | 127 | my %desired = map { ( $self->_resource_key($_) => 1 ) } @$desired; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | 127 | return grep { !$desired{ $self->_resource_key($_) } } @$previous; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | # Identity of a resource across API versions: group, kind, namespace, name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | 611 | ▶ | sub _resource_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resource_key: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | 611 | my ( $self, $resource ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | 611 | my ( $group ) = $resource->{apiVersion} =~ m{\A(.+)/[^/]+\z}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | 611 | ▶ | return join "\0", $group // '', $resource->{kind}, $resource->{namespace} // '', $resource->{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$group // ""
$resource->{"namespace"} // ""
MC/DC100%1/1
$group // ""
$group
MC/DC100%1/1
$resource->{"namespace"} // ""
$resource->{"namespace"}
Truth table100%2/2
A
A= $group
Truth table100%2/2
A
A= $resource->{"namespace"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | # The lists joined, the first of each identity kept. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | 122 | ▶ | sub _union { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_union: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | 122 | my ( $self, @lists ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | 122 | my ( %seen, @union ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | 122 | for my $resource ( map { @$_ } @lists ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | 172 | ▶ | push @union, $resource unless $seen{ $self->_resource_key($resource) }++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | 122 | return \@union; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | # Future of { resource, keep, note } per orphan; never fails. A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | # cluster-scoped orphan is left in place. An orphan that still carries the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | # Comb labels is deleted, with propagationPolicy Background: what it owns -- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | # the Pods of a Job, the ReplicaSets of a Deployment -- goes with it. One | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | # that does not carry them is gone or no longer this Comb's -- not ours to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | # delete either way. A failed check or delete keeps it for the next step. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | 120 | ▶ | sub _prune { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prune: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | 120 | my ( $self, @orphans ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | 120 | my ( @left, %groups ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | 120 | for my $orphan (@orphans) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | 26 | ▶ | if ( $self->_cluster_scoped($orphan) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | push @left, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | resource => $orphan, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | keep => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | 5 | note => 'left '.$orphan->{kind}.' '.$orphan->{name}.' in place: cluster-scoped, never pruned automatically' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | 5 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | 21 | ▶ | push @{ $groups{ $orphan->{apiVersion}.'/'.$orphan->{kind} }{ $orphan->{namespace} // '' } }, $orphan; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$orphan->{"namespace"} // ""
MC/DC0%0/1
$orphan->{"namespace"} // ""
$orphan->{"namespace"}
Truth table50%1/2
A
A= $orphan->{"namespace"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | 120 | ▶ | return Future->done(@left) unless %groups; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | return Future->needs_all( map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | 20 | my $resource = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | 20 | my ( $namespace, $members ) = ( $_, $groups{$resource}{$_} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | $self->k8s->list( $resource, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | ( length $namespace ? ( namespace => $namespace ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | labelSelector => $self->label_selector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | )->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | 19 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | 19 | ▶ | my %live = map { ( $_->metadata->name => $_ ) } @{ $_[0]->items // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0]->items // []
MC/DC0%0/1
$_[0]->items // []
$_[0]->items
Truth table50%1/2
A
A= $_[0]->items
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | 19 | return Future->needs_all( map { $self->_prune_one( $resource, $_, $live{ $_->{name} } ) } @$members ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | 1 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | 1 | my $error = $self->_message( $_[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | 1 | return Future->done( map { +{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | resource => $_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | keep => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | 1 | note => 'could not check '.$_->{kind}.' '.$_->{name}.' for pruning: '.$error | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | } } @$members ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | 20 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | 20 | } sort keys %{ $groups{$resource} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | 20 | ▶ | } sort keys %groups )->then( sub { Future->done( @left, @_ ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | # Cluster-scoped: a Namespace takes everything in it along, a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | # CustomResourceDefinition every object of its kind, and a same-named Comb of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | # another namespace may render it too. Recorded without a namespace means it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | # was applied as one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | 28 | ▶ | sub _cluster_scoped { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cluster_scoped: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | 28 | my ( $self, $resource ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | 28 | ▶ | return 1 unless defined $resource->{namespace}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | 24 | ▶ | return $self->_namespaced( undef, $resource ) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | 20 | ▶ | sub _prune_one { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prune_one: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | 20 | my ( $self, $resource, $orphan, $live ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | 20 | my $what = $orphan->{kind}.' '.$orphan->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | return $self->k8s->delete( $live, propagationPolicy => 'Background' )->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | 14 | ▶ | sub { Future->done( { resource => $orphan, keep => 0 } ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | 2 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | 2 | Future->done( { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | resource => $orphan, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | keep => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | note => 'deleting '.$what.' failed: '.$self->_message( $_[0] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | 20 | ▶ | ) if $live; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | return $self->k8s->get( $resource, $orphan->{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | ( defined $orphan->{namespace} ? ( namespace => $orphan->{namespace} ) : () ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | )->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | 3 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | 3 | Future->done( { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | resource => $orphan, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | keep => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | note => 'left '.$what.' alone: it no longer carries '.$self->label_selector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | 1 | ▶ | sub { Future->done( { resource => $orphan, keep => 0 } ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | 4 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | # Step 1: Future of the upstream object, or of nothing for local. The first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | # source that exists decides. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | 348 | ▶ | sub _resolve_upstream { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_upstream: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1873 | 348 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | 348 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1875 | 348 | ▶ | if ( $self->_has_upstream ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1876 | 91 | my $given = $self->_upstream; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | 69 | ▶ | return $self->_hook($given)->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | 69 | Future->done( $self->_upstream_from( 'the upstream coderef', @_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | 91 | ▶ | } ) if ref $given eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1880 | 19 | ▶ | return Future->done( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | $self->_upstream_from( 'the upstream argument', ref $given eq 'ARRAY' ? @$given : $given ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1884 | 257 | ▶ | my $spec = $self->has_crd ? $self->crd->spec : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | 257 | ▶ | return Future->done( $self->_upstream_from( 'spec.upstream', $spec->upstream ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$spec and $spec->has_upstream
MC/DC100%2/2
$spec and $spec->has_upstream
$spec
$spec->has_upstream
Truth table100%3/3
A and B
A= $specB= $spec->has_upstream
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | if $spec && $spec->has_upstream; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | 3 | ▶ | return $self->_hook('upstream')->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1888 | 3 | Future->done( $self->_upstream_from( ref($self).'->upstream', @_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | 235 | ▶ | } ) if $self->can('upstream'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1890 | 232 | return Future->done; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1891 | 348 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1892 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | # One answer: nothing (local), an upstream object, a hashref as in the custom | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | # resource, or Name => (%args) / '+Full::Class' => (%args). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1896 | 113 | ▶ | sub _upstream_from { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upstream_from: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1897 | 113 | my ( $self, $source, @answer ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1898 | 113 | ▶ | return if !@answer || ( @answer == 1 && !defined $answer[0] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
not @answer or @answer == 1 and not defined $answer[0]
@answer == 1 and not defined $answer[0]
MC/DC100%3/3
not @answer or @answer == 1 and not defined $answer[0]
not @answer
@answer == 1
not defined $answer[0]
Truth table100%4/4
not(A) or B and not(C)
A= not @answerB= @answer == 1C= not defined $answer[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1899 | 95 | my ( $first, @args ) = @answer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1900 | 95 | ▶ | if ( ref $first ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | 39 | ▶ | croak $source.': one upstream object or hashref, not a list of '.scalar(@answer) if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | 38 | ▶ | return $self->_checked_upstream( $source, $first ) if blessed $first; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1903 | 25 | ▶ | croak $source.': expected nothing, an upstream object, a hashref or Name => (...), got a ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1904 | .ref($first).' reference' unless ref $first eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1905 | 23 | my %spec = %$first; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1906 | 23 | my $class = delete $spec{class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1907 | 23 | ▶ | croak $source.' names no class' unless defined $class && length $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $class and length $class
MC/DC50%1/2
defined $class and length $class
defined $class
length $class
Truth table66%2/3
A and B
A= defined $classB= length $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1908 | 22 | return $self->_build_upstream( $source, $class, %spec ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1909 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1910 | 56 | ▶ | croak $source.': expected nothing, an upstream object, a hashref or Name => (...), got a list starting with undef' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1911 | unless defined $first; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1912 | 56 | ▶ | croak $source.': '.$first.' => (...) needs key/value pairs' if @args % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1913 | 55 | return $self->_build_upstream( $source, $self->_upstream_class($first), @args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1914 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1916 | 58 | ▶ | sub _upstream_class { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upstream_class: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1917 | 58 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1918 | 58 | ▶ | return $name =~ /\A\+(.+)\z/ ? $1 : 'Kubernetes::Comb::Upstream::'.$name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1919 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1920 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1921 | # Checked before it is built: a class the custom resource names gets no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1922 | # constructor call unless it is an upstream. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1923 | 77 | ▶ | sub _build_upstream { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_upstream: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1924 | 77 | my ( $self, $source, $class, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1925 | 77 | ▶ | use_module($class) unless $class->can('new'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1926 | 75 | ▶ | croak $source.': '.$class.' does not do '.$self->_upstream_role | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1927 | unless $class->DOES( $self->_upstream_role ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1928 | 71 | return $self->_checked_upstream( $source, $class->new(@args) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1929 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1930 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1931 | 84 | ▶ | sub _checked_upstream { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_checked_upstream: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1932 | 84 | my ( $self, $source, $upstream ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1933 | 84 | ▶ | croak $source.': '.ref($upstream).' does not do '.$self->_upstream_role | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1934 | unless $upstream->DOES( $self->_upstream_role ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1935 | 83 | return $upstream; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1936 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1937 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1938 | # Step 6, first half: the resolved local endpoints once the local path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1939 | # established them. The upstream path brings its own; a step that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1940 | # established nothing carries the previous ones forward (see _status_from) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1941 | # -- unless there are none, then a local Comb publishes its own. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1942 | 229 | ▶ | sub _publish_endpoints { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_publish_endpoints: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1943 | 229 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1944 | 229 | ▶ | my $established = $r->{established} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$r->{"established"} // ""
MC/DC100%1/1
$r->{"established"} // ""
$r->{"established"}
Truth table100%2/2
A
A= $r->{"established"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1945 | my $local = $established eq 'local' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1946 | 229 | ▶ | || ( !$established && !$r->{previous} && exists $r->{upstream} && !defined $r->{upstream} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%12/12
$established eq 'local' || !($established || $r->{'previous'}) && exists $r->{'upstream'} && !defined($r->{'upstream'})
not $established || $r->{"previous"} and exists $r->{"upstream"} and not defined $r->{"upstream"}
not $established || $r->{"previous"} and exists $r->{"upstream"}
$established || $r->{'previous'}
MC/DC100%5/5
$established eq 'local' || !($established || $r->{'previous'}) && exists $r->{'upstream'} && !defined($r->{'upstream'})
$established eq 'local'
$established
$r->{'previous'}
exists $r->{"upstream"}
not defined $r->{"upstream"}
Truth table100%6/6
A || not(B || C) and D and not(E)
A= $established eq 'local'B= $establishedC= $r->{'previous'}D= exists $r->{"upstream"}E= not defined $r->{"upstream"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1947 | 229 | ▶ | return Future->done($r) if $r->{endpoints} || !$local; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$r->{"endpoints"} or not $local
MC/DC100%2/2
$r->{"endpoints"} or not $local
$r->{"endpoints"}
not $local
Truth table100%3/3
A or not(B)
A= $r->{"endpoints"}B= not $local
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1948 | 160 | ▶ | return Future->call( sub { Future->done( $self->_local_endpoints ) } )->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1949 | 158 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1950 | 158 | $r->{endpoints} = [@_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1951 | 158 | return Future->done($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1952 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1953 | 2 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1954 | 2 | ▶ | return Future->done($r) if $r->{phase} eq 'Error'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1955 | 2 | return $self->_finish( $r, Error => EndpointsFailed => 'resolving the endpoints failed: '.$self->_message( $_[0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1956 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1957 | 160 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1958 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1959 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1960 | # Step 6: into the custom resource, else into memory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1961 | 229 | ▶ | sub _record { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_record: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1962 | 229 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1963 | 229 | my $status = $self->_status_from($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1964 | 227 | ▶ | unless ( $self->has_crd ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1965 | 168 | $self->_memory_status($status); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1966 | 168 | return Future->done($status); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1967 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1968 | 59 | ▶ | return Future->call( sub { $self->_write_status($status) } )->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1969 | 56 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1970 | 56 | my ( $stored ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1971 | 56 | $self->_set_crd($stored); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1972 | 56 | ▶ | return Future->done( $stored->status // $status ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$stored->status // $status
MC/DC0%0/2
$stored->status // $status
$stored->status
$status
Truth table33%1/3
A // B
A= $stored->statusB= $status
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1973 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1974 | 3 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1975 | # Keep what this step did, so the next one prunes against it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1976 | 3 | $self->_condition( $r, StatusWritten => False => WriteFailed => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1977 | 'writing the status into the custom resource failed: '.$self->_message( $_[0] ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1978 | 3 | my $kept = $self->_status_from($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1979 | 3 | $self->_set_crd( $self->_crd_with( $self->crd, $kept ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1980 | 3 | return Future->done($kept); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1981 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1982 | 59 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1983 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1984 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1985 | # update_status on a copy of the custom resource; if that fails -- a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1986 | # resourceVersion conflict looks like any other error -- once more on a fresh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1987 | # read of it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1988 | 59 | ▶ | sub _write_status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_status: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1989 | 59 | my ( $self, $status ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1990 | 5 | ▶ | return $self->k8s->update_status( $self->_crd_with( $self->crd, $status ) )->else( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1991 | 5 | my $meta = $self->crd->metadata; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1992 | 3 | ▶ | return $self->k8s->get( '+'.$self->crd_class, $meta->name, namespace => $meta->namespace )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1993 | 3 | my ( $fresh ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1994 | 3 | $self->_set_crd($fresh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1995 | 3 | return $self->k8s->update_status( $self->_crd_with( $fresh, $status ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1996 | 5 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1997 | 59 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1998 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2000 | 65 | ▶ | sub _crd_with { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_crd_with: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2001 | 65 | my ( $self, $crd, $status ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2002 | 65 | my $copy = ref($crd)->FROM_HASH( $crd->TO_JSON ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2003 | 65 | $copy->status($status); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2004 | 65 | return $copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2005 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2006 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2007 | 230 | ▶ | sub _status_from { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_status_from: called CC=21 SCAR=30.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2008 | 230 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2009 | 230 | my $now = $self->_now; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2010 | 230 | ▶ | my %before = map { ( $_->type => $_ ) } @{ ( $r->{previous} ? $r->{previous}->conditions : undef ) // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
($r->{"previous"} ? $r->{"previous"}->conditions : undef) // []
MC/DC100%1/1
($r->{"previous"} ? $r->{"previous"}->conditions : undef) // []
($r->{"previous"} ? $r->{"previous"}->conditions : undef)
Truth table100%2/2
A
A= ($r->{"previous"} ? $r->{"previous"}->conditions : undef)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2011 | 230 | my %unchecked = ( status => 'Unknown', reason => 'NotChecked', message => 'this step did not get that far' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2012 | my %conditions = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2013 | DependenciesReady => {%unchecked}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2014 | ConfigReady => {%unchecked}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2015 | 230 | ▶ | %{ $r->{conditions} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2016 | Ready => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2017 | status => $r->{phase} eq 'Running' ? 'True' : 'False', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2018 | reason => $r->{reason}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2019 | message => $r->{message} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2020 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2021 | 230 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2022 | 230 | my @fixed = qw( Ready DependenciesReady ConfigReady ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2023 | 230 | my %fixed = map { ( $_ => 1 ) } @fixed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2024 | 230 | ▶ | my $meta = $self->has_crd ? $self->crd->metadata : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025 | 230 | ▶ | my $generation = $meta ? $meta->generation : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2026 | # A step that established nothing -- it stopped before a path, or the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2027 | # local path failed before it was through -- changed nothing that serves: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2028 | # the endpoints and the upstream recorded before still stand, like | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2029 | # managedResources. So a bridge stays known until the local path replaced | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2030 | # it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2031 | 230 | ▶ | my $carried = $r->{established} ? undef : $r->{previous}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2032 | 49 | ▶ | my @endpoints = $r->{endpoints} ? ( map { $_->to_crd } @{ $r->{endpoints} } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2033 | 230 | ▶ | : $carried ? ( map { $_->TO_JSON } @{ $carried->endpoints // [] } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$carried->endpoints // []
MC/DC100%1/1
$carried->endpoints // []
$carried->endpoints
Truth table100%2/2
A
A= $carried->endpoints
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2034 | : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2035 | my $upstream = $r->{upstream_status} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2036 | 230 | ▶ | // ( $carried && $carried->upstream ? $carried->upstream->TO_JSON : undef ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$r->{"upstream_status"} // ($carried && $carried->upstream ? $carried->upstream->TO_JSON : undef)
$carried and $carried->upstream
MC/DC100%3/3
$r->{"upstream_status"} // ($carried && $carried->upstream ? $carried->upstream->TO_JSON : undef)
$r->{"upstream_status"}
$carried
$carried->upstream
Truth table100%4/4
A // B and C
A= $r->{"upstream_status"}B= $carriedC= $carried->upstream
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2037 | return $self->_status_class->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2038 | phase => $r->{phase}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2039 | conditions => [ map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2040 | 693 | my ( $type, $condition, $was ) = ( $_, $conditions{$_}, $before{$_} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2041 | +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2042 | type => $type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2043 | status => $condition->{status}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2044 | ( defined $condition->{reason} ? ( reason => $condition->{reason} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2045 | ( defined $condition->{message} ? ( message => $condition->{message} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2046 | 693 | ▶ | lastTransitionTime => $was && $was->status eq $condition->{status} && defined $was->lastTransitionTime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition83%5/6
$was and $was->status eq $condition->{"status"} and defined $was->lastTransitionTime
$was and $was->status eq $condition->{"status"}
MC/DC66%2/3
$was and $was->status eq $condition->{"status"} and defined $was->lastTransitionTime
$was
$was->status eq $condition->{"status"}
defined $was->lastTransitionTime
Truth table75%3/4
A and B and C
A= $wasB= $was->status eq $condition->{"status"}C= defined $was->lastTransitionTime
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2047 | ? $was->lastTransitionTime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2048 | : $now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2049 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2050 | 693 | ▶ | } @fixed, sort grep { !$fixed{$_} } keys %conditions ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%2/2
$r->{"managed"} // [$self->_previous_resources($r)]
MC/DC100%1/1
$r->{"managed"} // [$self->_previous_resources($r)]
$r->{"managed"}
Truth table100%2/2
A
A= $r->{"managed"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2051 | 230 | managedResources => $r->{managed} // [ $self->_previous_resources($r) ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2052 | endpoints => \@endpoints, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2053 | ( $upstream ? ( upstream => $upstream ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2054 | ( defined $generation ? ( observedGeneration => $generation ) : () ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2055 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2056 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2057 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2058 | # When even the status could not be built: the bare minimum, not written. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2059 | 2 | ▶ | sub _last_resort { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_last_resort: called CC=3 SCAR=11.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2060 | 2 | my ( $self, $error ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2061 | 2 | my $status = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2062 | 2 | $self->_status_class->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2063 | phase => 'Error', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2064 | conditions => [ { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2065 | type => 'Ready', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2066 | status => 'False', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2067 | reason => 'ReconcileFailed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2068 | message => 'recording the status failed: '.$self->_message($error), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2069 | lastTransitionTime => $self->_now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2070 | } ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2071 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2072 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2073 | 2 | ▶ | $self->_memory_status($status) if $status && !$self->has_crd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$status and not $self->has_crd
MC/DC0%0/2
$status and not $self->has_crd
$status
not $self->has_crd
Truth table33%1/3
A and not(B)
A= $statusB= not $self->has_crd
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2074 | 2 | return $status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2075 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2076 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2077 | 280 | ▶ | sub _now { strftime( '%Y-%m-%dT%H:%M:%SZ', gmtime ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_now: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2078 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2079 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2080 | 17 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2081 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2082 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||