mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Don't count diff2.REPORT (informational warnings) as a "correction" (#2361)
Co-authored-by: Tom Limoncelli <tal@whatexit.org>
This commit is contained in:
@@ -496,7 +496,9 @@ func (r *route53Provider) GetZoneRecordsCorrections(dc *models.DomainConfig, exi
|
||||
return nil, err
|
||||
}
|
||||
instructions = reorderInstructions(instructions)
|
||||
wasReport := false
|
||||
var reports []*models.Correction
|
||||
|
||||
//wasReport := false
|
||||
for _, inst := range instructions {
|
||||
instNameFQDN := inst.Key.NameFQDN
|
||||
instType := inst.Key.Type
|
||||
@@ -505,8 +507,12 @@ func (r *route53Provider) GetZoneRecordsCorrections(dc *models.DomainConfig, exi
|
||||
switch inst.Type {
|
||||
|
||||
case diff2.REPORT:
|
||||
chg = r53Types.Change{}
|
||||
wasReport = true
|
||||
// REPORTs are held in a separate list so that they aren't part of the batching process.
|
||||
reports = append(reports,
|
||||
&models.Correction{
|
||||
Msg: inst.MsgsJoined,
|
||||
})
|
||||
continue
|
||||
|
||||
case diff2.CREATE:
|
||||
fallthrough
|
||||
@@ -560,34 +566,19 @@ func (r *route53Provider) GetZoneRecordsCorrections(dc *models.DomainConfig, exi
|
||||
}
|
||||
|
||||
addCorrection := func(msg string, req *r53.ChangeResourceRecordSetsInput) {
|
||||
|
||||
if wasReport {
|
||||
|
||||
// Add a "msg only" correction.
|
||||
corrections = append(corrections,
|
||||
&models.Correction{
|
||||
Msg: msg,
|
||||
})
|
||||
|
||||
} else {
|
||||
|
||||
// Add a function to execute.
|
||||
corrections = append(corrections,
|
||||
&models.Correction{
|
||||
Msg: msg,
|
||||
F: func() error {
|
||||
var err error
|
||||
req.HostedZoneId = zone.Id
|
||||
withRetry(func() error {
|
||||
_, err = r.client.ChangeResourceRecordSets(context.Background(), req)
|
||||
return err
|
||||
})
|
||||
corrections = append(corrections,
|
||||
&models.Correction{
|
||||
Msg: msg,
|
||||
F: func() error {
|
||||
var err error
|
||||
req.HostedZoneId = zone.Id
|
||||
withRetry(func() error {
|
||||
_, err = r.client.ChangeResourceRecordSets(context.Background(), req)
|
||||
return err
|
||||
},
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
return err
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// Send the changes in as few API calls as possible.
|
||||
@@ -605,7 +596,7 @@ func (r *route53Provider) GetZoneRecordsCorrections(dc *models.DomainConfig, exi
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return corrections, nil
|
||||
return append(reports, corrections...), nil
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user