mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-09-05 20:54:22 +08:00
ROUTE53: BUGFIX converting alias to cname causes failure (#3567)
This commit is contained in:
parent
5e4d68b41c
commit
277a260d64
2 changed files with 30 additions and 22 deletions
|
@ -1074,6 +1074,36 @@ func makeTests() []*TestGroup {
|
|||
),
|
||||
),
|
||||
|
||||
// Bug https://github.com/StackExchange/dnscontrol/issues/3493
|
||||
// Summary: R53_ALIAS -> CNAME conversion doesn't work.
|
||||
testgroup("R53_B3493",
|
||||
requires(providers.CanUseRoute53Alias),
|
||||
// Create the R53_ALIAS:
|
||||
tc("b3493 create alias+cname in one step",
|
||||
r53alias("dev-system", "CNAME", "dev-system18.**current-domain**.", "false"),
|
||||
cname("dev-system18", "ec2-54-91-33-155.compute-1.amazonaws.com."),
|
||||
),
|
||||
// Convert R53_ALIAS -> CNAME.
|
||||
tc("convert r53alias to cname",
|
||||
cname("dev-system", "dev-system18.**current-domain**."),
|
||||
cname("dev-system18", "ec2-54-91-33-155.compute-1.amazonaws.com."),
|
||||
),
|
||||
),
|
||||
// Verify CNAME -> R53_ALIAS works too. (not part of the bug, but worth verifying)
|
||||
testgroup("R53_B3493_REV",
|
||||
requires(providers.CanUseRoute53Alias),
|
||||
// Create the CNAME
|
||||
tc("b3493 create cnames",
|
||||
cname("dev-system", "dev-system18.**current-domain**."),
|
||||
cname("dev-system18", "ec2-54-91-33-155.compute-1.amazonaws.com."),
|
||||
),
|
||||
// Convert CNAME -> R53_ALIAS.
|
||||
tc("convert cname to r53_alias",
|
||||
r53alias("dev-system", "CNAME", "dev-system18.**current-domain**.", "false"),
|
||||
cname("dev-system18", "ec2-54-91-33-155.compute-1.amazonaws.com."),
|
||||
),
|
||||
),
|
||||
|
||||
// CLOUDFLAREAPI features
|
||||
|
||||
// CLOUDFLAREAPI: Redirects:
|
||||
|
|
|
@ -307,7 +307,6 @@ func (r *route53Provider) GetZoneRecordsCorrections(dc *models.DomainConfig, exi
|
|||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
instructions = reorderInstructions(instructions)
|
||||
var reports []*models.Correction
|
||||
|
||||
// wasReport := false
|
||||
|
@ -409,27 +408,6 @@ func (r *route53Provider) GetZoneRecordsCorrections(dc *models.DomainConfig, exi
|
|||
return append(reports, corrections...), actualChangeCount, nil
|
||||
}
|
||||
|
||||
// reorderInstructions returns changes reordered to comply with AWS's requirements:
|
||||
// - The R43_ALIAS updates must come after records they refer to. To handle
|
||||
// this, we simply move all R53_ALIAS instructions to the end of the list, thus
|
||||
// guaranteeing they will happen after the records they refer to have been
|
||||
// reated.
|
||||
func reorderInstructions(changes diff2.ChangeList) diff2.ChangeList {
|
||||
var main, tail diff2.ChangeList
|
||||
for _, change := range changes {
|
||||
// Reports should be early in the list.
|
||||
// R53_ALIAS_ records should go to the tail.
|
||||
if change.Type != diff2.REPORT && strings.HasPrefix(change.Key.Type, "R53_ALIAS_") {
|
||||
tail = append(tail, change)
|
||||
} else {
|
||||
main = append(main, change)
|
||||
}
|
||||
}
|
||||
return append(main, tail...)
|
||||
// NB(tlim): This algorithm is O(n*2) but it is simple and usually only
|
||||
// operates on very small lists.
|
||||
}
|
||||
|
||||
func nativeToRecords(set r53Types.ResourceRecordSet, origin string) ([]*models.RecordConfig, error) {
|
||||
results := []*models.RecordConfig{}
|
||||
if set.AliasTarget != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue