Skip to content

Commit

Permalink
minor: add err checks for results with no answers
Browse files Browse the repository at this point in the history
  • Loading branch information
jpts committed Apr 5, 2023
1 parent 8e57779 commit b7185e1
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cmd/wildcard.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func wildcard(opts *cliOpts) ([]*svcResult, error) {
return nil, err
}

if len(res.raw.Extra) == 0 {
log.Debug().Msgf("No svcs for proto %s found", proto)
continue
}
for _, rr := range res.raw.Extra {
name, ns, ip, err := parseAAnswer(rr.String())
if err != nil {
Expand All @@ -32,12 +36,16 @@ func wildcard(opts *cliOpts) ([]*svcResult, error) {
}
svcs, _ = addUniqueSvcToSvcs(svcs, svc)
}

if len(res.answers) == 0 {
log.Debug().Msgf("No named ports for %s svcs found", proto)
continue
}
for _, rr := range res.answers {
name, ns, port, err := parseSRVAnswer(rr.String())
if err != nil {
return nil, err
}

addPortToSvcs(svcs, name, ns, proto, port, "")
}
}
Expand All @@ -50,7 +58,11 @@ func wildcard(opts *cliOpts) ([]*svcResult, error) {
continue
}

for _, rr := range res.raw.Answer {
if len(res.answers) == 0 {
log.Debug().Msgf("svc %s/%s has no registered endpoints", svc.Namespace, svc.Name)
continue
}
for _, rr := range res.answers {
_, _, ip, err := parseAAnswer(rr.String())
if err != nil {
log.Warn().Err(err)
Expand Down

0 comments on commit b7185e1

Please sign in to comment.