| 1 | package Kubernetes::Comb; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: A self-contained micro collection of Kubernetes parts as a live Perl instance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 16 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 16 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 16 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 16 | ▶ | use Digest::SHA qw( sha256_hex ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 16 | ▶ | use Future; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 16 | ▶ | use Future::Utils qw( fmap_void ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 16 | ▶ | use IO::K8s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 16 | ▶ | use JSON::MaybeXS qw( JSON is_bool ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 16 | ▶ | use Module::Runtime qw( use_module use_package_optimistically ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 16 | ▶ | use POSIX qw( strftime ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 16 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 16 | ▶ | use Socket qw( AF_INET AF_INET6 inet_ntop inet_pton ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 16 | ▶ | use Types::Common::Numeric qw( PositiveInt ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 16 | ▶ | use Types::Standard qw( ArrayRef CodeRef ConsumerOf HashRef InstanceOf Maybe Object Str ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 16 | ▶ | use Kubernetes::Comb::CRD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 16 | ▶ | use Kubernetes::Comb::CRD::Comb; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 16 | ▶ | use Kubernetes::Comb::Client::Sync; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 16 | ▶ | use Kubernetes::Comb::Endpoint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 16 | ▶ | 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 | 16 | 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 | 16 | 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 | 16 | 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 | 16 | my %RESTARTABLE = map { $_ => 1 } qw( apps/Deployment apps/StatefulSet apps/DaemonSet ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # Container waiting reasons that do not go away by waiting. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 16 | my %FAILURE_REASONS = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | CrashLoopBackOff ImagePullBackOff ErrImagePull ErrImageNeverPull InvalidImageName | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | CreateContainerConfigError CreateContainerError RunContainerError | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 16 | my %ENDPOINT_KEYS = map { $_ => 1 } qw( name port protocol service cluster external ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | #### Attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 16 | 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 | 16 | 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 | 16 | has _upstream => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | isa => Maybe[ CodeRef | HashRef | ArrayRef | Object ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | init_arg => 'upstream', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | predicate => 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 16 | has crd => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | is => 'rwp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | isa => InstanceOf['Kubernetes::Comb::CRD::Comb'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | predicate => 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 16 | has crd_class => ( is => 'lazy', isa => Str, predicate => '_has_crd_class' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 169 | ▶ | sub _build_crd_class { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_crd_class: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 169 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 169 | ▶ | return $self->has_crd ? ref $self->crd : 'Kubernetes::Comb::CRD::Comb'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 16 | 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 | 16 | 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 | 16 | has label_prefix => ( is => 'ro', isa => Str, default => 'comb.internal/' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 16 | has managed_by => ( is => 'ro', isa => Str, default => 'kubernetes-comb' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 16 | has max_upstream_depth => ( is => 'ro', isa => PositiveInt, default => 16 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 16 | has cluster_domain => ( is => 'ro', isa => Str, default => 'cluster.local' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 16 | has io_k8s => ( is => 'lazy', isa => InstanceOf['IO::K8s'] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 156 | ▶ | sub _build_io_k8s { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_io_k8s: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 156 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 156 | return IO::K8s->new( with => [ Kubernetes::Comb::CRD->new( crd_class => $self->crd_class ) ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 16 | 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 | 16 | 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 | 16 | has _digest_encoder => ( is => 'lazy', init_arg => undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 144 | ▶ | sub _build__digest_encoder { JSON->new->utf8->canonical } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build__digest_encoder: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 334 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 334 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 334 | ▶ | 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 | 333 | $self->_check_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 327 | ▶ | my $original = $self->is_stub ? $self->stub_of : $self->_original_by_name($args); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 327 | ▶ | $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 | 333 | ▶ | sub _check_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_name: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 333 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 333 | my ( $name ) = eval { $self->name }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 333 | ▶ | return unless defined $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 320 | ▶ | 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 | 319 | ▶ | sub _original_by_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_original_by_name: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 319 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 319 | my ( $original ) = ref($self) =~ /\A(.+)::Stub\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 319 | ▶ | 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 | 220 | ▶ | sub depends_on { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
depends_on: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 220 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 220 | ▶ | my $spec = $self->has_crd ? $self->crd->spec : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 220 | ▶ | 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 | 1029 | ▶ | sub comb_label { shift->label_prefix.'comb' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
comb_label: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 762 | ▶ | sub comb_namespace_label { shift->label_prefix.'comb-namespace' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
comb_namespace_label: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 483 | ▶ | sub comb_labels { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
comb_labels: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 483 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 483 | $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 | 184 | ▶ | sub label_selector { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
label_selector: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 184 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 184 | 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 | 562 | ▶ | 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 | 225 | ▶ | sub reconcile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reconcile: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 225 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 225 | my $r = { previous => $self->recorded_status, conditions => {} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 225 | ▶ | 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 | 225 | ▶ | ->then( sub { $self->_publish_endpoints($r) } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 225 | ▶ | ->then( sub { $self->_record($r) } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 225 | ▶ | ->else( sub { Future->done( $self->_last_resort( $_[0] ) ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 55 | ▶ | sub deploy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deploy: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 55 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 55 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 55 | ▶ | $self->_render->then( sub { $self->_apply(@_) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 55 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 61 | ▶ | sub status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 61 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 61 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 61 | ▶ | $self->_resolve_upstream->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 61 | my ( $upstream ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 61 | ▶ | return $upstream ? $self->_borrowed_status($upstream) : $self->_local_status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 61 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 61 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 9 | ▶ | sub healthy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
healthy: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 9 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 9 | ▶ | return $self->status->then( sub { Future->done( $_[0]{healthy} ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 6 | ▶ | sub logs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logs: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 6 | my ( $self, %args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 6 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 6 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 5 | ▶ | $self->_pods->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 5 | my @streams = map { $self->_log_streams($_) } @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 8 | ▶ | return Future->needs_all( map { $self->_log_text( $_, $lines ) } @streams )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 5 | my @texts = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 5 | ▶ | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | return Future->done( join "\n", map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 5 | ▶ | ( $headers ? '==> '.$streams[$_]{label}.' <=='."\n" : '' ).$texts[$_] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } 0 .. $#streams ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 5 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 6 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 6 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 5 | ▶ | sub restart { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
restart: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 5 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 5 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 5 | my $patch = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | spec => { template => { metadata => { annotations => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | $self->restart_annotation => $self->_now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } } } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 5 | ▶ | my $roll = sub { $self->k8s->patch( $_[0], patch => $patch, type => 'merge' ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 5 | return $self->_each_workload( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | [ 'apps/v1/Deployment' => $roll ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | [ 'apps/v1/StatefulSet' => $roll ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | [ 'apps/v1/DaemonSet' => $roll ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | [ 'batch/v1/Job' => $self->_delete_job ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 5 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 9 | ▶ | sub stop { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stop: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 9 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 9 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 9 | ▶ | my $scale = sub { $self->k8s->patch( $_[0], patch => { spec => { replicas => 0 } }, type => 'merge' ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | return $self->_each_workload( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | [ 'apps/v1/Deployment' => $scale ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | [ 'apps/v1/StatefulSet' => $scale ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 4 | ▶ | [ 'batch/v1/CronJob' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 4 | $self->k8s->patch( $_[0], patch => { spec => { suspend => JSON->true } }, type => 'merge' ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 9 | } ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | [ 'batch/v1/Job' => $self->_delete_job ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 9 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 6 | ▶ | sub describe { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 6 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 6 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 6 | my $recorded = $self->recorded_status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 6 | ▶ | my %describe = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | name => $self->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | class => ref $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | namespace => $self->namespace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | depends_on => [ $self->depends_on ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | ( $self->is_stub ? ( stub_of => ref $self->stub_of ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | ( $recorded ? ( recorded => $recorded->TO_JSON ) : () ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 5 | ▶ | return $self->_resolve_endpoints->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 5 | $describe{endpoints} = [ map { $_->to_crd->TO_JSON } @_ ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 5 | return $self->status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 4 | ▶ | } )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 4 | $describe{status} = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 4 | return Future->done( \%describe ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 5 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 6 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 13 | ▶ | sub endpoint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
endpoint: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 13 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 13 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 13 | ▶ | croak ref($self).'->endpoint needs a name' unless defined $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 8 | ▶ | return $self->_resolve_endpoints->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 8 | my ( $endpoint ) = grep { $_->name eq $name } @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 8 | ▶ | return Future->done($endpoint) if $endpoint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | return Future->fail( ref($self).'->endpoint: '.$self->name.' has no endpoint '.$name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 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;} @_))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 12 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 13 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 243 | ▶ | sub recorded_status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recorded_status: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 243 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 243 | ▶ | return $self->has_crd ? $self->crd->status : $self->_memory_status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | #### Internals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | # A contract method whose result may be a list or one Future of it, as a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | # Future; whatever it dies with becomes the failure. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 698 | ▶ | sub _hook { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hook: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 698 | my ( $self, $method, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 698 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 698 | my @result = $self->$method(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 677 | ▶ | 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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | ? $result[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | : Future->done(@result); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 698 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | # Fails with category manifests, so a broken manifest stays apart from a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # failing request further down the chain. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 247 | ▶ | sub _render { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_render: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 247 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | return $self->_hook('manifests') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 237 | ▶ | ->then( sub { Future->done( $self->_items(@_) ) } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 247 | ▶ | ->else( sub { Future->fail( $_[0], 'manifests' ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 299 | ▶ | sub _items { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_items: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 299 | my ( $self, @manifests ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 299 | return map { $self->_item($_) } @manifests; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | # One manifest, ready to apply -- labelled, namespace set, a copy of what the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | # class returned -- plus what the Comb needs to know about it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 486 | ▶ | sub _item { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_item: called CC=20 SCAR=30.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 486 | my ( $self, $manifest ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 486 | my $class = blessed $manifest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 486 | ▶ | my $data = $class ? $manifest->TO_JSON : $manifest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 486 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | .( ref $manifest || 'a plain scalar' ) unless ref $data eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 485 | my $kind = $data->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 485 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 483 | ▶ | my $name = ref $data->{metadata} eq 'HASH' ? $data->{metadata}{name} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 483 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 481 | my $labels = $self->comb_labels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 480 | my $object = $self->_merged_meta( $data, [], labels => $labels ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 480 | ▶ | $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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 479 | my ( $group ) = $object->{apiVersion} =~ m{\A(.+)/[^/]+\z}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 479 | ▶ | $group //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$group //= ""
MC/DC100%1/1
$group //= ""
$group
Truth table100%2/2
A
A= $group
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 479 | my $templates = $WORKLOAD_TEMPLATES{ $group.'/'.$kind }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 479 | ▶ | $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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 479 | my $namespace = $object->{metadata}{namespace}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 479 | ▶ | $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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | if !( defined $namespace && length $namespace ) && $self->_namespaced( $class, $object ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | # Of the manifest as it stands here: what the class rendered plus what the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | # Comb adds to every one. The annotation itself comes after it, and so does | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | # what deploy carries over from the live object (_restart_kept). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 479 | my $digest = $self->_digest_of( $object, $kind.' '.$name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 477 | $object = $self->_merged_meta( $object, [], annotations => { $self->applied_digest_annotation => $digest } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | manifest => $class ? $class->FROM_HASH($object) : $object, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | data => $object, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | digest => $digest, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | class => $class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | apiVersion => $object->{apiVersion}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | kind => $kind, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | group => $group, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | namespace => $namespace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | resource => $class && $class ne 'IO::K8s::Unstructured' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | ? '+'.$class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 477 | ▶ | : $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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | workload => $templates ? 1 : 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | # A copy of $node with $values merged into metadata.$field (labels, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | # annotations) at $path below it, copying only what it changes. A path that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | # does not exist is left alone. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 1961 | ▶ | sub _merged_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_merged_meta: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 1961 | my ( $self, $node, $path, $field, $values ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 1961 | my %copy = %$node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 1961 | ▶ | if ( my ( $key, @rest ) = @$path ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 680 | ▶ | $copy{$key} = $self->_merged_meta( $copy{$key}, \@rest, $field, $values ) if ref $copy{$key} eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 680 | return \%copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 1281 | ▶ | my %meta = ref $copy{metadata} eq 'HASH' ? %{ $copy{metadata} } : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 1281 | ▶ | $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}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 1281 | $copy{metadata} = \%meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 1281 | return \%copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | # The digest of a manifest, as the annotation holds it. A digest the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # manifest brings along -- rendered from a live object, say -- is left out. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 479 | ▶ | sub _digest_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_digest_of: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 479 | my ( $self, $object, $what ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 479 | my $plain = $self->_digestable( $object, $what ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 477 | my $meta = $plain->{metadata}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 477 | ▶ | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 5 | delete $meta->{annotations}{ $self->applied_digest_annotation }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 5 | ▶ | delete $meta->{annotations} unless %{ $meta->{annotations} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 477 | return 'sha256:'.sha256_hex( $self->_digest_encoder->encode($plain) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | # A copy of the value that encodes the same whatever Perl did to its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | # scalars: a number that was used as a string encodes as a string from then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | # on, and the other way round, and the manifest of a class is read more than | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | # once. So every leaf is a string, but for undef and the JSON booleans (\1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | # and \0 too). Dies on what no manifest holds. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 10667 | ▶ | sub _digestable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_digestable: called CC=13 SCAR=27.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 10667 | my ( $self, $value, $what ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 10667 | ▶ | return $value unless defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 10667 | my $ref = ref $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 10667 | ▶ | return ''.$value unless $ref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 4698 | ▶ | if ( blessed $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 2 | ▶ | return $value ? JSON->true : JSON->false if is_bool($value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | croak ref($self).': manifest '.$what.' cannot be digested: it holds a '.$ref.' object' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | unless $value->can('TO_JSON'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | return $self->_digestable( $value->TO_JSON, $what ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 4696 | ▶ | return { map { ( $_ => $self->_digestable( $value->{$_}, $what ) ) } keys %$value } if $ref eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 479 | ▶ | return [ map { $self->_digestable( $_, $what ) } @$value ] if $ref eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 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/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | if $ref eq 'SCALAR' && defined $$value && $$value =~ /\A[01]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 2 | croak ref($self).': manifest '.$what.' cannot be digested: it holds a '.$ref.' reference'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | # The spec the item renders, {} when it has none. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 194 | ▶ | sub _rendered_spec { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rendered_spec: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 194 | my ( $self, $item ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 194 | my $spec = $item->{data}{spec}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 194 | ▶ | return ref $spec eq 'HASH' ? $spec : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 3 | ▶ | sub _api_version_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_api_version_of: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 3 | my ( $self, $kind ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 3 | my $io = $self->io_k8s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 3 | my $class = eval { my $c = $io->expand_class($kind); $io->load_class($c); $c }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | unless $class && $class->can('api_version'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 2 | return $class->api_version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | # A Kind io_k8s does not know counts as namespaced: the parts of a Comb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | # nearly always are, and the API server drops the namespace of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | # cluster-scoped object anyway. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 491 | ▶ | sub _namespaced { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_namespaced: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 491 | my ( $self, $class, $object ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 491 | ▶ | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 470 | $class = $self->io_k8s->expand_class( $object->{kind}, $object->{apiVersion} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 470 | ▶ | return 1 unless defined $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 469 | $self->io_k8s->load_class($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 490 | ▶ | return $class->does('IO::K8s::Role::Namespaced') ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | # Sequentially, so a Namespace or a CRD comes before what needs it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 161 | ▶ | sub _apply { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_apply: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 161 | my ( $self, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 161 | my @applied; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 1 | ▶ | return $self->_keep_restarts(@items)->else( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 1 | Future->fail( 'reading the live workloads failed: '.$self->_message( $_[0] ), deploy => { applied => [] } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 160 | ▶ | } )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 160 | my @kept = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 256 | ▶ | return ( fmap_void { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 256 | my ( $item ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | $self->k8s->ensure( $item->{manifest} )->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 253 | ▶ | sub { push @applied, $_[0]; Future->done }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 3 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | Future->fail( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 'ensure '.$item->{kind}.' '.$item->{name}.': '.$_[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | deploy => { applied => [@applied], failed => $item->{manifest} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 256 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 160 | ▶ | } foreach => \@kept, concurrent => 1 )->then( sub { Future->done(@applied) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 161 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | # Future of the items, each Deployment, StatefulSet and DaemonSet with the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | # restart annotation of its live Pod template: ensure replaces the object, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | # and without it the Pods would roll once more -- or a rolling restart would | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | # be undone. Reads the live objects the items do not have yet. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 161 | ▶ | sub _keep_restarts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_keep_restarts: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 161 | my ( $self, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 161 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 161 | ▶ | 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'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 160 | ▶ | return ( @unread ? $self->_fetch_live(@unread) : Future->done )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 160 | Future->done( map { $self->_restart_kept($_) } @items ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 161 | ▶ | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 161 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 258 | ▶ | sub _restart_kept { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_restart_kept: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 258 | my ( $self, $item ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 258 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 33 | my $template = $item->{live}->TO_JSON->{spec}{template}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 33 | ▶ | my $meta = ref $template eq 'HASH' ? $template->{metadata} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | my $at = ref $meta eq 'HASH' && ref $meta->{annotations} eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 33 | ▶ | ? $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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 33 | ▶ | return $item unless defined $at; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 5 | my $data = $self->_merged_meta( $item->{data}, [qw( spec template )], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | annotations => { $self->restart_annotation => $at } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 5 | ▶ | return { %$item, data => $data, manifest => $item->{class} ? $item->{class}->FROM_HASH($data) : $data }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | # What status says of a Comb that runs its own resources. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 51 | ▶ | sub _local_status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_local_status: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 51 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 51 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 51 | ▶ | $self->_render->then( sub { $self->_observe_local(@_) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 51 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | # Future of what status says of the rendered @items; each item gets its live | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | # object (or undef) in $item->{live}. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 186 | ▶ | sub _observe_local { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_observe_local: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 186 | my ( $self, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 186 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 186 | ▶ | return Future->done( $self->_status_of( \@items, [] ) ) unless @items; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 174 | ▶ | return $self->_fetch_live(@items)->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | return Future->done( $self->_status_of( \@items, [] ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 174 | ▶ | 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'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 99 | ▶ | return $self->_pods->then( sub { Future->done( $self->_status_of( \@items, [@_] ) ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 182 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 186 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | # What status says of a Comb that borrows from $upstream. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 10 | ▶ | sub _borrowed_status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_borrowed_status: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 10 | my ( $self, $upstream ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 10 | ▶ | return $self->_observe_upstream($upstream)->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 10 | my ( $o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 10 | my %upstream = ( upstream => $self->_upstream_record($o) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 10 | ▶ | if ( my $stop = $o->{stop} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 2 | my ( $phase, $reason, $message ) = @$stop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | return Future->done( { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 2 | %{ $self->_verdict( $phase, [ { severity => 'error', reason => $reason, message => $message } ], [] ) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | %upstream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 8 | my @items = @{ $o->{items} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 8 | ▶ | return $self->_fetch_live(@items)->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | my @problems = map { +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | severity => 'pending', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | reason => 'ResourcesMissing', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 1 | message => $_->{kind}.' '.$_->{name}.' is missing' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 8 | } } grep { !$_->{live} } @items; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 8 | my ( $phase, $reason, $message ) = $self->_borrowed_verdict($o); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 8 | ▶ | push @problems, { severity => 'pending', reason => $reason, message => $message } if $phase ne 'Running'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | $phase = !@problems ? 'Running' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | : 'Pending'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 8 | return Future->done( { %{ $self->_verdict( $phase, \@problems, [] ) }, %upstream } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 8 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 10 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | # Puts the live object (or undef) of every item into $item->{live}: one list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | # per resource and namespace, by label, so a missing object is an empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | # answer rather than an error to tell apart from others. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 225 | ▶ | sub _fetch_live { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fetch_live: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 225 | my ( $self, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 225 | my %groups; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 225 | ▶ | push @{ $groups{ $_->{resource} }{ $_->{namespace} // '' } }, $_ for @items; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_->{"namespace"} // ""
MC/DC100%1/1
$_->{"namespace"} // ""
$_->{"namespace"}
Truth table100%2/2
A
A= $_->{"namespace"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | return Future->needs_all( map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 225 | my $resource = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 362 | my ( $namespace, $members ) = ( $_, $groups{$resource}{$_} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | # By the name label alone: a same-named Comb of another namespace that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | # renders the same resource may have applied it last, and requiring | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | # the namespace label here would make both deploy it every step. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | $self->k8s->list( $resource, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | ( length $namespace ? ( namespace => $namespace ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | labelSelector => $self->comb_label.'='.$self->name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 348 | ▶ | )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 348 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 348 | $_->{live} = $live{ $_->{name} } for @$members; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 348 | return Future->done; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 362 | ▶ | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 362 | } sort keys %{ $groups{$resource} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | } sort keys %groups ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 105 | ▶ | sub _pods { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pods: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 105 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | return $self->k8s->list( 'v1/Pod', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | namespace => $self->namespace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | labelSelector => $self->label_selector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 104 | ▶ | )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 104 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 105 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 178 | ▶ | sub _status_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_status_of: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 178 | my ( $self, $items, $pods ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 178 | my ( @pods, @problems ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 178 | for my $pod (@$pods) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 21 | my ( $state, $problem ) = $self->_pod_state($pod); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 21 | push @pods, $state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 21 | ▶ | push @problems, $problem if $problem; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 178 | ▶ | return $self->_verdict( Running => [], \@pods ) unless @$items; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | return $self->_verdict( NotDeployed => [ { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | severity => 'pending', reason => 'NotDeployed', message => 'not deployed' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 174 | ▶ | } ], \@pods ) unless grep { $_->{live} } @$items; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 115 | ▶ | return $self->_verdict( Stopped => [ { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | severity => 'pending', reason => 'Stopped', message => 'stopped' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | } ], \@pods ) if $self->_stopped($items); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | unshift @problems, map { +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | severity => 'pending', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | reason => 'ResourcesMissing', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 8 | message => $_->{kind}.' '.$_->{name}.' is missing' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 109 | } } grep { !$_->{live} } @$items; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 109 | ▶ | 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'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 109 | ▶ | my $phase = ( grep { $_->{severity} eq 'error' } @problems ) ? 'Error' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | : @problems ? 'Pending' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | : 'Running'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 109 | return $self->_verdict( $phase, \@problems, \@pods ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 188 | ▶ | sub _verdict { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_verdict: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 188 | my ( $self, $phase, $problems, $pods ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 188 | my ( $first ) = ( ( grep { $_->{severity} eq 'error' } @$problems ), @$problems ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | phase => $phase, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | healthy => $phase eq 'Running' ? JSON->true : JSON->false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | ( $first ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | reason => $first->{reason}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 188 | ▶ | message => join( '; ', map { $_->{message} } @$problems ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | pods => $pods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | # What L</stop> leaves: every Deployment/StatefulSet at 0, every CronJob | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | # suspended -- at least one of them against its manifest. The workloads stop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | # does not bring to rest (a DaemonSet, a ReplicaSet, a bare Pod) do not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | # count either way, its Jobs it deletes. A manifest that says 0 or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | # suspended itself is at rest as rendered, not stopped. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 115 | ▶ | sub _stopped { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stopped: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 115 | my ( $self, $items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 115 | my $against = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 115 | for my $item ( grep { $_->{live} } @$items ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 153 | ▶ | my $field = $STOPPABLE{ $item->{group}.'/'.$item->{kind} } or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 99 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 99 | my $want = $self->_rendered_spec($item); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 99 | ▶ | if ( $field eq 'suspend' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 4 | ▶ | return 0 unless $live->{suspend}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 3 | ▶ | $against++ unless $want->{suspend}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 95 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 30 | ▶ | return $against ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 125 | ▶ | sub _workload_problem { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_workload_problem: called CC=24 SCAR=32.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 125 | my ( $self, $item ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 125 | my $live = $item->{live}->TO_JSON; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 125 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 125 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 125 | my $what = $item->{kind}.' '.$item->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 125 | my $key = $item->{group}.'/'.$item->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 125 | ▶ | if ( $key eq 'batch/Job' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 12 | my %true = map { ( $_->{type} => $_ ) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 17 | ▶ | if ( my $failed = $true{Failed} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | severity => 'error', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | reason => $failed->{reason} // 'JobFailed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 5 | return { severity => 'pending', reason => 'JobNotComplete', message => $what.' has not completed' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 108 | my ( $ready, $desired, $scaled_down ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 108 | ▶ | if ( $key eq 'apps/DaemonSet' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | elsif ( $REPLICATED{$key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | # Scaled below what the manifest says -- deploy sets that, default 1 -- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | # by stop or by hand is short of replicas; scaled beyond it (by hand, an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | # autoscaler), the scale counts. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 95 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 95 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 95 | ▶ | $scaled_down = $scaled < $wanted ? $scaled : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 95 | ▶ | ( $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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 7 | return; # a bare Pod speaks for itself, a CronJob has nothing to wait for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 101 | ▶ | return if $ready >= $desired; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 28 | ▶ | severity => 'pending', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | reason => 'ReplicasNotReady', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | message => $what.': '.$ready.' of '.$desired.' ready' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | .( defined $scaled_down ? ' (scaled to '.$scaled_down.')' : '' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | # The public view of a Pod, and the problem it is for the Comb, if any. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 21 | ▶ | sub _pod_state { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pod_state: called CC=43 SCAR=39.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 21 | my ( $self, $pod ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 21 | my $data = $pod->TO_JSON; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 21 | my $restarts = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | my %state = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | name => $data->{metadata}{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 21 | ▶ | phase => $phase, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | ready => $ready ? JSON->true : JSON->false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | restarts => $restarts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 12 | my ( $severity, $reason, $message ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | my ( $container ) = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | } @all; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | my ( $unscheduled ) = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 12 | ▶ | } @{ $status->{conditions} // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$status->{"conditions"} // []
MC/DC100%1/1
$status->{"conditions"} // []
$status->{"conditions"}
Truth table100%2/2
A
A= $status->{"conditions"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 12 | ▶ | if ( $phase eq 'Failed' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 3 | ▶ | my $terminated = $container ? $container->{state}{terminated} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | elsif ($unscheduled) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 5 | $message = $waiting->{message}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 5 | ▶ | $severity = $FAILURE_REASONS{$reason} ? 'error' : 'pending'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | elsif ($container) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 1 | my $terminated = $container->{state}{terminated}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | elsif ( $phase eq 'Unknown' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 2 | ▶ | ( $severity, $reason ) = ( 'pending', $phase eq 'Pending' ? 'Pending' : 'ContainersNotReady' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 12 | $state{reason} = $reason; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 12 | ▶ | $state{message} = $message if defined $message; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 12 | ▶ | return \%state unless $severity; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | return ( \%state, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | severity => $severity, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | reason => $reason, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | .( defined $message && length $message ? ': '.$message : '' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | .( $restarts ? ' ('.$restarts.' restarts)' : '' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 3 | ▶ | sub _exit_message { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exit_message: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 3 | my ( $self, $terminated ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | return 'exit code '.( $terminated->{exitCode} // '?' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 6 | ▶ | sub _log_streams { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_log_streams: called CC=10 SCAR=23.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 6 | my ( $self, $pod ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 6 | my $data = $pod->TO_JSON; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 6 | my $name = $data->{metadata}{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 6 | ▶ | my %status = map { ( $_->{name} => $_ ) } @{ $data->{status}{containerStatuses} // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$data->{"status"}{"containerStatuses"} // []
MC/DC0%0/1
$data->{"status"}{"containerStatuses"} // []
$data->{"status"}{"containerStatuses"}
Truth table50%1/2
A
A= $data->{"status"}{"containerStatuses"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 6 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 6 | ▶ | 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= $status{$_}B= $status{$_}{"state"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 8 | ▶ | my $previous = $waiting && ( $waiting->{reason} // '' ) eq 'CrashLoopBackOff' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 8 | ▶ | pod => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | container => $_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | previous => $previous, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | label => $name.( @containers > 1 ? '/'.$_ : '' ).( $previous ? ' (previous)' : '' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | } @containers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 8 | ▶ | sub _log_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_log_text: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 8 | my ( $self, $stream, $lines ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | return $self->k8s->log( 'v1/Pod', $stream->{pod}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | namespace => $self->namespace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | container => $stream->{container}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | ( $stream->{previous} ? ( previous => 1 ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | tailLines => $lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | )->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 7 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 7 | ▶ | my $text = $_[0] // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0] // ""
MC/DC0%0/1
$_[0] // ""
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 7 | ▶ | $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/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 7 | return Future->done($text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 1 | ▶ | sub { Future->done( '(no log: '.( $_[0] =~ s/\s+\z//r ).")\n" ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 8 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | # Lists each resource of the Comb by label, runs the action on every object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | # found; Future of the list of what it touched, as Kind/name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 14 | ▶ | sub _each_workload { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_each_workload: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 14 | my ( $self, @actions ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | return Future->needs_all( map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 14 | my ( $resource, $action ) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | $self->k8s->list( $resource, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | namespace => $self->namespace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | labelSelector => $self->label_selector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 52 | ▶ | )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | return Future->needs_all( map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 52 | my $object = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 28 | ▶ | $action->($object)->then( sub { Future->done( $object->kind.'/'.$object->metadata->name ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | } @objects ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 56 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | } @actions ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | # Background: without a propagationPolicy the API server orphans the Pods of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | # a deleted batch/v1 Job. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 14 | ▶ | sub _delete_job { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_delete_job: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 14 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 14 | ▶ | return sub { $self->k8s->delete( $_[0], propagationPolicy => 'Background' ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | # The endpoints as they are reached now: the local ones, or with an active | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | # upstream the redirected ones -- failing with the reason when there are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | # none. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 18 | ▶ | sub _resolve_endpoints { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_endpoints: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 18 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 18 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 18 | ▶ | $self->_resolve_upstream->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 18 | my ( $upstream ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 18 | ▶ | return Future->done( $self->_local_endpoints ) unless $upstream; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 6 | ▶ | return $self->_observe_upstream($upstream)->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 6 | my ( $o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 6 | ▶ | return $o->{endpoints} ? Future->done( @{ $o->{endpoints} } ) : Future->fail( $o->{stop}[2] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 6 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 18 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 18 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 168 | ▶ | sub _local_endpoints { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_local_endpoints: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 168 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 168 | return map { $self->_local_endpoint($_) } $self->_declared_endpoints; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 44 | ▶ | sub _local_endpoint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_local_endpoint: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 44 | my ( $self, $declared ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | return $self->endpoint_class->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | name => $declared->{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | port => $declared->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | ( defined $declared->{protocol} ? ( protocol => $declared->{protocol} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | cluster => $declared->{cluster} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | // ( $declared->{service} // $self->name ).'.'.$self->namespace.'.svc:'.$declared->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 302 | ▶ | sub _declared_endpoints { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_declared_endpoints: called CC=13 SCAR=27.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 302 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 302 | my ( @declared, %seen ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 302 | for my $endpoint ( $self->endpoints ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 207 | my %declared; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 8 | ▶ | %declared = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | name => $endpoint->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | port => $endpoint->port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | protocol => $endpoint->protocol, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | ( $endpoint->has_cluster ? ( cluster => $endpoint->cluster ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | ( $endpoint->has_external ? ( external => $endpoint->external ) : () ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | elsif ( ref $endpoint eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 199 | %declared = %$endpoint; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 199 | my @unknown = sort grep { !$ENDPOINT_KEYS{$_} } keys %declared; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 199 | ▶ | croak ref($self).'->endpoints: unknown key(s) '.join( ', ', @unknown ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | .' (known: '.join( ', ', sort keys %ENDPOINT_KEYS ).')' if @unknown; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | .( ref $endpoint || 'a plain scalar' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | croak ref($self).'->endpoints: an endpoint has no name' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 205 | my $problem = $self->endpoint_class->name_problem( $declared{name} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 205 | ▶ | croak ref($self).'->endpoints: '.$problem if defined $problem; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | croak ref($self).'->endpoints: endpoint '.$declared{name}.' is declared twice' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 203 | ▶ | if $seen{ $declared{name} }++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 203 | push @declared, \%declared; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 298 | return @declared; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 22 | ▶ | sub _endpoint_names { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_endpoint_names: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 22 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 22 | return map { $_->{name} } $self->_declared_endpoints; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | #### Upstream and bridge internals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | # The upstream path up to the bridge, shared by reconcile, status and the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | # endpoints: Future of { upstream, seen (what its status said), via, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | # endpoints (redirected), items (the bridge, ready to apply) } as far as it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | # got, and where it cannot go on stop => [ phase, reason, message ]. Never | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | # fails. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 68 | ▶ | sub _observe_upstream { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_observe_upstream: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 68 | my ( $self, $upstream ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 68 | my %o = ( upstream => $upstream ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 27 | ▶ | my $stop = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 27 | my ( $phase, $reason, $message ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 27 | return Future->fail( $message, stop => $phase, $reason ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 68 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 68 | ▶ | return $self->_hook( sub { $upstream->status( $_[0] ) } )->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 66 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 66 | my ( $seen ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | .( ref $seen || 'a plain scalar' ).', not a hashref' ) unless ref $seen eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 65 | $o{seen} = $seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 65 | ▶ | return $stop->( Error => UpstreamFailed => ref($upstream).'->status answered a via that is no arrayref' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | unless ref $via eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | # A chain longer than that is taken for a loop, recorded cut to that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | # length: a loop then records the same via every step, not a growing one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 64 | my @via = @$via; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 64 | my $max = $self->max_upstream_depth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 64 | my $loop = @via > $max; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 64 | ▶ | splice @via, $max if $loop; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 64 | $o{via} = \@via; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 64 | my $label = $self->_upstream_label( \%o ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | return $stop->( Blocked => UpstreamUnreachable => $label.' is unreachable'.$self->_upstream_says( $seen, ': ' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 64 | ▶ | unless $seen->{reachable}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 60 | ▶ | return $stop->( Blocked => UpstreamLoop => $label.' leads through more than '.$max.' layers, a loop? via ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | .join( ', ', @via ) ) if $loop; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 7 | ▶ | return $self->_hook( sub { $upstream->endpoints( $_[0] ) } )->else( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 47 | $stop->( Error => UpstreamFailed => 'reading the endpoints of '.$label.' failed: '.$self->_message( $_[0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 53 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 2 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 2 | $stop->( Error => UpstreamFailed => 'reading the status of '.ref($upstream).' failed: '.$self->_message( $_[0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 52 | ▶ | )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 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')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 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]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | .( ref $wrong[0] || 'a plain scalar' ).', not a Kubernetes::Comb::Endpoint' ) if @wrong; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 51 | my ( $redirected, $missing ) = $self->_redirect(@offered); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 51 | ▶ | if (@$missing) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 6 | my $phase = $o{seen}{phase}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | return $stop->( Blocked => UpstreamEndpointsMissing => $self->_upstream_label( \%o ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | .' offers no reachable address for endpoint(s) '.join( ', ', @$missing ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | .( defined $phase && $phase ne 'Running' ? ' (it is '.$phase.')' : '' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 45 | $o{endpoints} = $redirected; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | return $self->_hook( bridge_manifests => @$redirected ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 42 | ▶ | ->then( sub { Future->done( $self->_items(@_) ) } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 4 | ▶ | ->else( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 4 | my ( $error, $category ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | if ( $category // '' ) eq 'bridge'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 2 | return $stop->( Error => BridgeFailed => 'rendering the bridge failed: '.$self->_message($error) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 45 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | } )->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 41 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 41 | $o{items} = [@_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 41 | return Future->done( \%o ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 27 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 27 | my ( $message, $category, $phase, $reason ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | ? [ $phase, $reason, $message ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | : [ Error => UpstreamFailed => 'borrowing from '.ref($upstream).' failed: '.$self->_message($message) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 27 | return Future->done( \%o ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 68 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | # The declared endpoints, each with the address of the upstream's endpoint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | # of that name: ( [ redirected ], [ names the upstream has no address for ] ). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 51 | ▶ | sub _redirect { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_redirect: called CC=11 SCAR=24.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 51 | my ( $self, @offered ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 51 | my %offered = map { ( $_->name => $_ ) } @offered; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 51 | my ( @redirected, @missing ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 51 | for my $declared ( $self->_declared_endpoints ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 50 | my $upstream = $offered{ $declared->{name} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 50 | ▶ | my $address = !$upstream ? undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | : $upstream->has_cluster ? $upstream->cluster | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | : $upstream->has_external ? $upstream->external | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 6 | push @missing, $declared->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | 6 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 44 | my ( $host, $port ) = $self->_split_address($address); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | push @redirected, $self->endpoint_class->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | name => $declared->{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | port => $declared->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 44 | ▶ | ( defined $declared->{protocol} ? ( protocol => $declared->{protocol} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | cluster => $address, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | ( $upstream->has_external ? ( external => $upstream->external ) : () ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 51 | return ( \@redirected, \@missing ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 106 | ▶ | sub _upstream_label { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upstream_label: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 106 | my ( $self, $o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 106 | ▶ | my $context = $o->{seen} ? $o->{seen}{context} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 106 | ▶ | return 'upstream '.ref( $o->{upstream} ).( defined $context ? ' (context '.$context.')' : '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | # The message of the upstream status, as status text behind $glue; else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | # nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 16 | ▶ | sub _upstream_says { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upstream_says: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 16 | my ( $self, $seen, $glue ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 16 | ▶ | return length $message ? $glue.$message : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | # Phase, reason and message of a bridge that is in place: Running when the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | # upstream is, else Pending. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 35 | ▶ | sub _borrowed_verdict { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_borrowed_verdict: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 35 | my ( $self, $o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 35 | my $label = $self->_upstream_label($o); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 35 | my $phase = $o->{seen}{phase}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | return ( Running => Borrowed => 'borrowed from '.$label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | if defined $phase && $phase eq 'Running'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | return ( Pending => UpstreamNotRunning => $label.' is '.( defined $phase ? $phase : 'in no known phase' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 6 | ▶ | .$self->_upstream_says( $o->{seen}, ': ' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | # status.upstream as far as the upstream answered. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 62 | ▶ | sub _upstream_record { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upstream_record: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 62 | my ( $self, $o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | class => ref $o->{upstream}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | ( defined $seen->{context} ? ( context => ''.$seen->{context} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | ( exists $seen->{reachable} ? ( reachable => $seen->{reachable} ? JSON->true : JSON->false ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | ( defined $seen->{phase} ? ( phase => ''.$seen->{phase} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 62 | ▶ | ( $o->{via} ? ( via => [ map { ''.$_ } @{ $o->{via} } ] ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | observedAt => $self->_now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | # The bridge of one Service: ( [ manifests ], [ why it cannot be ] ). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 59 | ▶ | sub _bridge_service { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bridge_service: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 59 | my ( $self, $service, @endpoints ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 59 | my ( @targets, @problems ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | 59 | for my $endpoint (@endpoints) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | 68 | ▶ | my $address = $endpoint->has_cluster ? $endpoint->cluster : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 68 | ▶ | my ( $host, $port ) = defined $address ? $self->_split_address($address) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | 2 | ▶ | push @problems, 'endpoint '.$endpoint->name.' has ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | .( defined $address ? 'the address '.$address.', not host:port' : 'no address' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | 66 | my ( $family, $ip ) = $self->_ip_address($host); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | 66 | ▶ | push @targets, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | endpoint => $endpoint, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | host => $family ? $ip : lc $host, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | port => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | family => $family | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 59 | ▶ | return ( [], \@problems ) if @problems; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 57 | my %families = map { ( $_->{family} => 1 ) } @targets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 57 | ▶ | if ( keys %families > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 2 | ▶ | my $what = $families{''} ? 'host names and IP addresses' : 'IPv4 and IPv6 addresses'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | return ( [], [ 'Service '.$service.': its endpoints point at both '.$what.' (' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 2 | .join( ', ', map { $_->{endpoint}->name.' at '.$_->{host} } @targets ).'), one Service cannot bridge both' ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 55 | my @ports = map { +{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | name => $_->{endpoint}->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | port => $_->{endpoint}->port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | protocol => $self->_service_protocol( $_->{endpoint}->protocol ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | 62 | } } @targets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | 55 | ▶ | return $families{''} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | ? $self->_bridge_external_name( $service, \@ports, @targets ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | : $self->_bridge_endpoint_slices( $service, \@ports, @targets ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 48 | ▶ | sub _bridge_external_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bridge_external_name: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 48 | my ( $self, $service, $ports, @targets ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 48 | my @problems; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 48 | my %hosts = map { ( $_->{host} => 1 ) } @targets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | push @problems, 'Service '.$service.': an ExternalName Service points at one host, but its endpoints are at ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 48 | ▶ | .join( ', ', map { $_->{endpoint}->name.' at '.$_->{host} } @targets ) if keys %hosts > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | push @problems, map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | 'Service '.$service.': endpoint '.$_->{endpoint}->name.' is port '.$_->{endpoint}->port.' here but ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 4 | .$_->{port}.' at '.$_->{host}.', and an ExternalName Service cannot map ports' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 48 | } grep { $_->{port} != $_->{endpoint}->port } @targets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 48 | ▶ | return ( [], \@problems ) if @problems; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 43 | my $host = $targets[0]{host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | 43 | ▶ | $host .= '.'.$self->cluster_domain if $host =~ /\.svc\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | return ( [ { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 43 | apiVersion => 'v1', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | kind => 'Service', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | metadata => { name => $service }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | spec => { type => 'ExternalName', externalName => $host, ports => $ports } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | } ], [] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | # A selector-less Service, and one EndpointSlice per address: the endpoints | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | # of a slice serve all its ports. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 7 | ▶ | sub _bridge_endpoint_slices { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bridge_endpoint_slices: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | 7 | my ( $self, $service, $ports, @targets ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | 7 | my $family = $targets[0]{family}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 7 | my ( @addresses, %ports_at ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 7 | for my $target (@targets) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 9 | ▶ | push @addresses, $target->{host} unless $ports_at{ $target->{host} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | 9 | push @{ $ports_at{ $target->{host} } }, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | name => $target->{endpoint}->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | port => $target->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | protocol => $self->_service_protocol( $target->{endpoint}->protocol ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | 7 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | return ( [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | apiVersion => 'v1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | kind => 'Service', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | metadata => { name => $service }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | spec => { ipFamilies => [ $family ], ipFamilyPolicy => 'SingleStack', ports => $ports } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | 7 | map { +{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | apiVersion => 'discovery.k8s.io/v1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | kind => 'EndpointSlice', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | metadata => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | name => $service.'-'.++$n, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | labels => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | 'kubernetes.io/service-name' => $service, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | 'endpointslice.kubernetes.io/managed-by' => $self->managed_by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | addressType => $family, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | 8 | ports => $ports_at{$_}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | endpoints => [ { addresses => [ $_ ] } ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | } } @addresses | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | ], [] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | 71 | ▶ | sub _service_protocol { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_service_protocol: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | 71 | my ( $self, $protocol ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | # host:port, [v6]:port, or either without the port: ( host, port or undef ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | # nothing for what is none of these. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 111 | ▶ | sub _split_address { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_split_address: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | 111 | my ( $self, $address ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 111 | ▶ | return ( $1, $2 ) if $address =~ /\A\[([^\[\]\s]+)\](?::(\d+))?\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | 109 | ▶ | return ( $1, $2 ) if $address =~ /\A([^:\[\]\s]+)(?::(\d+))?\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | 1 | my ( $family ) = $self->_ip_address($address); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | 1 | ▶ | return ( $address, undef ) if $family eq 'IPv6'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | 0 | ▶ | sub _join_address { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_join_address: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | 0 | my ( $self, $host, $port ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | 0 | my ( $family ) = $self->_ip_address($host); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | 0 | ▶ | return ( $family eq 'IPv6' ? '['.$host.']' : $host ).':'.$port; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | # ( IPv4 or IPv6, the address in canonical form ), or ( '' ) for a host name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 67 | ▶ | sub _ip_address { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ip_address: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 67 | my ( $self, $host ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | 67 | for my $family ( [ IPv4 => AF_INET ], [ IPv6 => AF_INET6 ] ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | 124 | my $packed = inet_pton( $family->[1], $host ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 124 | ▶ | return ( $family->[0], inet_ntop( $family->[1], $packed ) ) if defined $packed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | 55 | return (''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | #### Reconcile internals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | # One reconcile step works on $r: previous (the recorded status it started | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | # from), conditions (type => { status, reason, message }), upstream (the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | # resolved one, undef for local; absent while unresolved), then phase, reason | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | # and message, and -- where a step knows them -- managed (resource hashrefs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | # and endpoints (Kubernetes::Comb::Endpoint). established says which path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | # settled what serves: local once the local path is through (healthy, or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | # deployed and pruned), upstream once the upstream path observed its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | # upstream. Each step either finishes $r or hands it to the next; a step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | # whose own work fails finishes it as Error. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | 228 | ▶ | sub _status_class { 'Kubernetes::Comb::CRD::CombStatus' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_status_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | 164 | ▶ | sub _upstream_role { 'Kubernetes::Comb::Role::Upstream' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upstream_role: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 227 | ▶ | sub _finish { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finish: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | 227 | my ( $self, $r, $phase, $reason, $message ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | 227 | @{$r}{qw( phase reason message )} = ( $phase, $reason, $message ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 227 | return Future->done($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | 428 | ▶ | sub _condition { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_condition: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | 428 | my ( $self, $r, $type, $status, $reason, $message ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | 428 | $r->{conditions}{$type} = { status => $status, reason => $reason, message => $message }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | 428 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | # An error as status text: without the trailing whitespace, and without the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | # " at FILE line N." -- or "..., <FH> line N." -- that die and croak append | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | # when the text has no newline of its own. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | 53 | ▶ | sub _message { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_message: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | 53 | my ( $self, $error ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | 53 | ▶ | return 'unknown error' unless defined $error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 53 | return ( ''.$error ) =~ s/\s+\z//r | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | =~ s/\s+at (?:\(eval \d+\)|\S+) line \d+(?:, <[^>]*> (?:line|chunk) \d+)?\.\z//r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | # Step 1, then on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | 225 | ▶ | sub _reconcile_steps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reconcile_steps: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | 225 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | return $self->_resolve_upstream->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 222 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | 222 | ( $r->{upstream} ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 222 | return $self->_reconcile_enabled($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | 3 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | 3 | $self->_finish( $r, Error => UpstreamFailed => 'resolving the upstream failed: '.$self->_message( $_[0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | 225 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | # Steps 2 and 3. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | 222 | ▶ | sub _reconcile_enabled { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reconcile_enabled: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | 222 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | 222 | my $off = $self->_disabled_because; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | 222 | ▶ | return $self->_finish( $r, Disabled => Disabled => $off ) if defined $off; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | return $self->_unmet_dependencies->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | 217 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | 217 | my @unmet = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | 217 | ▶ | unless (@unmet) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | 208 | $self->_condition( $r, DependenciesReady => True => Healthy => 'all dependencies are healthy' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | 208 | return $self->_reconcile_check($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | 9 | my $message = join '; ', map { $_->{message} } @unmet; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | 9 | $self->_condition( $r, DependenciesReady => False => $unmet[0]{reason}, $message ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | 9 | return $self->_finish( $r, Blocked => $unmet[0]{reason}, $message ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | 0 | $self->_finish( $r, Error => DependenciesFailed => 'reading the dependencies failed: '.$self->_message( $_[0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | 217 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 222 | ▶ | sub _disabled_because { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_disabled_because: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | 222 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | 222 | ▶ | my $spec = $self->has_crd ? $self->crd->spec : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | 222 | ▶ | my $enabled = $spec ? $spec->enabled : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | 222 | ▶ | return defined $enabled ? ( $enabled ? undef : 'spec.enabled is false' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | : $self->optional ? ref($self).' is optional and spec.enabled is not set' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | # Future of one { reason, message } per dependency that is not there. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | 217 | ▶ | sub _unmet_dependencies { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unmet_dependencies: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | 217 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | 217 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | 217 | my @refs = $self->depends_on; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | 217 | ▶ | return Future->done unless @refs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | 11 | ▶ | return Future->done( { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | reason => 'NoResolver', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | message => 'depends on '.join( ', ', @refs ).', but there is no resolver to find them' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | } ) unless $self->has_resolver; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | 8 | return Future->needs_all( map { $self->_unmet_dependency($_) } @refs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | 217 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | 9 | ▶ | sub _unmet_dependency { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unmet_dependency: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | 9 | my ( $self, $ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | 9 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | 9 | my $dependency = $self->resolver->( $ref, $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | 7 | ▶ | return Future->done( { reason => 'DependencyNotFound', message => 'dependency '.$ref.' not found' } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | unless defined $dependency; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | reason => 'DependencyInvalid', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | message => 'the resolver returned '.( ref $dependency || 'a plain scalar' ).' for '.$ref.', not a Comb' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | } ) unless blessed $dependency && $dependency->can('healthy'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | return $dependency->healthy->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | 3 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | 3 | ▶ | return Future->done if $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | 1 | return Future->done( { reason => 'DependencyNotReady', message => 'dependency '.$ref.' is not healthy' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | 1 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | 1 | return Future->done( { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | reason => 'DependencyNotReady', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | message => 'dependency '.$ref.' is not healthy: '.$self->_message( $_[0] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | 2 | ▶ | } )->else( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | 2 | Future->done( { reason => 'ResolverFailed', message => 'looking up '.$ref.' failed: '.$self->_message( $_[0] ) } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | 9 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | # Step 4, then the path. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | 208 | ▶ | sub _reconcile_check { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reconcile_check: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | 208 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | return $self->_hook('check')->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | 200 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | 200 | my @missing = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | 200 | ▶ | if (@missing) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | 7 | my $message = 'missing: '.join( '; ', @missing ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | 7 | $self->_condition( $r, ConfigReady => False => MissingPrerequisites => $message ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | 7 | return $self->_finish( $r, NeedsConfig => MissingPrerequisites => $message ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | 193 | $self->_condition( $r, ConfigReady => True => Complete => 'nothing missing' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | 193 | ▶ | return defined $r->{upstream} ? $self->_reconcile_upstream($r) : $self->_reconcile_local($r); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | 8 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | 8 | my $message = 'check failed: '.$self->_message( $_[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | 8 | $self->_condition( $r, ConfigReady => Unknown => CheckFailed => $message ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | 8 | return $self->_finish( $r, Error => CheckFailed => $message ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | 208 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | # Step 5a. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | 141 | ▶ | sub _reconcile_local { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reconcile_local: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | 141 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | # After borrowing, the bridge may stand where the local resources belong, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | # and look healthy: deploy anyway. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | 141 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | return $self->_render->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | 136 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | 136 | my @items = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | return $self->_observe_local(@items)->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | 132 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | 132 | my ( $live ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | 132 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | 54 | my @changed = $self->_changed_items(@items); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | 54 | ▶ | return $self->_deploy_changed( $r, \@changed, @items ) if @changed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | 47 | ▶ | return $self->_settle_record( $r, @items ) if $self->_record_differs( $r, @items ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | 42 | $r->{established} = 'local'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | 42 | return $self->_finish( $r, Running => Healthy => 'healthy' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | 4 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | 4 | $self->_finish( $r, Error => StatusFailed => 'reading the live status failed: '.$self->_message( $_[0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | 136 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | 5 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | 5 | $self->_finish( $r, Error => ManifestsFailed => 'rendering the manifests failed: '.$self->_message( $_[0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | 141 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | # Whether the rendered items and the recorded managedResources name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | # different resources (by group, kind, namespace, name): something to prune | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | # -- dropped from the manifests, or a delete that failed -- or something | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | # that runs but is not recorded. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | 47 | ▶ | sub _record_differs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_record_differs: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | 47 | my ( $self, $r, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | 47 | my %recorded = map { ( $self->_resource_key($_) => 1 ) } $self->_previous_resources($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | 47 | my %rendered = map { ( $self->_resource_key( $self->_resource_of($_) ) => 1 ) } @items; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | 47 | ▶ | return 1 if keys %recorded != keys %rendered; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | 42 | ▶ | return grep( { !$recorded{$_} } keys %rendered ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | # The items whose live object was applied from another manifest than the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | # one rendered now, or from one without a digest. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | 54 | ▶ | sub _changed_items { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_changed_items: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | 54 | my ( $self, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | return grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | 54 | $self->_digest_counts($_) && ( $self->_live_digest($_) // '' ) ne $_->{digest} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | 95 | ▶ | } @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($_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | 84 | ▶ | sub _live_digest { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_live_digest: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | 84 | my ( $self, $item ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | 84 | my $annotations = $item->{live}->metadata->annotations; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | 84 | ▶ | return ref $annotations eq 'HASH' ? $annotations->{ $self->applied_digest_annotation } : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | # Whether the digest of the live object says what this Comb applied. Not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | # where another deploy would not change it, or reconcile would deploy every | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | # step: what the client leaves as it is, and what a same-named Comb of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | # another namespace applied last (see _fetch_live) -- its labels, and so its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | # digest, are that Comb's. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | 95 | ▶ | sub _digest_counts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_digest_counts: called CC=6 SCAR=18.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | 95 | my ( $self, $item ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | 95 | ▶ | my $live = $item->{live} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | 95 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | 95 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | 93 | ▶ | return $self->_kept_by_ensure($item) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | # What ensure of Kubernetes::REST and Net::Async::Kubernetes returns as it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | # found it: a core/v1 PersistentVolumeClaim, and a batch/v1 Job that runs or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | # has succeeded. Any other Job it replaces. By the exact apiVersion, as they | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | # tell. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | 93 | ▶ | sub _kept_by_ensure { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_kept_by_ensure: called CC=6 SCAR=19.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | 93 | my ( $self, $item ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | 93 | my $resource = $item->{apiVersion}.'/'.$item->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | 93 | ▶ | return 1 if $resource eq 'v1/PersistentVolumeClaim'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | 84 | ▶ | return 0 unless $resource eq 'batch/v1/Job'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | 9 | my $status = $item->{live}->TO_JSON->{status}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | # A healthy Comb that renders something else than it applied: deploy and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | # prune. What is live and healthy is what was rendered before, so whether | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | # the Comb is Running is for the next step to see. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | 7 | ▶ | sub _deploy_changed { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_deploy_changed: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | 7 | my ( $self, $r, $changed, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | 7 | my ( @differ, @without ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | 7 | ▶ | push @{ defined $self->_live_digest($_) ? \@differ : \@without }, $_->{kind}.' '.$_->{name} for @$changed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | 7 | ▶ | return $self->_deploy_pending( $r, join( '; ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | ( @differ ? 'rendered differently now: '.join( ', ', @differ ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | ( @without ? 'applied without a digest: '.join( ', ', @without ) : () ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | ), @items ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | # A healthy Comb whose record differs: deploy and prune all the same, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | # the debt is paid while it runs. Everything rendered was live and healthy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | # before, and applied as rendered, so it stays Running. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | 5 | ▶ | sub _settle_record { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_settle_record: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | 5 | my ( $self, $r, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | 5 | ▶ | return $self->_apply_and_prune( $r, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | 5 | $r->{established} = 'local'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | 5 | $self->_finish( $r, Running => Healthy => join '; ', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | 'healthy', 'the record differed from the manifests: applied '.scalar(@items).' resource(s)', @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | 5 | }, @items ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | # Step 5b, the upstream path: upstream status and endpoints, replicate_into, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | # the bridge; it fills phase, managed, endpoints and upstream_status of $r. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | 52 | ▶ | sub _reconcile_upstream { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reconcile_upstream: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | 52 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | 52 | my $upstream = $r->{upstream}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | 52 | ▶ | return $self->_observe_upstream($upstream)->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | 52 | my ( $o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | 52 | $r->{established} = 'upstream'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | 52 | $r->{upstream_status} = $self->_upstream_record($o); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | 52 | ▶ | $r->{endpoints} = $o->{endpoints} if $o->{endpoints}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | 52 | ▶ | return $self->_finish( $r, @{ $o->{stop} } ) if $o->{stop}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | my $replicated = $upstream->can('replicate_into') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | 2 | ▶ | ? $self->_hook( sub { $upstream->replicate_into( $_[0] ) } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | 29 | ▶ | : Future->done; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | return $replicated->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | 28 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | 27 | ▶ | $self->_apply_and_prune( $r, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | 27 | my ( $phase, $reason, $message ) = $self->_borrowed_verdict($o); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | 27 | return $self->_finish( $r, $phase, $reason, join '; ', $message, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | 28 | }, @{ $o->{items} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | 1 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | 1 | $self->_finish( $r, Error => ReplicationFailed => 'replicating from '.$self->_upstream_label($o) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | .' failed: '.$self->_message( $_[0] ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | 29 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | 52 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | 78 | ▶ | sub _deploy_and_prune { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_deploy_and_prune: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | 78 | my ( $self, $r, $live, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | my $state = $live->{healthy} ? 'in place of the bridge' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | 78 | ▶ | : '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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | 78 | return $self->_deploy_pending( $r, $state, @items ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | # Deploy and prune, then Pending, the message saying why it deployed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | 85 | ▶ | sub _deploy_pending { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_deploy_pending: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | 85 | my ( $self, $r, $why, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | 84 | ▶ | return $self->_apply_and_prune( $r, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | 84 | $r->{established} = 'local'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | 84 | $self->_finish( $r, Pending => Deployed => join '; ', 'applied '.scalar(@items).' resource(s), '.$why, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | 85 | }, @items ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | # Applies the items, then prunes what the record has and they do not; sets | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | # managed of $r. $done gets the notes of the pruning and finishes $r; a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | # failed apply finishes it as Error. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | 118 | ▶ | sub _apply_and_prune { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_apply_and_prune: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | 118 | my ( $self, $r, $done, @items ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | 118 | my @previous = $self->_previous_resources($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | 118 | my @desired = map { $self->_resource_of($_) } @items; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | return $self->_apply(@items)->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | 116 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | 116 | my %desired = map { ( $self->_resource_key($_) => 1 ) } @desired; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | 85 | ▶ | return $self->_prune( grep { !$desired{ $self->_resource_key($_) } } @previous )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | 116 | my @pruned = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | 116 | $r->{managed} = $self->_union( \@desired, [ map { $_->{resource} } grep { $_->{keep} } @pruned ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | 116 | ▶ | return $done->( map { $_->{note} // () } @pruned ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$_->{"note"} // ()
MC/DC0%0/2
$_->{"note"} // ()
$_->{"note"}
()
Truth table66%2/3
A // B
A= $_->{"note"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | 116 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | 2 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | 2 | my ( $error, $category, $details ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | # _apply goes one after the other: what it applied are the first items | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | my $applied = ( $category // '' ) eq 'deploy' && ref $details eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | 2 | $r->{managed} = $self->_union( [ @desired[ 0 .. $applied - 1 ] ], \@previous ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | 2 | return $self->_finish( $r, Error => DeployFailed => 'deploy failed: '.$self->_message($error) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | 118 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | 273 | ▶ | sub _previous_resources { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_previous_resources: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | 273 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | 273 | ▶ | my $recorded = $r->{previous} ? $r->{previous}->managedResources : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | return map { +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | 267 | ▶ | apiVersion => $_->apiVersion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | kind => $_->kind, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | ( defined $_->namespace ? ( namespace => $_->namespace ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | name => $_->name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | 273 | ▶ | } } @{ $recorded // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$recorded // []
MC/DC100%1/1
$recorded // []
$recorded
Truth table100%2/2
A
A= $recorded
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | 248 | ▶ | sub _resource_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resource_of: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | 248 | my ( $self, $item ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | apiVersion => $item->{apiVersion}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | kind => $item->{kind}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | ( defined $item->{namespace} ? ( namespace => $item->{namespace} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | name => $item->{name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | 248 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | # Identity of a resource across API versions: group, kind, namespace, name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | 582 | ▶ | sub _resource_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resource_key: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | 582 | my ( $self, $resource ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | 582 | my ( $group ) = $resource->{apiVersion} =~ m{\A(.+)/[^/]+\z}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | 582 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | # The lists joined, the first of each identity kept. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | 118 | ▶ | sub _union { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_union: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | 118 | my ( $self, @lists ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | 118 | my ( %seen, @union ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | 118 | for my $resource ( map { @$_ } @lists ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | 168 | ▶ | push @union, $resource unless $seen{ $self->_resource_key($resource) }++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | 118 | return \@union; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | # Future of { resource, keep, note } per orphan; never fails. A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | # cluster-scoped orphan is left in place. An orphan that still carries the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | # Comb labels is deleted, with propagationPolicy Background: what it owns -- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | # the Pods of a Job, the ReplicaSets of a Deployment -- goes with it. One | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | # that does not carry them is gone or no longer this Comb's -- not ours to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | # delete either way. A failed check or delete keeps it for the next step. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | 116 | ▶ | sub _prune { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prune: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | 116 | my ( $self, @orphans ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | 116 | my ( @left, %groups ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | 116 | for my $orphan (@orphans) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | 24 | ▶ | if ( $self->_cluster_scoped($orphan) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | push @left, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | resource => $orphan, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | keep => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | 4 | note => 'left '.$orphan->{kind}.' '.$orphan->{name}.' in place: cluster-scoped, never pruned automatically' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | 4 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | 20 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | 116 | ▶ | return Future->done(@left) unless %groups; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | return Future->needs_all( map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | 19 | my $resource = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | 19 | my ( $namespace, $members ) = ( $_, $groups{$resource}{$_} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | $self->k8s->list( $resource, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | ( length $namespace ? ( namespace => $namespace ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | labelSelector => $self->label_selector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | )->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | 18 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | 18 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | 18 | return Future->needs_all( map { $self->_prune_one( $resource, $_, $live{ $_->{name} } ) } @$members ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | 1 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | 1 | my $error = $self->_message( $_[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | 1 | return Future->done( map { +{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | resource => $_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | keep => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | 1 | note => 'could not check '.$_->{kind}.' '.$_->{name}.' for pruning: '.$error | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | } } @$members ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | 19 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | 19 | } sort keys %{ $groups{$resource} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | 19 | ▶ | } sort keys %groups )->then( sub { Future->done( @left, @_ ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | # Cluster-scoped: a Namespace takes everything in it along, a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | # CustomResourceDefinition every object of its kind, and a same-named Comb of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | # another namespace may render it too. Recorded without a namespace means it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | # was applied as one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | 24 | ▶ | sub _cluster_scoped { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cluster_scoped: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | 24 | my ( $self, $resource ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | 24 | ▶ | return 1 unless defined $resource->{namespace}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | 21 | ▶ | return $self->_namespaced( undef, $resource ) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | 19 | ▶ | sub _prune_one { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prune_one: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | 19 | my ( $self, $resource, $orphan, $live ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | 19 | my $what = $orphan->{kind}.' '.$orphan->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | return $self->k8s->delete( $live, propagationPolicy => 'Background' )->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | 13 | ▶ | sub { Future->done( { resource => $orphan, keep => 0 } ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | 2 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | 2 | Future->done( { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | resource => $orphan, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | keep => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | note => 'deleting '.$what.' failed: '.$self->_message( $_[0] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | 19 | ▶ | ) if $live; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | return $self->k8s->get( $resource, $orphan->{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | ( defined $orphan->{namespace} ? ( namespace => $orphan->{namespace} ) : () ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | )->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | 3 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | 3 | Future->done( { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | resource => $orphan, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | keep => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | note => 'left '.$what.' alone: it no longer carries '.$self->label_selector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | 1 | ▶ | sub { Future->done( { resource => $orphan, keep => 0 } ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | 4 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | # Step 1: Future of the upstream object, or of nothing for local. The first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | # source that exists decides. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | 334 | ▶ | sub _resolve_upstream { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_upstream: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | 334 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | 334 | ▶ | return Future->call( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | 334 | ▶ | if ( $self->_has_upstream ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | 91 | my $given = $self->_upstream; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | 69 | ▶ | return $self->_hook($given)->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | 69 | Future->done( $self->_upstream_from( 'the upstream coderef', @_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | 91 | ▶ | } ) if ref $given eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | 19 | ▶ | return Future->done( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | $self->_upstream_from( 'the upstream argument', ref $given eq 'ARRAY' ? @$given : $given ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | 243 | ▶ | my $spec = $self->has_crd ? $self->crd->spec : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | 243 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | if $spec && $spec->has_upstream; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | 3 | ▶ | return $self->_hook('upstream')->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | 3 | Future->done( $self->_upstream_from( ref($self).'->upstream', @_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | 221 | ▶ | } ) if $self->can('upstream'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | 218 | return Future->done; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | 334 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | # One answer: nothing (local), an upstream object, a hashref as in the custom | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | # resource, or Name => (%args) / '+Full::Class' => (%args). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | 113 | ▶ | sub _upstream_from { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upstream_from: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | 113 | my ( $self, $source, @answer ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | 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]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | 95 | my ( $first, @args ) = @answer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | 95 | ▶ | if ( ref $first ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | 39 | ▶ | croak $source.': one upstream object or hashref, not a list of '.scalar(@answer) if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | 38 | ▶ | return $self->_checked_upstream( $source, $first ) if blessed $first; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | 25 | ▶ | croak $source.': expected nothing, an upstream object, a hashref or Name => (...), got a ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | .ref($first).' reference' unless ref $first eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | 23 | my %spec = %$first; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | 23 | my $class = delete $spec{class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | 22 | return $self->_build_upstream( $source, $class, %spec ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | 56 | ▶ | croak $source.': expected nothing, an upstream object, a hashref or Name => (...), got a list starting with undef' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | unless defined $first; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | 56 | ▶ | croak $source.': '.$first.' => (...) needs key/value pairs' if @args % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | 55 | return $self->_build_upstream( $source, $self->_upstream_class($first), @args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | 58 | ▶ | sub _upstream_class { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upstream_class: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | 58 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | 58 | ▶ | return $name =~ /\A\+(.+)\z/ ? $1 : 'Kubernetes::Comb::Upstream::'.$name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | # Checked before it is built: a class the custom resource names gets no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | # constructor call unless it is an upstream. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | 77 | ▶ | sub _build_upstream { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_upstream: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | 77 | my ( $self, $source, $class, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | 77 | ▶ | use_module($class) unless $class->can('new'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | 75 | ▶ | croak $source.': '.$class.' does not do '.$self->_upstream_role | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | unless $class->DOES( $self->_upstream_role ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | 71 | return $self->_checked_upstream( $source, $class->new(@args) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1873 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | 84 | ▶ | sub _checked_upstream { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_checked_upstream: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1875 | 84 | my ( $self, $source, $upstream ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1876 | 84 | ▶ | croak $source.': '.ref($upstream).' does not do '.$self->_upstream_role | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | unless $upstream->DOES( $self->_upstream_role ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | 83 | return $upstream; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1880 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | # Step 6, first half: the resolved local endpoints once the local path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | # established them. The upstream path brings its own; a step that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | # established nothing carries the previous ones forward (see _status_from) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1884 | # -- unless there are none, then a local Comb publishes its own. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | 225 | ▶ | sub _publish_endpoints { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_publish_endpoints: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | 225 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | 225 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1888 | my $local = $established eq 'local' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | 225 | ▶ | || ( !$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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1890 | 225 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1891 | 156 | ▶ | return Future->call( sub { Future->done( $self->_local_endpoints ) } )->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1892 | 154 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | 154 | $r->{endpoints} = [@_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | 154 | return Future->done($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1896 | 2 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1897 | 2 | ▶ | return Future->done($r) if $r->{phase} eq 'Error'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1898 | 2 | return $self->_finish( $r, Error => EndpointsFailed => 'resolving the endpoints failed: '.$self->_message( $_[0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1899 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1900 | 156 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1903 | # Step 6: into the custom resource, else into memory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1904 | 225 | ▶ | sub _record { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_record: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1905 | 225 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1906 | 225 | my $status = $self->_status_from($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1907 | 223 | ▶ | unless ( $self->has_crd ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1908 | 164 | $self->_memory_status($status); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1909 | 164 | return Future->done($status); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1910 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1911 | 59 | ▶ | return Future->call( sub { $self->_write_status($status) } )->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1912 | 56 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1913 | 56 | my ( $stored ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1914 | 56 | $self->_set_crd($stored); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1915 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1916 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1917 | 3 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1918 | # Keep what this step did, so the next one prunes against it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1919 | 3 | $self->_condition( $r, StatusWritten => False => WriteFailed => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1920 | 'writing the status into the custom resource failed: '.$self->_message( $_[0] ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1921 | 3 | my $kept = $self->_status_from($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1922 | 3 | $self->_set_crd( $self->_crd_with( $self->crd, $kept ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1923 | 3 | return Future->done($kept); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1924 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1925 | 59 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1926 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1927 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1928 | # update_status on a copy of the custom resource; if that fails -- a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1929 | # resourceVersion conflict looks like any other error -- once more on a fresh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1930 | # read of it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1931 | 59 | ▶ | sub _write_status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_status: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1932 | 59 | my ( $self, $status ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1933 | 5 | ▶ | return $self->k8s->update_status( $self->_crd_with( $self->crd, $status ) )->else( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1934 | 5 | my $meta = $self->crd->metadata; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1935 | 3 | ▶ | return $self->k8s->get( '+'.$self->crd_class, $meta->name, namespace => $meta->namespace )->then( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1936 | 3 | my ( $fresh ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1937 | 3 | $self->_set_crd($fresh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1938 | 3 | return $self->k8s->update_status( $self->_crd_with( $fresh, $status ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1939 | 5 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1940 | 59 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1941 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1942 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1943 | 65 | ▶ | sub _crd_with { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_crd_with: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1944 | 65 | my ( $self, $crd, $status ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1945 | 65 | my $copy = ref($crd)->FROM_HASH( $crd->TO_JSON ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1946 | 65 | $copy->status($status); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1947 | 65 | return $copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1948 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1949 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1950 | 226 | ▶ | sub _status_from { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_status_from: called CC=21 SCAR=30.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1951 | 226 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1952 | 226 | my $now = $self->_now; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1953 | 226 | ▶ | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1954 | 226 | my %unchecked = ( status => 'Unknown', reason => 'NotChecked', message => 'this step did not get that far' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1955 | my %conditions = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1956 | DependenciesReady => {%unchecked}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1957 | ConfigReady => {%unchecked}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1958 | 226 | ▶ | %{ $r->{conditions} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1959 | Ready => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1960 | status => $r->{phase} eq 'Running' ? 'True' : 'False', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1961 | reason => $r->{reason}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1962 | message => $r->{message} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1963 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1964 | 226 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1965 | 226 | my @fixed = qw( Ready DependenciesReady ConfigReady ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1966 | 226 | my %fixed = map { ( $_ => 1 ) } @fixed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1967 | 226 | ▶ | my $meta = $self->has_crd ? $self->crd->metadata : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1968 | 226 | ▶ | my $generation = $meta ? $meta->generation : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1969 | # A step that established nothing -- it stopped before a path, or the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1970 | # local path failed before it was through -- changed nothing that serves: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1971 | # the endpoints and the upstream recorded before still stand, like | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1972 | # managedResources. So a bridge stays known until the local path replaced | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1973 | # it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1974 | 226 | ▶ | my $carried = $r->{established} ? undef : $r->{previous}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1975 | 49 | ▶ | my @endpoints = $r->{endpoints} ? ( map { $_->to_crd } @{ $r->{endpoints} } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1976 | 226 | ▶ | : $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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1977 | : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1978 | my $upstream = $r->{upstream_status} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1979 | 226 | ▶ | // ( $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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1980 | return $self->_status_class->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1981 | phase => $r->{phase}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1982 | conditions => [ map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1983 | 681 | my ( $type, $condition, $was ) = ( $_, $conditions{$_}, $before{$_} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1984 | +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1985 | type => $type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1986 | status => $condition->{status}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1987 | ( defined $condition->{reason} ? ( reason => $condition->{reason} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1988 | ( defined $condition->{message} ? ( message => $condition->{message} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1989 | 681 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1990 | ? $was->lastTransitionTime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1991 | : $now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1992 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1993 | 681 | ▶ | } @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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1994 | 226 | managedResources => $r->{managed} // [ $self->_previous_resources($r) ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1995 | endpoints => \@endpoints, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1996 | ( $upstream ? ( upstream => $upstream ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1997 | ( defined $generation ? ( observedGeneration => $generation ) : () ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1998 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1999 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2000 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2001 | # When even the status could not be built: the bare minimum, not written. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2002 | 2 | ▶ | sub _last_resort { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_last_resort: called CC=3 SCAR=11.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2003 | 2 | my ( $self, $error ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2004 | 2 | my $status = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2005 | 2 | $self->_status_class->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2006 | phase => 'Error', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2007 | conditions => [ { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2008 | type => 'Ready', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2009 | status => 'False', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2010 | reason => 'ReconcileFailed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2011 | message => 'recording the status failed: '.$self->_message($error), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2012 | lastTransitionTime => $self->_now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2013 | } ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2014 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2015 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2016 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2017 | 2 | return $status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2018 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2019 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2020 | 276 | ▶ | sub _now { strftime( '%Y-%m-%dT%H:%M:%SZ', gmtime ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_now: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2021 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2022 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2023 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2024 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2026 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2027 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2028 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2029 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2030 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2031 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2032 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2033 | Kubernetes::Comb - A self-contained micro collection of Kubernetes parts as a live Perl instance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2034 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2035 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2036 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2037 | version 0.001 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2038 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2039 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2040 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2041 | package MyApp::Comb::NATS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2042 | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2043 | extends 'Kubernetes::Comb'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2044 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2045 | sub endpoints { { name => 'client', port => 4222 } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2046 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2047 | sub manifests { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2048 | my ( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2049 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2050 | { apiVersion => 'apps/v1', kind => 'Deployment', metadata => { name => 'nats' }, spec => { ... } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2051 | { apiVersion => 'v1', kind => 'Service', metadata => { name => 'nats' }, spec => { ... } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2052 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2053 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2054 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2055 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2056 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2057 | my $comb = Kubernetes::Comb->from_crd($cr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2058 | k8s => $k8s, # default: Kubernetes::Comb::Client::Sync | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2059 | resolver => sub { $combs{ $_[0] } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2060 | stub => sub { $_[0]->name eq 'mailer' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2061 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2062 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2063 | $comb->deploy->get; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2064 | my $status = $comb->status->get; # { phase => 'Running', healthy => 1, pods => [...] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2065 | print $comb->logs(lines => 50)->get; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2066 | my $ep = $comb->endpoint('client')->get; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2067 | print $ep->cluster; # nats.platform.svc:4222 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2068 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2069 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2070 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2071 | A Comb is one cell of a honeycomb: a named set of Kubernetes parts that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2072 | deploys itself, reports its status and publishes its endpoints. Controlling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2073 | code builds the instance -- usually with L</from_crd> from a C<Comb> custom | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2074 | resource -- and from then on only calls its methods. All Kubernetes work | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2075 | happens in here, through the L</k8s> client. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2076 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2077 | A Comb class extends this one and overrides the contract: L</name>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2078 | L</depends_on>, L</endpoints>, L</manifests>, L</check>, L</optional>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2079 | L</bridge_manifests>, L</stub_class>. It may also define a plain C<upstream> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2080 | method (where its service is borrowed from); this class deliberately defines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2081 | none, so whether a class has one is visible to C<can>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2082 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2083 | Every lifecycle method -- L</reconcile>, L</deploy>, L</status>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2084 | L</healthy>, L</logs>, L</restart>, L</stop>, L</describe>, L</endpoint> -- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2085 | returns a L<Future> and never throws: any error, including one in a contract | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2086 | method, is a failed Future. L</reconcile> goes further: its Future never | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2087 | fails at all. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2088 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2089 | =head1 WHAT A MANAGER MUST DO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2090 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2091 | Kubernetes::Comb ships no manager or daemon: whoever drives Combs does it from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2092 | their own program, sync or async, with one step repeated: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2093 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2094 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2095 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2096 | =item 1. Watch or list C<Comb> custom resources. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2097 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2098 | =item 2. Build an instance for each with L</from_crd>, passing C<k8s>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2099 | C<resolver>, C<upstream> and C<stub> as the layering and stub choices call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2100 | for. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2102 | =item 3. Order the instances by L</depends_on> (topological sort; a cycle is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2103 | not an exception -- report it, and reconcile its Combs anyway: each stays | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2104 | C<Blocked> on the other, and says so). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2106 | =item 4. Call L</reconcile> on each, repeatedly (a timer, on a CR change, or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2107 | both). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2109 | =item 5. Show or act on L</status>; call L</restart>, L</stop>, L</logs> on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2110 | request. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2112 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2114 | F<examples/sync.pl> and F<examples/async.pl> do exactly this for three | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2115 | Combs -- C<nats> local, C<db> replicated (L<Kubernetes::Comb::Upstream::Static> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2116 | or L<Kubernetes::Comb::Upstream::K8s>), C<mailer> as a stub -- and print every | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2117 | state transition; run either with C<--help>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2119 | =head2 k8s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2121 | The Kubernetes client, anything doing L<Kubernetes::Comb::Role::Client>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2122 | Defaults to a L<Kubernetes::Comb::Client::Sync> on the current kube context; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2123 | pass a L<Kubernetes::Comb::Client::Async> to run on an L<IO::Async> loop. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2125 | =head2 resolver | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2127 | Coderef that turns a dependency reference (C<name> or C<namespace/name>) into | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2128 | the Comb instance. The only way a Comb finds its dependencies; supplied by the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2129 | controlling code. C<has_resolver> tells whether there is one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2131 | =head2 upstream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2133 | Constructor argument: what the controlling code says about the upstream, the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2134 | first source of the upstream resolution. A coderef, called with the Comb and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2135 | returning what a class C<upstream> method returns; or that answer given | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2136 | directly: an object doing C<Kubernetes::Comb::Role::Upstream>, a hashref as in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2137 | the custom resource (C<< { class => ..., ... } >>), an arrayref of the Perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2138 | helper form (C<< [ K8s => ( context => 'dev' ) ] >>), or C<undef> for an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2139 | explicit "local". There is no reader of this name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2141 | =head2 crd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2143 | The C<Comb> custom resource this instance was built from, if any. Name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2144 | namespace, config and dependencies default to what it says, and the Comb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2145 | writes its status into it. C<has_crd> tells whether there is one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2147 | =head2 crd_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2149 | The custom resource class. Defaults to the class of L</crd>, else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2150 | L<Kubernetes::Comb::CRD::Comb>. A CR class for another API group is a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2151 | subclass of that, see L<Kubernetes::Comb::CRD::Comb>. Construction dies when a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2152 | given L</crd> is not an instance of it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2154 | =head2 namespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2156 | Where the Comb lives: its namespaced resources that name none get this one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2157 | Defaults to the namespace of L</crd>; without either, every operation that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2158 | needs it fails. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2160 | =head2 config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2162 | Free-form configuration for the class. Defaults to a copy of C<spec.config> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2163 | of L</crd>, else an empty hashref. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2165 | =head2 label_prefix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2167 | Prefix of the label and annotation keys the Comb sets, default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2168 | C<comb.internal/>: the name label is C<E<lt>prefixE<gt>comb>, the namespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2169 | label C<E<lt>prefixE<gt>comb-namespace>, the restart annotation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2170 | C<E<lt>prefixE<gt>restartedAt>, the digest annotation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2171 | C<E<lt>prefixE<gt>applied-digest>. Include the trailing C</>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2173 | =head2 managed_by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2175 | Value of the C<app.kubernetes.io/managed-by> label on every resource the Comb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2176 | deploys. Default C<kubernetes-comb>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2178 | =head2 max_upstream_depth | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2180 | The most layers an upstream chain may have, default 16. An upstream whose | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2181 | C<via> names more is taken for a loop -- C<Blocked>, see L</reconcile> -- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2182 | and its C<via> is recorded cut to this length, so a loop never makes it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2183 | grow. Kube context names cannot tell a loop: layers may share one context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2184 | (namespaces of one cluster), and kubeconfigs name contexts alike. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2186 | =head2 cluster_domain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2188 | The DNS domain of the cluster, default C<cluster.local>. The default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2189 | L</bridge_manifests> appends it to a host ending in C<.svc> before it becomes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2190 | the C<externalName> of a Service: the cluster DNS answers that with a CNAME, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2191 | which a Pod's resolver does not expand with its search domains. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2193 | =head2 io_k8s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2195 | The L<IO::K8s> instance that tells the Comb what a manifest hashref is: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2196 | whether its Kind is namespaced, and its C<apiVersion> when it has none. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2197 | Defaults to one that knows the built-in Kinds and the Comb CR. Pass one with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2198 | your CRD providers (C<< IO::K8s->new(with => [...]) >>) when manifests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2199 | contain cluster-scoped custom resources; a Kind it does not know counts as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2200 | namespaced. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2202 | =head2 stub_of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2204 | The original Comb this instance stands in for, when it was built as its stub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2205 | (see L</from_crd>). Construction checks the contract: a stub that lacks any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2206 | endpoint name of its original dies, naming the missing ones. C<is_stub> tells | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2207 | whether there is one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2209 | A class named C<Foo::Stub> that is a C<Foo> -- the default L</stub_class> of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2210 | C<Foo> -- is checked against C<Foo> however it was selected: built without | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2211 | C<stub_of>, e.g. because C<spec.class> names it directly, it builds a C<Foo> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2212 | from the same arguments to check against. That C<Foo> is not kept: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2213 | C<stub_of> stays unset. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2215 | =head2 name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2217 | The name of the Comb. Defaults to C<metadata.name> of L</crd>; a class used | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2218 | without a custom resource overrides it. It goes into a label value on every | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2219 | resource, so construction dies on a name that cannot be one: more than 63 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2220 | characters, or other than letters, digits, C<->, C<_> and C<.> with a letter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2221 | or digit at both ends. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2223 | =head2 depends_on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2225 | List of the Combs this one needs, each C<name> or C<namespace/name>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2226 | Defaults to C<spec.dependsOn> of L</crd>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2228 | =head2 endpoints | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2230 | List of what the Comb offers, each a hashref or a L<Kubernetes::Comb::Endpoint>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2231 | A hashref has C<name> -- a DNS-1123 label, see | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2232 | L<Kubernetes::Comb::Endpoint/name_problem> -- and C<port>, optionally | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2233 | C<protocol> (default C<tcp>), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2234 | C<service> (the Service it is reached through, default L</name>), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2235 | C<external> and C<cluster> (both C<host:port>; C<cluster> defaults to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2236 | C<E<lt>serviceE<gt>.E<lt>namespaceE<gt>.svc:E<lt>portE<gt>>). Default: none. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2238 | =head2 manifests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2240 | List of the resources the Comb consists of, as L<IO::K8s> objects or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2241 | hashrefs -- or a Future of that list. Default: none. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2243 | =head2 check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2245 | List of the prerequisites that are missing, as human-readable strings -- or a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2246 | Future of that list. Empty means the Comb can go ahead. Default: nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2247 | missing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2249 | =head2 optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2251 | Whether the Comb stays off until it is switched on: with C<spec.enabled> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2252 | unset, L</reconcile> leaves an optional Comb C<Disabled> and runs any other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2253 | one. Default false. Works as class and as instance method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2255 | =head2 bridge_manifests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2257 | my @manifests = $comb->bridge_manifests(@endpoints)->get; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2259 | The resources that make the upstream reachable under the local names while an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2260 | upstream is active: for each Service the Comb would have locally, the one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2261 | that points at the upstream instead, so consumers keep using | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2262 | C<E<lt>serviceE<gt>:E<lt>portE<gt>>. Called with the redirected endpoints | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2263 | (L<Kubernetes::Comb::Endpoint>), whose C<cluster> is the upstream address to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2264 | point at; returns the manifests, or a Future of them. Override it when the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2265 | service needs more. A Future that fails with category C<bridge> says the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2266 | upstream cannot be bridged -- L</reconcile> reports that as C<Blocked> and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2267 | deploys nothing -- any other failure is an C<Error>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2269 | The default groups the endpoints by their Service (C<service> of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2270 | L</endpoints>, default L</name>), each port named after its endpoint: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2272 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2274 | =item * all host names: a Service of type C<ExternalName>. It cannot map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2275 | ports, so an upstream port that differs from the local one, or endpoints | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2276 | pointing at different hosts, cannot be bridged. A host ending in C<.svc> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2277 | gets L</cluster_domain> appended. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2279 | =item * all IP addresses of one family: a selector-less Service | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2280 | (C<ipFamilies> that family) plus an C<EndpointSlice> per address | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2281 | (C<discovery.k8s.io/v1>, C<kubernetes.io/service-name> label), which may | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2282 | point at another port. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2284 | =item * a mix of names and addresses, or of IPv4 and IPv6: cannot be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2285 | bridged. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2287 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2289 | =head2 stub_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2291 | The class that stands in for this one when a stub is asked for. Defaults to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2292 | C<E<lt>classE<gt>::Stub> if that class exists or loads -- a stub that fails to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2293 | compile dies --, else C<undef>. Works as class and as instance method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2295 | =head2 endpoint_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2297 | The class L</endpoint> builds, L<Kubernetes::Comb::Endpoint>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2299 | =head2 from_crd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2301 | my $comb = Kubernetes::Comb->from_crd($cr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2302 | k8s => $k8s, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2303 | resolver => sub { ... }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2304 | upstream => sub { ... }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2305 | stub => sub { my ( $comb ) = @_; ... } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2306 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2308 | Builds the Comb for a C<Comb> custom resource: loads C<spec.class> and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2309 | constructs it with C<< crd => $cr >> plus the options, all of which but | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2310 | C<stub> go to the constructor. C<stub> is called with that instance; when it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2311 | returns true, the instance's L</stub_class> is built instead, with the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2312 | original as L</stub_of> -- which checks the stub keeps the original's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2313 | endpoints. A C<spec.class> naming a stub directly is checked as well, see | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2314 | L</stub_of>. Dies when C<spec.class> is not a subclass of the invocant, a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2315 | stub is asked for and there is none, or construction dies. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2317 | =head2 comb_label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2319 | Key of the label that carries the Comb name: C<E<lt>label_prefixE<gt>comb>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2321 | =head2 comb_namespace_label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2323 | Key of the label that carries the Comb namespace: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2324 | C<E<lt>label_prefixE<gt>comb-namespace>. Next to the name it tells the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2325 | resources of same-named Combs in different namespaces apart -- the layers of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2326 | one cluster -- where they share a namespace or are cluster-scoped. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2328 | =head2 comb_labels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2330 | Hashref of the labels every resource of the Comb gets, Pod templates of its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2331 | workloads included: L</comb_label> with the name, L</comb_namespace_label> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2332 | with the L</namespace>, and C<app.kubernetes.io/managed-by> with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2333 | L</managed_by>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2335 | =head2 label_selector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2337 | Label selector for everything of this Comb: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2338 | C<E<lt>comb_labelE<gt>=E<lt>nameE<gt>,E<lt>comb_namespace_labelE<gt>=E<lt>namespaceE<gt>>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2340 | =head2 restart_annotation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2342 | Pod template annotation L</restart> sets: C<E<lt>label_prefixE<gt>restartedAt>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2344 | =head2 applied_digest_annotation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2346 | Annotation L</deploy> puts on every resource, holding the digest of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2347 | manifest it was applied from: C<E<lt>label_prefixE<gt>applied-digest>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2349 | =head2 reconcile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2351 | my $status = $comb->reconcile->get; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2352 | print $status->phase; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2354 | One step towards what the Comb class describes. Future of the new recorded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2355 | status, a L<Kubernetes::Comb::CRD::CombStatus> -- also what | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2356 | L</recorded_status> returns afterwards. The Future never fails: whatever | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2357 | goes wrong, a dying contract method or a broken client included, becomes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2358 | phase C<Error> with the reason in the C<Ready> condition. Run one step at a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2359 | time per Comb. In order: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2361 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2363 | =item 1. Upstream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2365 | Resolved from the first source that I<exists>, whose answer is final even | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2366 | when it is "local": the L</upstream> constructor argument, C<spec.upstream> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2367 | of L</crd> (an explicit C<null> is "local"), a class method C<upstream>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2368 | else local. The coderef and the class method return nothing (local), an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2369 | object doing L<Kubernetes::Comb::Role::Upstream>, C<< Name => (%args) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2370 | for C<< Kubernetes::Comb::Upstream::Name->new(%args) >>, or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2371 | C<< '+Full::Class' => (%args) >> for that class -- or a Future of that. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2372 | custom resource and a hashref say C<< { class => 'Full::Class', %args } >>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2373 | the class always fully qualified. An answer that does not resolve is an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2374 | C<Error>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2376 | =item 2. Enabled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2378 | C<spec.enabled> false, or unset while the class is L</optional>: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2379 | C<Disabled>. A disabled Comb touches no resource -- what runs keeps running. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2381 | =item 3. Dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2383 | Each of L</depends_on> goes to the L</resolver> as written (C<name> or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2384 | C<namespace/name>), with the Comb as second argument; it returns the Comb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2385 | instance or C<undef>. One not found, one whose L</healthy> is false or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2386 | fails, a dying resolver, or none at all: C<Blocked>, every problem in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2387 | message. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2389 | =item 4. Check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2391 | L</check> reports missing prerequisites: C<NeedsConfig>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2393 | =item 5a. Local | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2395 | Without an upstream. L</status> healthy, every resource applied as it is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2396 | rendered now, and C<managedResources> naming just what the manifests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2397 | render: C<Running>, nothing applied. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2399 | Not healthy: L</deploy>, then prune: every namespaced resource this Comb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2400 | recorded in C<managedResources> that it no longer renders -- compared by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2401 | group, kind, namespace and name, so a new API version is no orphan -- is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2402 | deleted if it still carries L</label_selector>, name and namespace of this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2403 | Comb, together with what it owns (C<propagationPolicy> C<Background>: the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2404 | Pods of a Job, the ReplicaSets of a Deployment). One that does not -- it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2405 | lost the labels, or a same-named Comb of another namespace applied it last | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2406 | -- is left alone and dropped from the record, one that is gone is dropped, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2407 | one that fails to delete stays for the next step. A cluster-scoped one is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2408 | never deleted: a Namespace or a CustomResourceDefinition takes far more with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2409 | it, and a same-named Comb of another namespace may render it too. It is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2410 | dropped from the record and left in place, which the C<Ready> message | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2411 | says. Then C<Pending>. A deploy that fails half-way is an C<Error> that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2412 | records what it applied on top of the previous record, and prunes nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2414 | Healthy, but a resource was applied from another manifest than the one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2415 | rendered now -- a new image in the class, a changed C<spec.config> the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2416 | manifests render from: deploy and prune all the same, then C<Pending>, the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2417 | C<Ready> message naming the resources; the next step finds the Comb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2418 | C<Running>, or not. The live L</applied_digest_annotation> tells, compared | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2419 | with the digest of the rendered manifest (see L</deploy>). A resource that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2420 | carries none -- applied by a version before there was one -- counts as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2421 | changed, which deploys the Comb once. What is compared is what the Comb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2422 | renders, never the live object: a change made to that by hand is not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2423 | detected, and a rolling L</restart> is no change. Two kinds of resources | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2424 | never deploy a Comb by their digest, since a deploy would not change them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2425 | and so every step would deploy: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2427 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2429 | =item * What the client does not replace once it exists (see | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2430 | L<Kubernetes::Comb::Role::Client/ensure>): a C<v1> PersistentVolumeClaim, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2431 | and a C<batch/v1> Job that runs or has succeeded. They keep the digest they | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2432 | were created with. A Job that failed makes the Comb unhealthy, so it is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2433 | deployed, which replaces the Job by what is rendered now. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2435 | =item * What a same-named Comb of another namespace applied last -- it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2436 | carries that Comb's L</comb_namespace_label>, and that Comb's digest. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2438 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2440 | Healthy and applied as rendered, but the record names other resources than | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2441 | the manifests render -- one dropped from the manifests, a delete that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2442 | failed, one that runs but was never recorded: deploy and prune all the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2443 | same, and stay C<Running>, the C<Ready> message saying so. Everything the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2444 | manifests render was live and healthy before. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2446 | A workload scaled below its manifest counts as not healthy (see | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2447 | L</status>), so a reconcile after L</stop>, or after scaling a Deployment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2448 | down by hand, deploys again, which scales the workloads back up. The first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2449 | step after borrowing from an upstream deploys even when L</status> looks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2450 | healthy, since the bridge may stand where the local resources belong. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2452 | =item 5b. Upstream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2454 | With an active upstream (see L<Kubernetes::Comb::Role::Upstream>), the Comb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2455 | runs nothing of its own and borrows the service instead: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2457 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2459 | =item * The upstream's C<status>. Not reachable: C<Blocked> with its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2460 | message. A C<via> of more than L</max_upstream_depth> layers is taken for a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2461 | loop: C<Blocked> (C<UpstreamLoop>), the recorded C<via> cut to that length. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2463 | =item * The upstream's C<endpoints>, matched by name to L</endpoints>: each | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2464 | declared endpoint gets the upstream's C<cluster> address (else its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2465 | C<external> one) and C<external> -- the redirected endpoints, which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2466 | L</endpoint> returns and C<status.endpoints> publishes. One the upstream has | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2467 | no address for: C<Blocked>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2469 | =item * L</bridge_manifests> for the redirected endpoints. A bridge that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2470 | cannot be: C<Blocked>, nothing deployed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2472 | =item * C<replicate_into>, when the upstream has it. A failure: C<Error>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2474 | =item * The bridge is deployed and pruned as the manifests are in the local | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2475 | path, so the local workloads go and a local Service of a bridged name is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2476 | changed in place. Then C<Running> when the upstream is C<Running>, else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2477 | C<Pending> with its phase. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2479 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2481 | A failing C<status> or C<endpoints>, an answer that is none, or a bridge that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2482 | does not render: C<Error>. Whatever the upstream's C<status> said is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2483 | recorded in C<status.upstream>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2485 | =item 6. Record | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2487 | Phase, conditions, the resolved endpoints -- the redirected ones while | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2488 | borrowing, once they are known --, C<status.upstream> while an upstream is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2489 | active, C<managedResources> and C<observedGeneration> go through | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2490 | C<update_status> into L</crd>, which is replaced by what the API server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2491 | returns; without a custom resource the status is kept in memory. A failed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2492 | write is retried once on a freshly read custom resource; if that fails too | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2493 | the status is kept in memory and carries a C<StatusWritten> condition that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2494 | says why. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2496 | A step that changes nothing that serves carries C<managedResources>, the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2497 | endpoints and C<status.upstream> of the previous status forward: one that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2498 | stops before step 5 (C<Disabled>, C<Blocked> by its dependencies, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2499 | C<NeedsConfig>, an C<Error> there), and a local step that fails before it is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2500 | through. So a bridge stays recorded -- and replaced by the next local step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2501 | -- until the local path has deployed in its place; C<status.upstream> goes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2502 | once it has. On the very first step there is nothing to carry, and a local | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2503 | Comb publishes its own endpoints. The upstream path records what its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2504 | upstream says now, and endpoints only once the upstream offers an address | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2505 | for each. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2507 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2509 | Conditions: C<Ready> (C<True> when C<Running>; its reason and message are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2510 | the step's), C<DependenciesReady> and C<ConfigReady> (each C<Unknown> with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2511 | reason C<NotChecked> when the step did not get that far), and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2512 | C<StatusWritten> -- present only when writing the status failed (see step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2513 | 6), C<False> with the reason. Their C<lastTransitionTime> changes only when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2514 | their status does. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2516 | =head2 deploy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2518 | my @stored = $comb->deploy->get; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2520 | Renders L</manifests>, labels every resource (and the Pod templates of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2521 | workloads) with L</comb_labels>, puts L</namespace> on namespaced resources | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2522 | that name none and L</applied_digest_annotation> on every one, and creates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2523 | or updates them one after the other. Future of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2524 | the objects as stored. A failure stops at that resource; the Future fails | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2525 | with the message, category C<deploy> and C<< { applied => [...], failed => $manifest } >>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2526 | Manifests that do not render fail it with category C<manifests>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2528 | An update replaces the object with what the manifest says, so the Pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2529 | template of a live Deployment, StatefulSet or DaemonSet would lose the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2530 | L</restart_annotation> L</restart> put there -- rolling its Pods once more, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2531 | or undoing a restart under way. Deploy keeps it: the rendered Pod template | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2532 | gets the live value. It reads those workloads first, one list by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2533 | L</comb_label> per kind (L</reconcile> passes on what it has read anyway); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2534 | when that fails, so does the deploy -- category C<deploy>, nothing applied. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2536 | The L</applied_digest_annotation> holds C<sha256:> and the SHA-256, in hex, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2537 | of the manifest as it is applied -- what the class rendered, with the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2538 | labels, the namespace and the C<apiVersion> deploy adds -- but for that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2539 | annotation itself and the restart annotation carried over. It is taken of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2540 | the canonical JSON of the manifest with every number and string as a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2541 | string, so it does not depend on how Perl holds a value: C<replicas: 2> and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2542 | C<replicas: "2"> digest alike. A manifest holding what is no data (a code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2543 | reference, an object without C<TO_JSON>) does not render. L</reconcile> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2544 | compares the digest; the bridge of a borrowing Comb carries one too, which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2545 | nothing compares. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2547 | =head2 status | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2549 | my $status = $comb->status->get; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2551 | Future of what the cluster shows of the Comb right now: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2553 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2554 | phase => 'Running', # Running, Pending, Error, Stopped or NotDeployed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2555 | healthy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2556 | reason => '...', # when there is a problem: the first one's reason | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2557 | message => '...', # every problem, joined with '; ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2558 | pods => [ { name, phase, ready, restarts, reason, message }, ... ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2559 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2561 | It looks for every rendered resource (by L</comb_label> alone: where a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2562 | same-named Comb of another namespace renders the same resource, the one that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2563 | applied it last owns it, and both find it) and at the Pods of the Comb (by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2564 | L</label_selector>). C<NotDeployed>: none of the resources exists. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2565 | C<Stopped>: as L</stop> leaves the Comb -- every Deployment and StatefulSet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2566 | at 0 replicas, every CronJob suspended, at least one of them against its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2567 | manifest. What stop leaves running (a DaemonSet, a ReplicaSet, a bare Pod) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2568 | does not keep a Comb from C<Stopped>; a manifest that says C<replicas: 0> or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2569 | C<suspend: true> itself is at rest as rendered, not stopped. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2570 | C<Running>: every resource exists, every Pod that should run has all its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2571 | containers ready, the replicated workloads have their ready replicas and the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2572 | Jobs completed. A replicated workload wants the replicas of its manifest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2573 | (default 1, what L</deploy> sets); scaled below that, by hand or by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2574 | L</stop>, it is short of them (C<ReplicasNotReady>, "scaled to" in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2575 | message), scaled beyond it -- by hand, by an autoscaler -- it wants its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2576 | scale. A Comb without workloads is running once its resources | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2577 | exist. Waiting and terminated container reasons, restart counts and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2578 | C<PodScheduled=False> make up the reasons and messages; a reason that does not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2579 | pass by waiting (C<CrashLoopBackOff>, C<ImagePullBackOff>, a failed Job, a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2580 | failed Pod of its own) makes the phase C<Error>. Completed Pods never count | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2581 | against the Comb; a failed Pod that belongs to a controller is left to it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2583 | With an active upstream (resolved as in L</reconcile>) the Comb runs no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2584 | Pods; the status is that of the borrowed service instead, with C<pods> empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2585 | and an C<upstream> key holding what C<status.upstream> would. C<Running>: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2586 | the upstream is reachable and C<Running> and every resource of the bridge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2587 | (L</bridge_manifests>) exists. C<Pending> or C<NotDeployed> while that is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2588 | not so; C<Blocked> or C<Error> where L</reconcile> would stop with that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2589 | phase. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2591 | =head2 healthy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2592 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2593 | Future of a boolean: whether L</status> is C<Running>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2595 | =head2 logs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2597 | print $comb->logs(lines => 50)->get; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2599 | Future of the last C<lines> (default 100) log lines of every container of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2600 | Comb's Pods. With more than one container, each gets a C<==E<gt> pod/container | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2601 | E<lt>==> header. A container in C<CrashLoopBackOff> shows its previous | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2602 | instance, marked C<(previous)>. A container whose log cannot be read shows why | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2603 | instead of failing the whole Future. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2605 | =head2 restart | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2607 | Rolling restart: sets L</restart_annotation> to the current time (RFC 3339) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2608 | on the Pod template of every Deployment, StatefulSet and DaemonSet of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2609 | Comb; deletes its Jobs together with their Pods. Future of the list of what | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2610 | it touched, as C<Kind/name>. L</deploy> -- and so L</reconcile> -- keeps the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2611 | annotation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2613 | =head2 stop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2615 | Scales the Deployments and StatefulSets of the Comb to 0, suspends its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2616 | CronJobs and deletes its Jobs together with their Pods. Future of the list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2617 | of what it touched, as C<Kind/name>. L</status> is C<Stopped> then; the next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2618 | L</reconcile> deploys the Comb again. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2620 | =head2 describe | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2622 | Future of a hashref with everything about the Comb, plain data: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2623 | C<name>, C<class>, C<namespace>, C<depends_on>, C<endpoints> (resolved, as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2624 | hashrefs), C<status> (see L</status>), C<recorded> (the L</recorded_status>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2625 | when there is one) and C<stub_of> (class of the original, for a stub). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2627 | =head2 endpoint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2629 | my $ep = $comb->endpoint('client')->get; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2631 | Future of the L<Kubernetes::Comb::Endpoint> of that name, with its resolved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2632 | addresses. Fails for a name the Comb does not offer. With an active upstream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2633 | the addresses are the redirected ones (see L</reconcile>), and it fails with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2634 | the reason when the upstream offers none. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2636 | =head2 recorded_status | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2638 | The status the Comb last recorded, a L<Kubernetes::Comb::CRD::CombStatus> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2639 | or C<undef>: C<status> of L</crd>, without a custom resource the one kept in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2640 | memory. Unlike L</status> this reads nothing from the cluster. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2642 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2644 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2646 | =item * L<Kubernetes::Comb::CRD::Comb> -- the custom resource | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2647 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2648 | =item * L<Kubernetes::Comb::Role::Client> -- the client surface | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2650 | =item * L<Kubernetes::Comb::Endpoint> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2652 | =item * L<Kubernetes::Comb::Role::Upstream>, L<Kubernetes::Comb::Upstream::K8s>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2653 | L<Kubernetes::Comb::Upstream::Static> -- layering | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2655 | =item * L<Kubernetes::Comb::Static> -- a Comb whose manifests are files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2657 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2659 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2661 | =head2 Issues | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2663 | Please report bugs and feature requests on GitHub at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2664 | L<https://github.com/Getty/p5-kubernetes-comb/issues>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2666 | =head2 IRC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2668 | Join C<#kubernetes> on C<irc.perl.org> or message Getty directly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2670 | =head1 CONTRIBUTING | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2672 | Contributions are welcome! Please fork the repository and submit a pull request. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2674 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2676 | Torsten Raudssus <getty@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2678 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2680 | This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> L<https://raudssus.de/>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2681 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2682 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2683 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2684 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2685 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||