Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout for the internal command functions #19743

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions lib/sles4sap/ipaddr2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,6 @@ sub ipaddr2_ssh_bastion_assert_script_run {
"'$args{cmd}'"));
}


=head2 ipaddr2_ssh_bastion_script_run

my $ret = ipaddr2_ssh_bastion_script_run(
Expand Down Expand Up @@ -939,15 +938,17 @@ sub ipaddr2_ssh_internal_cmd {
run a command on one of the two internal VM through the bastion
using the assert_script_run API

=over 3
=over 4

=item B<id> - ID of the internal VM. Used to compose its name and as address for ssh.

=item B<cmd> - Command to be run on the internal VM.

=item B<bastion_ip> - Public IP address of the bastion. Calculated if not provided.
Providing it as an argument is recommended in order
to avoid having to query Azure to get it.

=item B<cmd> - Command to be run on the internal VM.
=item B<timeout> - Execution timeout, default 90sec

=back
=cut
Expand All @@ -957,11 +958,14 @@ sub ipaddr2_ssh_internal {
foreach (qw(id cmd)) {
croak("Argument < $_ > missing") unless $args{$_}; }
$args{bastion_ip} //= ipaddr2_bastion_pubip();
$args{timeout} //= 90;

assert_script_run(ipaddr2_ssh_internal_cmd(
assert_script_run(
ipaddr2_ssh_internal_cmd(
id => $args{id},
bastion_ip => $args{bastion_ip},
cmd => $args{cmd}));
cmd => $args{cmd}),
timeout => $args{timeout});
}

=head2 ipaddr2_ssh_internal_output
Expand All @@ -974,15 +978,17 @@ sub ipaddr2_ssh_internal {
Runs $cmd through the bastion on one of the two internal VMs using script_output.
Return the command output.

=over 3
=over 4

=item B<id> - ID of the internal VM. Used to compose its name and as address for ssh.

=item B<cmd> - Command to be run on the internal VM.

=item B<bastion_ip> - Public IP address of the bastion. Calculated if not provided.
Providing it as an argument is recommended in order
to avoid having to query Azure to get it.

=item B<cmd> - Command to be run on the internal VM.
=item B<timeout> - Execution timeout, default 90sec

=back
=cut
Expand All @@ -992,11 +998,14 @@ sub ipaddr2_ssh_internal_output {
foreach (qw(id cmd)) {
croak("Argument < $_ > missing") unless $args{$_}; }
$args{bastion_ip} //= ipaddr2_bastion_pubip();
$args{timeout} //= 90;

return script_output(ipaddr2_ssh_internal_cmd(
return script_output(
ipaddr2_ssh_internal_cmd(
id => $args{id},
bastion_ip => $args{bastion_ip},
cmd => $args{cmd}));
cmd => $args{cmd}),
timeout => $args{timeout});
}

=head2 ipaddr2_create_cluster
Expand Down Expand Up @@ -1084,6 +1093,8 @@ sub ipaddr2_registeration_check {
croak("Argument < id > missing") unless $args{id};

$args{bastion_ip} //= ipaddr2_bastion_pubip();

# Initially suppose is registered
my $registered = 1;
my $json = decode_json(ipaddr2_ssh_internal_output(
id => $args{id},
Expand Down
1 change: 1 addition & 0 deletions t/22_ipaddr2.t
Original file line number Diff line number Diff line change
Expand Up @@ -424,4 +424,5 @@ subtest '[ipaddr2_registeration_set]' => sub {
ok((any { /registercloudguest.*clean/ } @calls), 'registercloudguest clean');
ok((any { /registercloudguest.*-r.*1234567890/ } @calls), 'registercloudguest register');
};

done_testing;
1 change: 0 additions & 1 deletion tests/sles4sap/ipaddr2/configure.pm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ sub run {
}
}


record_info("TEST STAGE", "Init and configure the Pacemaker cluster");
ipaddr2_create_cluster(bastion_ip => $bastion_ip);
}
Expand Down
Loading