Skip to content

Commit 827fb1e

Browse files
committed
Update RRData incrementally
Compute the adds and deletes required to get from existing RRData to new RRData and perform just those operations instead of doing a complete drop/add of the entire RRData set. Also during an update, do adds before deletes. This eliminates the existence gap and fixes thias#29
1 parent eb6d3f5 commit 827fb1e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/puppet_bind/provider/nsupdate.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# ex: syntax=ruby si sw=2 ts=2 et
12
require 'tempfile'
23

34
module PuppetBind
@@ -27,8 +28,8 @@ def destroy
2728
def flush
2829
return if @properties.empty?
2930
update do |file|
30-
destructo(file)
3131
accio(file)
32+
destructo(file)
3233
end
3334
end
3435

@@ -58,17 +59,25 @@ def update(&block)
5859
end
5960

6061
def accio(file)
61-
newdata.each do |datum|
62+
rrdata_adds.each do |datum|
6263
file.write "update add #{name}. #{resource[:ttl]} #{rrclass} #{type} #{datum}\n"
6364
end
6465
end
6566

6667
def destructo(file)
67-
rrdata.each do |datum|
68+
rrdata_deletes.each do |datum|
6869
file.write "update delete #{name}. #{ttl} #{rrclass} #{type} #{datum}\n"
6970
end
7071
end
7172

73+
def rrdata_adds
74+
newdata - rrdata
75+
end
76+
77+
def rrdata_deletes
78+
type === 'SOA' ? [] : rrdata - newdata
79+
end
80+
7281
def server
7382
resource[:server]
7483
end

0 commit comments

Comments
 (0)