mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
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:
parent
e38c87238e
commit
707e22f2d2
2 changed files with 63 additions and 20 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue