Skip to content

Commit

Permalink
Remove init checks for valid label and field selectors (influxdata#7198)
Browse files Browse the repository at this point in the history
Importing k8s.io/klog starts a long running goroutine at init time.
  • Loading branch information
danielnelson authored Mar 18, 2020
1 parent e804374 commit 3a737b0
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 19 deletions.
2 changes: 0 additions & 2 deletions docs/LICENSE_OF_DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ following works:
- gopkg.in/olivere/elastic.v5 [MIT License](https://github.com/olivere/elastic/blob/v5.0.76/LICENSE)
- gopkg.in/tomb.v1 [BSD 3-Clause Clear License](https://github.com/go-tomb/tomb/blob/v1/LICENSE)
- gopkg.in/yaml.v2 [Apache License 2.0](https://github.com/go-yaml/yaml/blob/v2.2.2/LICENSE)
- k8s.io/apimachinery [Apache License 2.0](https://github.com/kubernetes/apimachinery/blob/master/LICENSE)
- k8s.io/klog [Apache License 2.0](https://github.com/kubernetes/klog/blob/master/LICENSE)

## telegraf used and modified code from these projects
- github.com/DataDog/datadog-agent [Apache License 2.0](https://github.com/DataDog/datadog-agent/LICENSE)
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ require (
gopkg.in/olivere/elastic.v5 v5.0.70
gopkg.in/yaml.v2 v2.2.4
gotest.tools v2.2.0+incompatible // indirect
k8s.io/apimachinery v0.17.1
k8s.io/apimachinery v0.17.1 // indirect
)

// replaced due to https://github.com/satori/go.uuid/issues/73
Expand Down
16 changes: 0 additions & 16 deletions plugins/inputs/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/internal/tls"
"github.com/influxdata/telegraf/plugins/inputs"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
)

const acceptHeader = `application/vnd.google.protobuf;proto=io.prometheus.client.MetricFamily;encoding=delimited;q=0.7,text/plain;version=0.0.4;q=0.3,*/*;q=0.1`
Expand Down Expand Up @@ -138,20 +136,6 @@ func (p *Prometheus) Init() error {
p.Log.Warnf("Use of deprecated configuration: 'metric_version = 1'; please update to 'metric_version = 2'")
}

if len(p.KubernetesLabelSelector) > 0 {
_, err := labels.Parse(p.KubernetesLabelSelector)
if err != nil {
return fmt.Errorf("label selector validation failed %q: %v", p.KubernetesLabelSelector, err)
}
}

if len(p.KubernetesFieldSelector) > 0 {
_, err := fields.ParseSelector(p.KubernetesFieldSelector)
if err != nil {
return fmt.Errorf("field selector validation failed %s: %v", p.KubernetesFieldSelector, err)
}
}

return nil
}

Expand Down

0 comments on commit 3a737b0

Please sign in to comment.