mirror of
https://github.com/zalando-incubator/kube-metrics-adapter.git
synced 2026-05-30 17:37:25 +00:00
Permit disregarding incompatible HPAs (#95)
* This commit adds a --disregard-incompatible-hpas that makes the HPA provider stop erroring out when a collector cannot be created for a metric in a HPA. Useful when kube-metrics-adapter runs alongside another metrics provider. Fixes issue #94. Signed-off-by: Tomás Pinho <me@tomaspinho.com> * Make tests pass Signed-off-by: Tomás Pinho <me@tomaspinho.com> * Wraps the Plugin Not Found error in a new type that can be checked by the caller of a function to determine if its contents should be logged or added as an event to the HPA, when this HPA is incompatible. The disregardIncompatibleHPAs is now targetting only the log or addition of the same event. Signed-off-by: Tomás Pinho <me@tomaspinho.com> * Invert if expression to select when we should log CreateNewMetricsCollector errors: don't log when both conditions are true - it's not a PluginNotFoundError and disregardIncompatibleHPAs flag is set to true. This way, if an error is NOT PluginNotFoundError it will always be logged, and when it IS PluginNotFoundError it will only be logged when disregardIncompatibleHPAs is false. Signed-off-by: Tomás Pinho <me@tomaspinho.com> * Remove redundant "whether to" Signed-off-by: Tomás Pinho <me@tomaspinho.com> * Add test case for updating HPAs via HPA Provider while disregarding incompatible HPAs. Signed-off-by: Tomás Pinho <me@tomaspinho.com>
This commit is contained in:
+6
-2
@@ -110,7 +110,8 @@ func NewCommandStartAdapterServer(stopCh <-chan struct{}) *cobra.Command {
|
||||
"whether to enable AWS external metrics")
|
||||
flags.StringSliceVar(&o.AWSRegions, "aws-region", o.AWSRegions, "the AWS regions which should be monitored. eg: eu-central, eu-west-1")
|
||||
flags.StringVar(&o.MetricsAddress, "metrics-address", o.MetricsAddress, "The address where to serve prometheus metrics")
|
||||
|
||||
flags.BoolVar(&o.DisregardIncompatibleHPAs, "disregard-incompatible-hpas", o.DisregardIncompatibleHPAs, ""+
|
||||
"disregard failing to create collectors for incompatible HPAs")
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -228,7 +229,7 @@ func (o AdapterServerOptions) RunCustomMetricsAdapterServer(stopCh <-chan struct
|
||||
collectorFactory.RegisterExternalCollector([]string{collector.AWSSQSQueueLengthMetric}, collector.NewAWSCollectorPlugin(awsSessions))
|
||||
}
|
||||
|
||||
hpaProvider := provider.NewHPAProvider(client, 30*time.Second, 1*time.Minute, collectorFactory)
|
||||
hpaProvider := provider.NewHPAProvider(client, 30*time.Second, 1*time.Minute, collectorFactory, o.DisregardIncompatibleHPAs)
|
||||
|
||||
go hpaProvider.Run(ctx)
|
||||
|
||||
@@ -332,4 +333,7 @@ type AdapterServerOptions struct {
|
||||
MetricsAddress string
|
||||
// SkipperBackendWeightAnnotation is the annotation on the ingress indicating the backend weights
|
||||
SkipperBackendWeightAnnotation []string
|
||||
// Whether to disregard failing to create collectors for incompatible HPAs - such as when using
|
||||
// kube-metrics-adapter beside another Metrics Provider
|
||||
DisregardIncompatibleHPAs bool
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user