Skip to content

Commit

Permalink
Merge pull request #20786 from Amrysliu/jsc_9788
Browse files Browse the repository at this point in the history
Run terraform destroy before retrying terraform apply
  • Loading branch information
BillAnastasiadis authored Dec 12, 2024
2 parents b285c4e + ca4b6cd commit 4910acf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions lib/qesapdeployment.pm
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,17 @@ sub qesap_execute_conditional_retry {
if ($ret[0]) {
if (qesap_file_find_string(file => $ret[1], search_string => $args{error_string})) {
record_info('DETECTED ' . uc($args{cmd}) . ' ERROR', $args{error_string});

# Executing terraform destroy before retrying terraform apply
if ($args{destroy_terraform}) {
qesap_execute(
cmd => 'terraform',
cmd_options => '-d',
logname => "qesap_exec_terraform_destroy_before_retry$args{retries}.log.txt",
verbose => 1,
timeout => 1200);
}

@ret = qesap_execute(cmd => $args{cmd},
logname => 'qesap_' . $args{cmd} . '_retry_' . $args{retries} . '.log.txt',
timeout => $args{timeout});
Expand Down
3 changes: 2 additions & 1 deletion tests/sles4sap/publiccloud/qesap_terraform.pm
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ sub run {
verbose => 1,
timeout => 3600,
retries => 2,
error_string => 'An internal execution error occurred. Please retry later');
error_string => 'An internal execution error occurred. Please retry later',
destroy_terraform => 1);
die 'Terraform deployment FAILED. Check "qesap*" logs for details.' if ($ret[0]);

$provider->terraform_applied(1);
Expand Down

0 comments on commit 4910acf

Please sign in to comment.