Continue checking cert from other sources if error occurs (#5381)
This commit is contained in:
parent
1a81e49d05
commit
1137fa50ad
|
@ -166,7 +166,7 @@ func (c *X509Cert) Gather(acc telegraf.Accumulator) error {
|
||||||
for _, location := range c.Sources {
|
for _, location := range c.Sources {
|
||||||
certs, err := c.getCert(location, c.Timeout.Duration*time.Second)
|
certs, err := c.getCert(location, c.Timeout.Duration*time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot get SSL cert '%s': %s", location, err.Error())
|
acc.AddError(fmt.Errorf("cannot get SSL cert '%s': %s", location, err.Error()))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, cert := range certs {
|
for _, cert := range certs {
|
||||||
|
|
|
@ -4,13 +4,14 @@ import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
|
@ -115,7 +116,7 @@ func TestGatherRemote(t *testing.T) {
|
||||||
|
|
||||||
acc := testutil.Accumulator{}
|
acc := testutil.Accumulator{}
|
||||||
err = sc.Gather(&acc)
|
err = sc.Gather(&acc)
|
||||||
if err != nil {
|
if len(acc.Errors) > 0 {
|
||||||
testErr = true
|
testErr = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +174,7 @@ func TestGatherLocal(t *testing.T) {
|
||||||
|
|
||||||
acc := testutil.Accumulator{}
|
acc := testutil.Accumulator{}
|
||||||
err = sc.Gather(&acc)
|
err = sc.Gather(&acc)
|
||||||
if err != nil {
|
if len(acc.Errors) > 0 {
|
||||||
error = true
|
error = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue