Skip to content

Commit

Permalink
DNS logs will contain error rather than actual pod error visibility. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Tatsinnit authored Sep 16, 2021
1 parent 165e024 commit 118d62a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/collector/dns_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ func (collector *DNSCollector) GetName() string {
func (collector *DNSCollector) Collect() error {
output, err := utils.ReadFileContent("/etchostlogs/resolv.conf")
if err != nil {
return err
output = err.Error()
}

collector.data["virtualmachine"] = output

output, err = utils.ReadFileContent("/etc/resolv.conf")
if err != nil {
return err
output = err.Error()
}

collector.data["kubernetes"] = output
Expand Down
34 changes: 34 additions & 0 deletions pkg/collector/dns_collector_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package collector

import (
"testing"
)

func TestNewDNSCollector(t *testing.T) {
tests := []struct {
name string
want int
wantErr bool
}{
{
name: "get dns logs",
want: 1,
wantErr: false,
},
}

c := NewDNSCollector()

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := c.Collect()
if (err != nil) != tt.wantErr {
t.Errorf("Collect() error = %v, wantErr %v", err, tt.wantErr)
}
raw := c.GetData()
if len(raw) < tt.want {
t.Errorf("len(GetData()) = %v, want %v", len(raw), tt.want)
}
})
}
}

0 comments on commit 118d62a

Please sign in to comment.