Skip to content

Commit

Permalink
Add check for ignored nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
WGOS committed Feb 5, 2024
1 parent cde210d commit c9c7e24
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func answerForNodes(domain string) []dns.RR {
}

for _, node := range nodes {
if node.IsManager || returnWorkers {
if (node.IsManager || returnWorkers) && !node.Ignore {
rr := new(dns.A)
rr.Hdr = dns.RR_Header{Name: domain, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: uint32(TTL)}
rr.A = net.ParseIP(node.Ip)
Expand Down
4 changes: 4 additions & 0 deletions swarm/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type SwarmNode struct {
Ip string
Hostname string
IsManager bool
Ignore bool
DnsNames []string
}

Expand Down Expand Up @@ -55,11 +56,14 @@ func (client swarmClient) ListActiveNodes() ([]SwarmNode, error) {
ip = node.Status.Addr
}

_, ignore := node.Spec.Annotations.Labels["swarmdns-ignore"]

nodes = append(nodes,
SwarmNode{
Ip: ip,
Hostname: getHostname(node),
IsManager: node.ManagerStatus != nil,
Ignore: ignore,
DnsNames: getDnsNames(node),
})
}
Expand Down

0 comments on commit c9c7e24

Please sign in to comment.