Skip to content

Commit

Permalink
Fix delete backup issue in autogenerated admin client
Browse files Browse the repository at this point in the history
  • Loading branch information
sakthivelmanii committed Dec 17, 2024
1 parent 9faac07 commit d0e762b
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertTrue;

import com.google.api.gax.rpc.FailedPreconditionException;
import com.google.cloud.Timestamp;
import com.google.cloud.spanner.DatabaseId;
import com.google.cloud.spanner.ErrorCode;
Expand Down Expand Up @@ -643,8 +644,13 @@ private static void deleteAllBackups(String instanceId) throws InterruptedExcept
attempts++;
databaseAdminClient.deleteBackup(backup.getName());
break;
} catch (SpannerException e) {
if (e.getErrorCode() == ErrorCode.FAILED_PRECONDITION
} catch (SpannerException | FailedPreconditionException e) {
ErrorCode errorCode = ErrorCode.FAILED_PRECONDITION;

if(e instanceof SpannerException) {
errorCode = ((SpannerException) e).getErrorCode();
}
if (errorCode == ErrorCode.FAILED_PRECONDITION
&& e.getMessage()
.contains(
"Please try deleting the backup once the restore or post-restore optimize "
Expand Down

0 comments on commit d0e762b

Please sign in to comment.