Skip to content

Commit

Permalink
Merge pull request #81 from akamai/dns_maint
Browse files Browse the repository at this point in the history
Dns maint
  • Loading branch information
edglynes authored Apr 21, 2020
2 parents 299a7e7 + 2107399 commit 6017f10
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
40 changes: 31 additions & 9 deletions configdns-v2/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,29 @@ func NewRecordBody(params RecordBody) *RecordBody {
return recordbody
}

func (record *RecordBody) Save(zone string) error {
// Eval option lock arg passed into writable endpoints. Default is true, e.g. lock
func localLock(lockArg []bool) bool {

for _, lock := range lockArg {
// should only be one entry
return lock
}

return true

}

func (record *RecordBody) Save(zone string, recLock ...bool) error {
// This lock will restrict the concurrency of API calls
// to 1 save request at a time. This is needed for the Soa.Serial value which
// is required to be incremented for every subsequent update to a zone
// so we have to save just one request at a time to ensure this is always
// incremented properly
zoneRecordWriteLock.Lock()
defer zoneRecordWriteLock.Unlock()

if localLock(recLock) {
zoneRecordWriteLock.Lock()
defer zoneRecordWriteLock.Unlock()
}

req, err := client.NewJSONRequest(
Config,
Expand Down Expand Up @@ -116,14 +131,17 @@ func (record *RecordBody) Save(zone string) error {
return nil
}

func (record *RecordBody) Update(zone string) error {
func (record *RecordBody) Update(zone string, recLock ...bool) error {
// This lock will restrict the concurrency of API calls
// to 1 save request at a time. This is needed for the Soa.Serial value which
// is required to be incremented for every subsequent update to a zone
// so we have to save just one request at a time to ensure this is always
// incremented properly
zoneRecordWriteLock.Lock()
defer zoneRecordWriteLock.Unlock()

if localLock(recLock) {
zoneRecordWriteLock.Lock()
defer zoneRecordWriteLock.Unlock()
}

req, err := client.NewJSONRequest(
Config,
Expand Down Expand Up @@ -159,14 +177,18 @@ func (record *RecordBody) Update(zone string) error {
return nil
}

func (record *RecordBody) Delete(zone string) error {
func (record *RecordBody) Delete(zone string, recLock ...bool) error {
// This lock will restrict the concurrency of API calls
// to 1 save request at a time. This is needed for the Soa.Serial value which
// is required to be incremented for every subsequent update to a zone
// so we have to save just one request at a time to ensure this is always
// incremented properly
zoneRecordWriteLock.Lock()
defer zoneRecordWriteLock.Unlock()

if localLock(recLock) {
zoneRecordWriteLock.Lock()
defer zoneRecordWriteLock.Unlock()
}

req, err := client.NewJSONRequest(
Config,
"DELETE",
Expand Down
1 change: 0 additions & 1 deletion configdns-v2/record_lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ func ParseRData(rtype string, rdata []string) map[string]interface{} {
parts := strings.Split(rcontent, " ")
newrdata = append(newrdata, parts[1])
}
sort.Strings(newrdata)
fieldMap["target"] = newrdata

case "NAPTR":
Expand Down

0 comments on commit 6017f10

Please sign in to comment.