1
0
mirror of https://github.com/coreos/prometheus-operator.git synced 2026-02-05 06:45:27 +01:00

feat: add prometheus_operator_feature_gate_info metric

This change also moves the feature gates to the operator config struct.
It means that after a feature gate is enabled/disabled, the operator
will reconcile the managed Prometheus resources which should be the
right thing to do.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
Simon Pasquier
2024-06-06 15:16:47 +02:00
parent 7c17d9cc92
commit 704206b716
5 changed files with 169 additions and 62 deletions

View File

@@ -120,7 +120,7 @@ var (
kubeletSelector operator.LabelSelector
nodeAddressPriority operator.NodeAddressPriority
featureGates *k8sflag.MapStringBool
featureGates = k8sflag.NewMapStringBool(ptr.To(map[string]bool{}))
)
func parseFlags(fs *flag.FlagSet) {
@@ -173,11 +173,9 @@ func parseFlags(fs *flag.FlagSet) {
fs.Var(&cfg.ThanosRulerSelector, "thanos-ruler-instance-selector", "Label selector to filter ThanosRuler Custom Resources to watch.")
fs.Var(&cfg.SecretListWatchSelector, "secret-field-selector", "Field selector to filter Secrets to watch")
// Auto GOMEMLIMIT Ratio
fs.Float64Var(&memlimitRatio, "auto-gomemlimit-ratio", defaultMemlimitRatio, "The ratio of reserved GOMEMLIMIT memory to the detected maximum container or system memory. The value should be greater than 0.0 and less than 1.0. Default: 0.0 (disabled).")
featureGates = k8sflag.NewMapStringBool(ptr.To(make(map[string]bool)))
fs.Var(featureGates, "feature-gates", fmt.Sprintf("Feature gates are a set of key=value pairs that describe Prometheus-Operator features. Available features: %q.", operator.AvailableFeatureGates()))
cfg.RegisterFeatureGatesFlags(fs, featureGates)
logging.RegisterFlags(fs, &logConfig)
versionutil.RegisterFlags(fs)
@@ -199,17 +197,14 @@ func run(fs *flag.FlagSet) int {
stdlog.Fatal(err)
}
gates, err := operator.ValidateFeatureGates(featureGates)
if err != nil {
level.Error(logger).Log(
"msg", "error validating feature gates",
"error", err)
if err := cfg.Gates.UpdateFeatureGates(*featureGates.Map); err != nil {
level.Error(logger).Log("error", err)
return 1
}
level.Info(logger).Log("msg", "Starting Prometheus Operator", "version", version.Info())
level.Info(logger).Log("build_context", version.BuildContext())
level.Info(logger).Log("feature_gates", gates)
level.Info(logger).Log("feature_gates", cfg.Gates.String())
goruntime.SetMaxProcs(logger)
goruntime.SetMemLimit(logger, memlimitRatio)
@@ -509,6 +504,7 @@ func run(fs *flag.FlagSet) int {
),
collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}),
versioncollector.NewCollector("prometheus_operator"),
cfg.Gates,
)
mux.Handle("/metrics", promhttp.HandlerFor(r, promhttp.HandlerOpts{}))