Skip RRS update if existing records are equal to desired records

This is done first and formost to stop "empty" commits that cause errors in
publishDnsUpdates. The reason being that the Cloud DNS api fails when there are
no updates at all in a change.

Allowing this is a requirement for the writer to be idempotent - if we delete a
domain, then run the writer to delete it again - we'll get 0 additions and 0
deletions which fails.

This isn't theoretical either - we've seen it happen, causing a
publishDnsUpdates to fail over and over again.

While fixing this, we also remove all RRS that are common between additions and
deletions. This is just an optimization and shouldn't affect behavior.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179525218
This commit is contained in:
guyben 2017-12-19 01:53:58 -08:00 committed by Ben McIlwain
parent 42795074a8
commit 633eb3179a
2 changed files with 24 additions and 1 deletions

View file

@ -490,4 +490,10 @@ public class CloudDnsWriterTest {
writer.commit();
assertThat(zoneNameCaptor.getValue()).isEqualTo("triple-secret-tld");
}
@Test
public void testEmptyCommit() {
writer.commit();
verify(dnsConnection, times(0)).changes();
}
}