Don't try https and http: use https if possible, else http. Lower timeout from 5 to 3 seconds. Start updating/fixing pt-archiver/version_check.t.

This commit is contained in:
Daniel Nichter
2013-02-14 09:41:52 -07:00
parent 4c63a36795
commit 8ecde260a7
21 changed files with 635 additions and 508 deletions

View File

@@ -4736,9 +4736,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -4752,7 +4754,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -4760,22 +4762,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -4787,7 +4788,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -4795,7 +4801,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -4815,13 +4821,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -4853,7 +4860,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -4890,7 +4897,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -4905,7 +4912,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -5196,7 +5203,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}

View File

@@ -4410,9 +4410,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -4426,7 +4428,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -4434,22 +4436,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -4461,7 +4462,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -4469,7 +4475,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -4489,13 +4495,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -4527,7 +4534,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -4564,7 +4571,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -4579,7 +4586,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -4870,7 +4877,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}

View File

@@ -3326,9 +3326,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -3342,7 +3344,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -3350,22 +3352,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -3377,7 +3378,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -3385,7 +3391,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -3405,13 +3411,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -3443,7 +3450,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -3480,7 +3487,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -3495,7 +3502,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -3786,7 +3793,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}

View File

@@ -4221,9 +4221,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -4237,7 +4239,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -4245,22 +4247,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -4272,7 +4273,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -4280,7 +4286,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -4300,13 +4306,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -4338,7 +4345,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -4375,7 +4382,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -4390,7 +4397,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -4681,7 +4688,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}

View File

@@ -4082,9 +4082,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -4098,7 +4100,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -4106,22 +4108,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -4133,7 +4134,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -4141,7 +4147,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -4161,13 +4167,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -4199,7 +4206,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -4236,7 +4243,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -4251,7 +4258,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -4542,7 +4549,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}

View File

@@ -2894,9 +2894,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -2910,7 +2912,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -2918,22 +2920,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -2945,7 +2946,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -2953,7 +2959,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -2973,13 +2979,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -3011,7 +3018,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -3048,7 +3055,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -3063,7 +3070,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -3354,7 +3361,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}

View File

@@ -2836,9 +2836,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -2852,7 +2854,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -2860,22 +2862,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -2887,7 +2888,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -2895,7 +2901,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -2915,13 +2921,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -2953,7 +2960,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -2990,7 +2997,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -3005,7 +3012,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -3296,7 +3303,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}

View File

@@ -4062,9 +4062,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -4078,7 +4080,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -4086,22 +4088,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -4113,7 +4114,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -4121,7 +4127,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -4141,13 +4147,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -4179,7 +4186,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -4216,7 +4223,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -4231,7 +4238,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -4522,7 +4529,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}

View File

@@ -5537,9 +5537,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -5553,7 +5555,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -5561,22 +5563,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -5588,7 +5589,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -5596,7 +5602,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -5616,13 +5622,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -5654,7 +5661,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -5691,7 +5698,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -5706,7 +5713,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -5997,7 +6004,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}

View File

@@ -5759,9 +5759,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -5775,7 +5777,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -5783,22 +5785,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -5810,7 +5811,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -5818,7 +5824,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -5838,13 +5844,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -5876,7 +5883,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -5913,7 +5920,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -5928,7 +5935,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -6219,7 +6226,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}

View File

@@ -7209,9 +7209,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -7225,7 +7227,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -7233,22 +7235,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -7260,7 +7261,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -7268,7 +7274,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -7288,13 +7294,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -7326,7 +7333,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -7363,7 +7370,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -7378,7 +7385,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -7669,7 +7676,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}

View File

@@ -7492,9 +7492,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -7508,7 +7510,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -7516,22 +7518,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -7543,7 +7544,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -7551,7 +7557,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -7571,13 +7577,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -7609,7 +7616,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -7646,7 +7653,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -7661,7 +7668,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -7952,7 +7959,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}

View File

@@ -13121,9 +13121,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -13137,7 +13139,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -13145,22 +13147,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -13172,7 +13173,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -13180,7 +13186,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -13200,13 +13206,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -13238,7 +13245,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -13275,7 +13282,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -13290,7 +13297,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -13581,7 +13588,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}

View File

@@ -3437,9 +3437,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -3453,7 +3455,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -3461,22 +3463,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -3488,7 +3489,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -3496,7 +3502,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -3516,13 +3522,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -3554,7 +3561,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -3591,7 +3598,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -3606,7 +3613,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -3897,7 +3904,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}

View File

@@ -4061,9 +4061,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -4077,7 +4079,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -4085,22 +4087,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -4112,7 +4113,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -4120,7 +4126,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -4140,13 +4146,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -4178,7 +4185,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -4215,7 +4222,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -4230,7 +4237,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -4521,7 +4528,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}

View File

@@ -775,9 +775,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -791,7 +793,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -799,22 +801,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -826,7 +827,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -834,7 +840,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -854,13 +860,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -892,7 +899,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -929,7 +936,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -944,7 +951,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -1235,7 +1242,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}

View File

@@ -8899,9 +8899,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -8915,7 +8917,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -8923,22 +8925,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -8950,7 +8951,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -8958,7 +8964,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -8978,13 +8984,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -9016,7 +9023,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -9053,7 +9060,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -9068,7 +9075,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -9359,7 +9366,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}

View File

@@ -11718,9 +11718,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -11734,7 +11736,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -11742,22 +11744,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -11769,7 +11770,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -11777,7 +11783,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -11797,13 +11803,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -11835,7 +11842,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -11872,7 +11879,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -11887,7 +11894,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -12178,7 +12185,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}

View File

@@ -4344,9 +4344,11 @@ sub version_check_time_limit {
sub version_check {
my (%args) = @_;
eval {
my $instances = $args{instances} || [];
my $instances = $args{instances} || [];
my $instances_to_check;
eval {
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
return;
@@ -4360,7 +4362,7 @@ sub version_check {
push @$instances, { name => 'system', id => 0 };
my $instances_to_check = get_instances_to_check(
$instances_to_check = get_instances_to_check(
instances => $instances,
vc_file => $args{vc_file}, # testing
now => $args{now}, # testing
@@ -4368,22 +4370,21 @@ sub version_check {
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
return unless @$instances_to_check;
my $advice;
PROTOCOL:
foreach my $protocol ( qw(https http) ) {
$advice = eval {
pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
};
last PROTOCOL unless $EVAL_ERROR;
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
my $protocol = 'https'; # optimistic, but...
eval { require IO::Socket::SSL; };
if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR);
$protocol = 'http';
}
PTDEBUG && _d('Using', $protocol);
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
if ( scalar @$advice > 1) {
@@ -4395,7 +4396,12 @@ sub version_check {
}
print join("\n", map { "# * $_" } @$advice), "\n\n";
}
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
}
eval {
update_check_times(
instances => $instances_to_check,
vc_file => $args{vc_file}, # testing
@@ -4403,7 +4409,7 @@ sub version_check {
);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
}
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
@@ -4423,13 +4429,14 @@ sub get_instances_to_check {
my $vc_file = $args{vc_file} || version_check_file();
if ( !-f $vc_file ) {
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
'version checking all instances');
return $instances;
}
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
chomp(my $file_contents = do { local $/ = undef; <$fh> });
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
close $fh;
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
@@ -4461,7 +4468,7 @@ sub update_check_times {
PTDEBUG && _d('Updating last check time:', $now);
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
PTDEBUG && _d('Updated:', Dumper($instance));
print { $fh } $instance->{id} . ',' . $now . "\n";
}
@@ -4498,7 +4505,7 @@ sub get_instance_id {
}
my $id = md5_hex($name);
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
return $name, $id;
}
@@ -4513,7 +4520,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -4804,7 +4811,6 @@ sub get_from_mysql {
'on', $instance->{name});
push @versions, $version;
}
$version_for{ $instance->{id} } = join(' ', @versions);
}