Kantoor. DnsRecords. Salt. State
(Kantoor v1.0.0)
The pure comparison and merge between what Kantoor expects
(Kantoor.DnsRecords) and what Salt holds.
Per record
classify/3 answers one of:
:in_sync- the expected value is at the name;:missing- the name has no record of that type;:different- it has records of that type, but not this value; adding this one is safe (SRV sets may hold several targets);:conflict- adding it would break or hijack someone else's answer::cname_elsewhere- a CNAME at the name points at another target (an autodiscover served by another system is not overwritten);:data_blocks_cname- another type is at a name where Kantoor wants a CNAME (DNS forbids CNAME beside other data);:cname_blocks- a CNAME occupies a name where Kantoor wants data;:path_taken- another application set the CalDAV/CardDAVpath=TXT; a second path record would make the answer a coin toss;:multiple_paths- Kantoor's path is there and another one is;
:unavailable- the RFC 6186 "service not available" marker, which is never published.
:conflict is never written over. The operator sees what is in the way.
What a write does
plan/3 builds the smallest set of writes that makes Salt hold everything
Kantoor expects and removes only values recorded as Kantoor's own
(Kantoor.DnsRecords.OwnedRecord). It never drops a value it did not add:
- existing values at a name/type stay, except a value Kantoor owns that is no longer part of the record set;
- the expected values that are
:missingor:differentare added; - a type whose record is in conflict is left completely alone;
- a write keeps the rrset's existing TTL when there was one, so adding a value does not retime anyone else's records.
The writes are rendered as one zone-file text for Salt's import API
(zone_text/1); an rrset that would become empty is a delete instead (an
import in merge mode can only add and replace). added/1 names the values
that were not already there, which are exactly the ones Kantoor may record as
its own.
Summary
Functions
The values a write adds (absent before it), the only ones Kantoor may own.
Classifies every expected record. owned is owned/1 of the stored rows.
Indexes Salt's rrset list by name and type, keeping only enabled records.
A Salt/absolute name: lower case, no trailing dot.
The owned-value set from Kantoor.DnsRecords.OwnedRecord rows.
Classifies and plans the smallest write set. See the module documentation.
Renders the planned writes as one RFC 1035 master-file text for the import API.
Types
@type entry() :: %{ record: Kantoor.DnsRecords.Record.t(), status: status(), existing: [String.t()], owned: boolean(), reason: atom() | nil }
@type plan() :: %{ entries: [entry()], counts: %{ in_sync: non_neg_integer(), missing: non_neg_integer(), different: non_neg_integer(), conflict: non_neg_integer(), unavailable: non_neg_integer() }, writes: [write()], deletes: [%{name: String.t(), type: String.t(), records: [String.t()]}], conflicts: [entry()] }
@type status() :: :in_sync | :missing | :different | :conflict | :unavailable
@type write() :: %{ name: String.t(), type: String.t(), ttl: pos_integer(), records: [String.t()], added: [%{value: String.t(), content: String.t(), ttl: pos_integer()}] }
Functions
@spec added([write()]) :: [ %{name: String.t(), type: String.t(), value: String.t(), ttl: integer()} ]
The values a write adds (absent before it), the only ones Kantoor may own.
@spec classify([Kantoor.DnsRecords.Record.t()], index(), owned()) :: [entry()]
Classifies every expected record. owned is owned/1 of the stored rows.
Indexes Salt's rrset list by name and type, keeping only enabled records.
Names are absolute without a trailing dot; the map is keyed the same way, so
a Kantoor.DnsRecords.Record name (which ends in a dot) is normalised by
name/1 before lookup.
A Salt/absolute name: lower case, no trailing dot.
The owned-value set from Kantoor.DnsRecords.OwnedRecord rows.
@spec plan([Kantoor.DnsRecords.Record.t()], index(), [ %{name: String.t(), type: String.t(), value: String.t()} ]) :: plan()
Classifies and plans the smallest write set. See the module documentation.
Renders the planned writes as one RFC 1035 master-file text for the import API.