mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
ROUTE53: Messages don't display correctly in big batch mode (#580)
* fixed description for paginated r53 updates Signed-off-by: marco.messerschmidt <marco.messerschmidt@zalando.de> * fixed description for paginated r53 updates Signed-off-by: marco.messerschmidt <marco.messerschmidt@zalando.de> * Update route53Provider.go reset batch site
This commit is contained in:
@ -223,8 +223,8 @@ func (r *route53Provider) GetDomainCorrections(dc *models.DomainConfig) ([]*mode
|
|||||||
// or changes where we upsert an entire record set.
|
// or changes where we upsert an entire record set.
|
||||||
dels := []*r53.Change{}
|
dels := []*r53.Change{}
|
||||||
changes := []*r53.Change{}
|
changes := []*r53.Change{}
|
||||||
changeDesc := ""
|
changeDesc := []string{}
|
||||||
delDesc := ""
|
delDesc := []string{}
|
||||||
|
|
||||||
for k, recs := range updates {
|
for k, recs := range updates {
|
||||||
chg := &r53.Change{}
|
chg := &r53.Change{}
|
||||||
@ -233,7 +233,7 @@ func (r *route53Provider) GetDomainCorrections(dc *models.DomainConfig) ([]*mode
|
|||||||
if len(recs) == 0 {
|
if len(recs) == 0 {
|
||||||
dels = append(dels, chg)
|
dels = append(dels, chg)
|
||||||
chg.Action = sPtr("DELETE")
|
chg.Action = sPtr("DELETE")
|
||||||
delDesc += strings.Join(namesToUpdate[k], "\n") + "\n"
|
delDesc = append(delDesc, strings.Join(namesToUpdate[k], "\n"))
|
||||||
// on delete just submit the original resource set we got from r53.
|
// on delete just submit the original resource set we got from r53.
|
||||||
for _, r := range records {
|
for _, r := range records {
|
||||||
if unescape(r.Name) == k.NameFQDN && (*r.Type == k.Type || k.Type == "R53_ALIAS_"+*r.Type) {
|
if unescape(r.Name) == k.NameFQDN && (*r.Type == k.Type || k.Type == "R53_ALIAS_"+*r.Type) {
|
||||||
@ -246,7 +246,7 @@ func (r *route53Provider) GetDomainCorrections(dc *models.DomainConfig) ([]*mode
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
changes = append(changes, chg)
|
changes = append(changes, chg)
|
||||||
changeDesc += strings.Join(namesToUpdate[k], "\n") + "\n"
|
changeDesc = append(changeDesc, strings.Join(namesToUpdate[k], "\n"))
|
||||||
// on change or create, just build a new record set from our desired state
|
// on change or create, just build a new record set from our desired state
|
||||||
chg.Action = sPtr("UPSERT")
|
chg.Action = sPtr("UPSERT")
|
||||||
rrset = &r53.ResourceRecordSet{
|
rrset = &r53.ResourceRecordSet{
|
||||||
@ -297,20 +297,29 @@ func (r *route53Provider) GetDomainCorrections(dc *models.DomainConfig) ([]*mode
|
|||||||
batchSize := getBatchSize(len(dels), 1000)
|
batchSize := getBatchSize(len(dels), 1000)
|
||||||
batch := dels[:batchSize]
|
batch := dels[:batchSize]
|
||||||
dels = dels[batchSize:]
|
dels = dels[batchSize:]
|
||||||
|
delDescBatch := delDesc[:batchSize]
|
||||||
|
delDesc = delDesc[batchSize:]
|
||||||
|
|
||||||
|
delDescBatchStr := "\n" + strings.Join(delDescBatch, "\n") + "\n"
|
||||||
|
|
||||||
delReq := &r53.ChangeResourceRecordSetsInput{
|
delReq := &r53.ChangeResourceRecordSetsInput{
|
||||||
ChangeBatch: &r53.ChangeBatch{Changes: batch},
|
ChangeBatch: &r53.ChangeBatch{Changes: batch},
|
||||||
}
|
}
|
||||||
addCorrection(delDesc, delReq)
|
addCorrection(delDescBatchStr, delReq)
|
||||||
}
|
}
|
||||||
|
|
||||||
for len(changes) > 0 {
|
for len(changes) > 0 {
|
||||||
batchSize := getBatchSize(len(changes), 500)
|
batchSize := getBatchSize(len(changes), 500)
|
||||||
batch := changes[:batchSize]
|
batch := changes[:batchSize]
|
||||||
changes = changes[batchSize:]
|
changes = changes[batchSize:]
|
||||||
|
changeDescBatch := changeDesc[:batchSize]
|
||||||
|
changeDesc = changeDesc[batchSize:]
|
||||||
|
changeDescBatchStr := "\n" + strings.Join(changeDescBatch, "\n") + "\n"
|
||||||
|
|
||||||
changeReq := &r53.ChangeResourceRecordSetsInput{
|
changeReq := &r53.ChangeResourceRecordSetsInput{
|
||||||
ChangeBatch: &r53.ChangeBatch{Changes: batch},
|
ChangeBatch: &r53.ChangeBatch{Changes: batch},
|
||||||
}
|
}
|
||||||
addCorrection(changeDesc, changeReq)
|
addCorrection(changeDescBatchStr, changeReq)
|
||||||
}
|
}
|
||||||
|
|
||||||
return corrections, nil
|
return corrections, nil
|
||||||
|
Reference in New Issue
Block a user