Don't throw entity integrity errors for renamed hosts

Old ForeignKeyIndex entities pointing to hosts are soft-deleted when a
host is renamed, and a new ForeignKeyIndex is created that correctly
points at the new host.  This is an expected state of the system, so
don't throw an error when it is observed.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=122447608
This commit is contained in:
Ben McIlwain 2016-05-16 12:45:49 -07:00 committed by Justine Tunney
parent e38c87238e
commit 707e22f2d2
2 changed files with 63 additions and 20 deletions

View file

@ -22,6 +22,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.DateTimeUtils.earliestOf;
import static google.registry.util.DateTimeUtils.isAtOrAfter;
import static google.registry.util.DateTimeUtils.isBeforeOrAt;
import static google.registry.util.FormattingLogger.getLoggerForCallerClass;
import static google.registry.util.PipelineUtils.createJobPath;
@ -305,11 +306,14 @@ public class VerifyEntityIntegrityAction implements Runnable {
@SuppressWarnings("cast")
EppResource resource = verifyExistence(fkiKey, fki.getReference());
if (resource != null) {
integrity().check(
fki.getForeignKey().equals(resource.getForeignKey()),
fkiKey,
Key.create(resource),
"Foreign key index points to EppResource with different foreign key");
// TODO(user): Traverse the chain of pointers to old FKIs instead once they are written.
if (isAtOrAfter(fki.getDeletionTime(), resource.getDeletionTime())) {
integrity().check(
fki.getForeignKey().equals(resource.getForeignKey()),
fkiKey,
Key.create(resource),
"Foreign key index points to EppResource with different foreign key");
}
}
if (fki instanceof ForeignKeyDomainIndex) {
getContext().incrementCounter("domain foreign key indexes");
@ -539,7 +543,9 @@ public class VerifyEntityIntegrityAction implements Runnable {
foreignKey,
resourceKind,
"Missing foreign key index for EppResource");
if (thereCanBeOnlyOne) {
// Skip the case where no resources were found because entity exceptions are already thrown in
// the mapper in invalid situations where FKIs point to non-existent entities.
if (thereCanBeOnlyOne && !resources.isEmpty()) {
verifyOnlyOneActiveResource(resources, getOnlyElement(foreignKeyIndexes));
}
}