--- Begin Message ---
This fixes an issue with dual stacking, when using a zone with both a V4 and V6
subnet and the same dns suffix, pve-network will try to set both dns records 
(type A and AAAA) in the
same powerdns rrset, causing an api error, and effectively causing no forward 
dns records being created.

This change edits the `get_zone_rrset` function so that it takes the dns record 
type into account.

Signed-off-by: Matthieu Pignolet <m...@mpgn.dev>
---
 src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm 
b/src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm
index dae63d1..70b7b80 100644
--- a/src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm
+++ b/src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm
@@ -57,7 +57,7 @@ sub add_a_record {
     my $fqdn = $hostname.".".$zone.".";
 
     my $zonecontent = get_zone_content($plugin_config, $zone);
-    my $existing_rrset = get_zone_rrset($zonecontent, $fqdn);
+    my $existing_rrset = get_zone_rrset($zonecontent, $fqdn, $type);
 
     my $final_records = [];
     for my $record (@{$existing_rrset->{records}}) {
@@ -133,7 +133,7 @@ sub del_a_record {
     my $type = Net::IP::ip_is_ipv6($ip) ? "AAAA" : "A";
 
     my $zonecontent = get_zone_content($plugin_config, $zone);
-    my $existing_rrset = get_zone_rrset($zonecontent, $fqdn);
+    my $existing_rrset = get_zone_rrset($zonecontent, $fqdn, $type);
 
     my $final_records = [ grep { $_->{content} ne $ip } 
$existing_rrset->{records}->@* ];
     my $final_records_size = scalar($final_records->@*);
@@ -278,10 +278,10 @@ sub get_zone_content {
 }
 
 sub get_zone_rrset {
-    my ($zonecontent, $name) = @_;
+    my ($zonecontent, $name, $type) = @_;
 
     for my $rrset (@{$zonecontent->{rrsets}}) {
-       return $rrset if $rrset->{name} eq $name;
+       return $rrset if $rrset->{name} eq $name and ($rrset->{type} eq $type);
     }
     return; # not found
 }
-- 
2.48.1




--- End Message ---
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to