1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

deSEC: API rejects empty updates caused by IGNORE() of all records (#2830)

This commit is contained in:
Tom Limoncelli
2024-02-09 15:55:13 -05:00
committed by GitHub
parent f5bb6e658b
commit 22d96f2c26
2 changed files with 39 additions and 13 deletions

View File

@ -2113,6 +2113,28 @@ func makeTests(t *testing.T) []*TestGroup {
).ExpectNoChanges(), ).ExpectNoChanges(),
), ),
// https://github.com/StackExchange/dnscontrol/issues/2822
// Don't send empty updates.
// A carefully constructed IGNORE() can ignore all the
// changes. This resulted in the deSEC provider generating an
// empty upsert, which the API rejected.
testgroup("IGNORE everything b2822",
tc("Create some records",
a("dyndns-city1", "91.42.1.1"),
a("dyndns-city2", "91.42.1.2"),
aaaa("dyndns-city1", "2003:dd:d7ff::fe71:ce77"),
aaaa("dyndns-city2", "2003:dd:d7ff::fe71:ce78"),
),
tc("ignore them all",
a("dyndns-city1", "91.42.1.1"),
a("dyndns-city2", "91.42.1.2"),
aaaa("dyndns-city1", "2003:dd:d7ff::fe71:ce77"),
aaaa("dyndns-city2", "2003:dd:d7ff::fe71:ce78"),
ignore("dyndns-city1", "A,AAAA", ""),
ignore("dyndns-city2", "A,AAAA", ""),
).ExpectNoChanges().UnsafeIgnore(),
),
testgroup("structured TXT", testgroup("structured TXT",
only("OVH"), only("OVH"),
tc("Create TXT", tc("Create TXT",

View File

@ -213,19 +213,23 @@ func (c *desecProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, exist
} }
} }
} }
msg := fmt.Sprintf("Changes:\n%s", buf)
corrections = append(corrections, // If there are changes, upsert them.
&models.Correction{ if len(rrs) > 0 {
Msg: msg, msg := fmt.Sprintf("Changes:\n%s", buf)
F: func() error { corrections = append(corrections,
rc := rrs &models.Correction{
err := c.upsertRR(rc, dc.Name) Msg: msg,
if err != nil { F: func() error {
return err rc := rrs
} err := c.upsertRR(rc, dc.Name)
return nil if err != nil {
}, return err
}) }
return nil
},
})
}
// NB(tlim): This sort is just to make updates look pretty. It is // NB(tlim): This sort is just to make updates look pretty. It is
// cosmetic. The risk here is that there may be some updates that // cosmetic. The risk here is that there may be some updates that