Do not cancel pending transfers unless there is one to cancel

A previous CL inadvertently caused the system to always set the transfer status to SERVER_CANCELLED when deleting a resource, even if there was no transfer. This led to RDE problems.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=140890919
This commit is contained in:
mountford 2016-12-02 14:03:30 -08:00 committed by Ben McIlwain
parent 7cf29366bc
commit c0d9b54872
5 changed files with 37 additions and 7 deletions

View file

@ -131,9 +131,10 @@ public final class DomainDeleteFlow implements TransactionalFlow {
AfterValidationParameters.newBuilder().setExistingDomain(existingDomain).build());
ImmutableSet.Builder<ImmutableObject> entitiesToSave = new ImmutableSet.Builder<>();
HistoryEntry historyEntry = buildHistoryEntry(existingDomain, now);
Builder builder =
ResourceFlowUtils.<DomainResource, DomainResource.Builder>resolvePendingTransfer(
existingDomain, TransferStatus.SERVER_CANCELLED, now);
Builder builder = existingDomain.getStatusValues().contains(StatusValue.PENDING_TRANSFER)
? ResourceFlowUtils.<DomainResource, DomainResource.Builder>resolvePendingTransfer(
existingDomain, TransferStatus.SERVER_CANCELLED, now)
: existingDomain.asBuilder();
builder.setDeletionTime(now).setStatusValues(null);
// If the domain is in the Add Grace Period, we delete it immediately, which is already
// reflected in the builder we just prepared. Otherwise we give it a PENDING_DELETE status.