-
Notifications
You must be signed in to change notification settings - Fork 35
Add flag to disable annotation discovery #82
Conversation
- Move discovery of endpoints from resources to new endpointCreator - Add unit tests for new endpointCreator - Add documentation about new config value disable_annotation_discovery [MONIT-21378](https://wavefront.atlassian.net/browse/MONIT-21378)
db2aef4
to
b12b7bb
Compare
Containers: make([]v1.Container, 0), | ||
} | ||
|
||
got := e.discoverEndpoints(resource) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why this discovers when the resource does not have any annotations on it (under the meta
section)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works because down in the encoder it assumes that we're using an annotation and then fills in all the default values when nothing is defined in meta:
func Param(meta metav1.ObjectMeta, annotation, cfgVal, defaultVal string) string {
value := ""
// give precedence to annotation
if annotation != "" {
value = meta.GetAnnotations()[annotation]
}
if value == "" {
// then config
value = cfgVal
}
if value == "" {
// then default
value = defaultVal
}
return value
}
func (e *endpointCreator) discoverEndpointsWithAnnotations(resource discovery.Resource) []*discovery.Endpoint { | ||
var eps []*discovery.Endpoint | ||
// delegate to runtime handlers if no matching delegate | ||
if ep := e.makeEndpoint(resource, discovery.PluginConfig{Type: "prometheus", Name: "example"}); ep != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably remove the example
name (just leave the name empty) since that is used to determine whether to check for annotations here:
if rule.Name == "" && scrape != "true" { |
Kind: discovery.PodType.String(), | ||
IP: "0.0.0.0", | ||
Meta: metav1.ObjectMeta{}, | ||
Containers: make([]v1.Container, 0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This resource needs an annotation on it for it to validly get skipped
MONIT-21378