Skip to content

Commit

Permalink
Incorporate review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vjsamuel committed Jan 9, 2020
1 parent feeff7f commit fcb2025
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 1 addition & 2 deletions libbeat/autodiscover/providers/kubernetes/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import (
"fmt"
"time"

"github.com/elastic/beats/libbeat/common/kubernetes/metadata"

"github.com/gofrs/uuid"
v1 "k8s.io/api/core/v1"
k8s "k8s.io/client-go/kubernetes"
Expand All @@ -31,6 +29,7 @@ import (
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/common/bus"
"github.com/elastic/beats/libbeat/common/kubernetes"
"github.com/elastic/beats/libbeat/common/kubernetes/metadata"
"github.com/elastic/beats/libbeat/common/safemapstr"
"github.com/elastic/beats/libbeat/logp"
)
Expand Down
10 changes: 7 additions & 3 deletions libbeat/autodiscover/providers/kubernetes/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,14 @@ func NewPodEventer(uuid uuid.UUID, cfg *common.Config, client k8s.Interface, pub
metaConf := config.AddResourceMetadata
if metaConf != nil {
if metaConf.Node != nil && metaConf.Node.Enabled() {
nodeWatcher, err = kubernetes.NewWatcher(client, &kubernetes.Node{}, kubernetes.WatchOptions{
options := kubernetes.WatchOptions{
SyncTimeout: config.SyncPeriod,
Node: config.Node,
}, nil)
}
if config.Namespace != "" {
options.Namespace = config.Namespace
}
nodeWatcher, err = kubernetes.NewWatcher(client, &kubernetes.Node{}, options, nil)
if err != nil {
return nil, fmt.Errorf("couldn't create watcher for %T due to error %+v", &kubernetes.Node{}, err)
}
Expand All @@ -97,7 +101,7 @@ func NewPodEventer(uuid uuid.UUID, cfg *common.Config, client k8s.Interface, pub
return nil, fmt.Errorf("couldn't create watcher for %T due to error %+v", &kubernetes.Namespace{}, err)
}

nodeMeta = metadata.NewNamespaceMetadataGenerator(metaConf.Namespace, namespaceWatcher.Store())
namespaceMeta = metadata.NewNamespaceMetadataGenerator(metaConf.Namespace, namespaceWatcher.Store())
}
}

Expand Down

0 comments on commit fcb2025

Please sign in to comment.