2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-10-02 08:51:44 +00:00

refactor(xcat-core): report the Kea DDNS deferral through the warning key

kea_build_ddns_intent returned the deferral under a deferred key. No other
xCAT code uses that key: dhcp.pm reports through error, warning, node and
data, and makedhcp already passed this message to the callback as a warning.

The intent hash now carries the message under warning, so one name describes
it from the hash to the callback. Behaviour does not change.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
Daniel Hilst
2026-09-29 22:28:58 -03:00
parent 22b43ff7b3
commit 5e69d912ec
2 changed files with 10 additions and 10 deletions
+4 -4
View File
@@ -2706,9 +2706,9 @@ sub kea_process_request
flock($dhcplockfd, LOCK_UN);
return;
}
my ( $using_ddns, $ddns_deferred ) =
my ( $using_ddns, $ddns_warning ) =
kea_apply_ddns_intent($ddns_intent, $intent4, $intent6, $using_dhcp6);
$callback->({ warning => [$ddns_deferred] }) if $ddns_deferred;
$callback->({ warning => [$ddns_warning] }) if $ddns_warning;
if ($opt->{n}) {
my $result = $backend->write_dhcp4_config($intent4, backup_existing => 1);
@@ -3062,7 +3062,7 @@ sub kea_build_ddns_intent
# xcatconfig sets site.dnshandler=ddns on every new installation, and only makedns -n writes
# the key material.
my ( $key_algorithm, $key_secret ) = kea_ddns_key();
return { deferred => "No DDNS key material exists yet. DNS updates stay off until makedns -n runs." } unless $key_secret;
return { warning => "No DDNS key material exists yet. DNS updates stay off until makedns -n runs." } unless $key_secret;
my @tsig_keys = (
{
@@ -3146,7 +3146,7 @@ sub kea_apply_ddns_intent
my ( $ddns_intent, $intent4, $intent6, $using_dhcp6 ) = @_;
return ( 0, undef ) unless $ddns_intent;
return ( 0, $ddns_intent->{deferred} ) if $ddns_intent->{deferred};
return ( 0, $ddns_intent->{warning} ) if $ddns_intent->{warning};
my $dhcp_ddns = kea_dhcp_ddns_section();
$intent4->{'dhcp-ddns'} = $dhcp_ddns;
+6 -6
View File
@@ -99,7 +99,7 @@ $xCAT::Table::networks = DDNSNetworksTable->new( \%provision_network );
my $ddns_intent = xCAT_plugin::dhcp::kea_build_ddns_intent();
ok( !$ddns_intent->{error}, 'a missing DDNS key is not an error' );
like(
$ddns_intent->{deferred},
$ddns_intent->{warning},
qr/makedns -n/,
'the deferral names the command that creates the key',
);
@@ -107,12 +107,12 @@ $xCAT::Table::networks = DDNSNetworksTable->new( \%provision_network );
my %dhcp4 = ( subnets => [ { id => 1 } ] );
my %dhcp6 = ( subnets => [ { id => 10001 } ] );
my ( $using_ddns, $deferred ) =
my ( $using_ddns, $warning ) =
xCAT_plugin::dhcp::kea_apply_ddns_intent( $ddns_intent, \%dhcp4, \%dhcp6, 1 );
is( $using_ddns, 0, 'DNS updates stay off' );
like(
$deferred,
$warning,
qr/DNS updates stay off until makedns -n runs/,
'makedhcp -n warns that DNS updates stay off',
);
@@ -129,7 +129,7 @@ $xCAT::Table::networks = DDNSNetworksTable->new( \%provision_network );
local *xCAT_plugin::dhcp::kea_ddns_key = sub { return ( 'HMAC-SHA256', 'c2VjcmV0' ); };
my $ddns_intent = xCAT_plugin::dhcp::kea_build_ddns_intent();
ok( !$ddns_intent->{deferred}, 'key material defers nothing' );
ok( !$ddns_intent->{warning}, 'key material defers nothing' );
ok( !$ddns_intent->{error}, 'key material reports no error' );
is_deeply(
$ddns_intent->{'tsig-keys'},
@@ -144,11 +144,11 @@ $xCAT::Table::networks = DDNSNetworksTable->new( \%provision_network );
my %dhcp4;
my %dhcp6;
my ( $using_ddns, $deferred ) =
my ( $using_ddns, $warning ) =
xCAT_plugin::dhcp::kea_apply_ddns_intent( $ddns_intent, \%dhcp4, \%dhcp6, 1 );
is( $using_ddns, 1, 'DNS updates stay on' );
is( $deferred, undef, 'makedhcp -n warns about nothing' );
is( $warning, undef, 'makedhcp -n warns about nothing' );
is( $dhcp4{'dhcp-ddns'}{'server-port'}, 53001, 'the DHCPv4 configuration keeps the D2 connection' );
is( $dhcp6{'dhcp-ddns'}{'server-port'}, 53001, 'the DHCPv6 configuration keeps the D2 connection' );
ok( $dhcp4{'ddns-send-updates'}, 'the DHCPv4 configuration requests DNS updates' );