Commit 5740c900 authored by Daniel Salzman's avatar Daniel Salzman
Browse files

Merge branch 'knotc_notify' into 'master'

ctl: added knotc zone-notify command to send notify manually

See merge request !877
parents c7a5560a e66e24b3
Pipeline #32824 passed with stages
in 15 minutes and 7 seconds
......@@ -109,6 +109,10 @@ newer zone, a transfer is scheduled. This command is valid for slave zones.
Trigger a zone transfer from the zone\(aqs master. The server doesn\(aqt check the
serial of the master\(aqs zone. This command is valid for slave zones.
.TP
\fBzone\-notify\fP [\fIzone\fP\&...]
Trigger a NOTIFY message to all configured remotes. This can help in cases
when previous NOTIFY had been lost or the slaves offline.
.TP
\fBzone\-flush\fP [\fIzone\fP\&...] [\fB+outdir\fP \fIdirectory\fP]
Trigger a zone journal flush into the zone file. If output dir is specified,
instead of flushing the zonefile, the zone is dumped to a file in the specified
......
......@@ -86,6 +86,10 @@ Actions
Trigger a zone transfer from the zone's master. The server doesn't check the
serial of the master's zone. This command is valid for slave zones.
**zone-notify** [*zone*...]
Trigger a NOTIFY message to all configured remotes. This can help in cases
when previous NOTIFY had been lost or the slaves offline.
**zone-flush** [*zone*...] [**+outdir** *directory*]
Trigger a zone journal flush into the zone file. If output dir is specified,
instead of flushing the zonefile, the zone is dumped to a file in the specified
......
......@@ -312,6 +312,15 @@ static int zone_retransfer(zone_t *zone, ctl_args_t *args)
return KNOT_EOK;
}
static int zone_notify(zone_t *zone, ctl_args_t *args)
{
UNUSED(args);
zone_events_schedule_user(zone, ZONE_EVENT_NOTIFY);
return KNOT_EOK;
}
static int zone_flush(zone_t *zone, ctl_args_t *args)
{
if (MATCH_AND_FILTER(args, CTL_FILTER_FLUSH_OUTDIR)) {
......@@ -1173,6 +1182,8 @@ static int ctl_zone(ctl_args_t *args, ctl_cmd_t cmd)
return zones_apply(args, zone_refresh);
case CTL_ZONE_RETRANSFER:
return zones_apply(args, zone_retransfer);
case CTL_ZONE_NOTIFY:
return zones_apply(args, zone_notify);
case CTL_ZONE_FLUSH:
return zones_apply(args, zone_flush);
case CTL_ZONE_SIGN:
......@@ -1605,6 +1616,7 @@ static const desc_t cmd_table[] = {
[CTL_ZONE_RELOAD] = { "zone-reload", ctl_zone },
[CTL_ZONE_REFRESH] = { "zone-refresh", ctl_zone },
[CTL_ZONE_RETRANSFER] = { "zone-retransfer", ctl_zone },
[CTL_ZONE_NOTIFY] = { "zone-notify", ctl_zone },
[CTL_ZONE_FLUSH] = { "zone-flush", ctl_zone },
[CTL_ZONE_SIGN] = { "zone-sign", ctl_zone },
[CTL_ZONE_KSK_SBM] = { "zone-ksk-submitted", ctl_zone },
......
......@@ -58,6 +58,7 @@ typedef enum {
CTL_ZONE_RELOAD,
CTL_ZONE_REFRESH,
CTL_ZONE_RETRANSFER,
CTL_ZONE_NOTIFY,
CTL_ZONE_FLUSH,
CTL_ZONE_SIGN,
CTL_ZONE_KSK_SBM,
......
......@@ -44,6 +44,7 @@
#define CMD_ZONE_RELOAD "zone-reload"
#define CMD_ZONE_REFRESH "zone-refresh"
#define CMD_ZONE_RETRANSFER "zone-retransfer"
#define CMD_ZONE_NOTIFY "zone-notify"
#define CMD_ZONE_FLUSH "zone-flush"
#define CMD_ZONE_SIGN "zone-sign"
#define CMD_ZONE_KSK_SBM "zone-ksk-submitted"
......@@ -238,6 +239,7 @@ static void format_data(ctl_cmd_t cmd, knot_ctl_type_t data_type,
case CTL_ZONE_RELOAD:
case CTL_ZONE_REFRESH:
case CTL_ZONE_RETRANSFER:
case CTL_ZONE_NOTIFY:
case CTL_ZONE_FLUSH:
case CTL_ZONE_SIGN:
case CTL_ZONE_KSK_SBM:
......@@ -358,6 +360,7 @@ static void format_block(ctl_cmd_t cmd, bool failed, bool empty)
case CTL_ZONE_RELOAD:
case CTL_ZONE_REFRESH:
case CTL_ZONE_RETRANSFER:
case CTL_ZONE_NOTIFY:
case CTL_ZONE_FLUSH:
case CTL_ZONE_SIGN:
case CTL_ZONE_KSK_SBM:
......@@ -1065,6 +1068,7 @@ const cmd_desc_t cmd_table[] = {
{ CMD_ZONE_RELOAD, cmd_zone_ctl, CTL_ZONE_RELOAD, CMD_FOPT_ZONE },
{ CMD_ZONE_REFRESH, cmd_zone_ctl, CTL_ZONE_REFRESH, CMD_FOPT_ZONE },
{ CMD_ZONE_RETRANSFER, cmd_zone_ctl, CTL_ZONE_RETRANSFER, CMD_FOPT_ZONE },
{ CMD_ZONE_NOTIFY, cmd_zone_ctl, CTL_ZONE_NOTIFY, CMD_FOPT_ZONE },
{ CMD_ZONE_FLUSH, cmd_zone_filter_ctl, CTL_ZONE_FLUSH, CMD_FOPT_ZONE },
{ CMD_ZONE_SIGN, cmd_zone_ctl, CTL_ZONE_SIGN, CMD_FOPT_ZONE },
{ CMD_ZONE_KSK_SBM, cmd_zone_ctl, CTL_ZONE_KSK_SBM, CMD_FREQ_ZONE },
......@@ -1110,6 +1114,7 @@ static const cmd_help_t cmd_help_table[] = {
{ CMD_ZONE_MEMSTATS, "[<zone>...]", "Estimate memory use for the zone. (*)" },
{ CMD_ZONE_RELOAD, "[<zone>...]", "Reload a zone from a disk." },
{ CMD_ZONE_REFRESH, "[<zone>...]", "Force slave zone refresh." },
{ CMD_ZONE_NOTIFY, "[<zone>...]", "Send a NOTIFY message to all configured remotes." },
{ CMD_ZONE_RETRANSFER, "[<zone>...]", "Force slave zone retransfer (no serial check)." },
{ CMD_ZONE_FLUSH, "[<zone>...] [<filter>...]", "Flush zone journal into the zone file." },
{ CMD_ZONE_SIGN, "[<zone>...]", "Re-sign the automatically signed zone." },
......
$ORIGIN notify.
$TTL 3600
@ SOA dns1 hostmaster 2010111201 10800 3600 1209600 7200
NS dns1
NS dns2
MX 10 mail
dns1 A 192.0.2.1
AAAA 2001:DB8::1
dns2 A 192.0.2.2
AAAA 2001:DB8::2
mail A 192.0.2.3
AAAA 2001:DB8::3
$ORIGIN notify.
$TTL 3600
@ SOA dns1 hostmaster 2010111202 10800 3600 1209600 7200
NS dns1
NS dns2
MX 10 mail
dns1 A 192.0.2.1
AAAA 2001:DB8::1
dns2 A 192.0.2.2
AAAA 2001:DB8::2
mail A 192.0.2.3
AAAA 2001:DB8::3
node A 1.2.3.4
#!/usr/bin/env python3
'''Test for knotc zone-notify'''
from dnstest.test import Test
t = Test()
master = t.server("knot")
slave = t.server("knot")
zone = t.zone("notify.", storage=".")
t.link(zone, master, slave)
t.start()
master.zone_wait(zone)
slave.zone_wait(zone)
slave.stop()
master.update_zonefile(zone, version=1) # notify doesn't succeed while slave is offline
master.reload()
master.zone_wait(zone)
slave.start() # slave starts with older version of zone and doesn't attempt refersh since it's in timers
slave.zone_wait(zone)
resp = slave.dig("node.notify.", "A")
resp.check(rcode="NXDOMAIN")
master.ctl("zone-notify")
t.sleep(2)
resp = slave.dig("node.notify.", "A")
resp.check(rcode="NOERROR", rdata="1.2.3.4")
t.end()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment