-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enhancement: allow toggling custom config deprecation behaviour #6955
enhancement: allow toggling custom config deprecation behaviour #6955
Conversation
e58644d
to
b667bf5
Compare
Documentation/operator.md
Outdated
@@ -49,6 +49,8 @@ Usage of ./operator: | |||
Value used by the operator to filter Alertmanager, Prometheus, PrometheusAgent and ThanosRuler objects that it should reconcile. If the value isn't empty, the operator only reconciles objects with an operator.prometheus.io/controller-id annotation of the same value. Otherwise the operator reconciles all objects without the annotation or with an empty annotation value. | |||
-deny-namespaces value | |||
Namespaces not to scope the interaction of the Prometheus Operator (deny list). This is mutually exclusive with --namespaces. | |||
-deprecate-custom-configuration |
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.
I'd suggest to name the flag -disable-unmanaged-prometheus-configuration
and default to false.
Not sure I understand what the flag is for, can you elaborate a bit? I lack the context behind this. |
To provide more context, there's a legacy behavior which instructs the operator to not manage the Prometheus configuration when all selectors (ruleSelector, serviceMonitorSelector, ...) are nil. In this case, the user is supposed to build by hand the secret holding the (gzipped) configuration. It can be a pain to debug if you run into this mode by accident because the operator doesn't complain but the Prometheus statefulset will never spin up pods if the secret is missing. |
f6de19a
to
b1e4375
Compare
b1e4375
to
b5797a8
Compare
This PR is rebased on #6992 to address an issue that crashed the |
28fe238
to
aee0477
Compare
aee0477
to
7e9f70d
Compare
Allow toggling custom config deprecation behaviour; helpful in scenarios where a controller disables all service discovery methods. Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
7e9f70d
to
7a052f5
Compare
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.
As a follow-up change, I suggest to enhance the Reconciled
status condition so that when all selectors are nil, it gets reflected in the reconciled message. E.g. it's not an error but it can be hard to find out what you missed. Something like:
status:
availableReplicas: 2
conditions:
- lastTransitionTime: "2024-10-21T14:45:40Z"
message: ""
observedGeneration: 2
reason: ""
status: "True"
type: Available
- lastTransitionTime: "2024-10-21T14:45:40Z"
message: "None of the scrape resource selectors are specified."
observedGeneration: 2
reason: "NoScrapeResourceSelected"
status: "True"
type: Reconciled
cmd/operator/main.go
Outdated
@@ -183,7 +185,7 @@ func parseFlags(fs *flag.FlagSet) { | |||
fs.Var(&cfg.SecretListWatchLabelSelector, "secret-label-selector", "Label selector to filter Secrets to watch") | |||
|
|||
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).") | |||
|
|||
fs.BoolVar(&disableUnmanagedPrometheusConfiguration, "disable-unmanaged-prometheus-configuration", false, "Toggle the legacy deprecation behaviour for unmanaged Prometheus configuration. Default: false.") |
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.
fs.BoolVar(&disableUnmanagedPrometheusConfiguration, "disable-unmanaged-prometheus-configuration", false, "Toggle the legacy deprecation behaviour for unmanaged Prometheus configuration. Default: false.") | |
fs.BoolVar(&disableUnmanagedPrometheusConfiguration, "disable-unmanaged-prometheus-configuration", false, "Disable support for unmanaged Prometheus configuration when all resource selectors are nil. Default: false.") |
pkg/prometheus/server/operator.go
Outdated
@@ -117,6 +119,14 @@ func WithStorageClassValidation() ControllerOption { | |||
} | |||
} | |||
|
|||
// WithDisableUnmanagedPrometheusConfiguration tells that the controller should deprecate | |||
// the custom configuration. | |||
func WithDisableUnmanagedPrometheusConfiguration() ControllerOption { |
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.
func WithDisableUnmanagedPrometheusConfiguration() ControllerOption { | |
func WithUnmanagedConfigurationDisabled() ControllerOption { |
pkg/prometheus/server/operator.go
Outdated
@@ -91,6 +91,8 @@ type Operator struct { | |||
canReadStorageClass bool | |||
|
|||
eventRecorder record.EventRecorder | |||
|
|||
disableUnmanagedPrometheusConfiguration bool |
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.
disableUnmanagedPrometheusConfiguration bool | |
disableUnmanagedConfiguration bool |
pkg/prometheus/server/operator.go
Outdated
@@ -954,7 +964,7 @@ func (c *Operator) UpdateStatus(ctx context.Context, key string) error { | |||
return nil | |||
} | |||
|
|||
func logDeprecatedFields(logger *slog.Logger, p *monitoringv1.Prometheus) { | |||
func logDeprecatedFields(logger *slog.Logger, p *monitoringv1.Prometheus, disableUnmanagedPrometheusConfiguration bool) { |
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.
(suggestion) let's make it a pointer receiver function.
func logDeprecatedFields(logger *slog.Logger, p *monitoringv1.Prometheus, disableUnmanagedPrometheusConfiguration bool) { | |
func (c *Operator) logDeprecatedFields(logger *slog.Logger, p *monitoringv1.Prometheus) { |
cmd/operator/main.go
Outdated
@@ -274,6 +276,9 @@ func run(fs *flag.FlagSet) int { | |||
promControllerOptions = []prometheuscontroller.ControllerOption{} | |||
thanosControllerOptions = []thanoscontroller.ControllerOption{} | |||
) | |||
if disableUnmanagedPrometheusConfiguration { | |||
promControllerOptions = append(promControllerOptions, prometheuscontroller.WithDisableUnmanagedPrometheusConfiguration()) |
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 might be good to log an info message saying that unmanaged configuration is disabled.
Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
83864a0
to
39ff9a0
Compare
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.
I've got just a few last nits otherwise LGTM.
Documentation/operator.md
Outdated
@@ -49,6 +49,8 @@ Usage of ./operator: | |||
Value used by the operator to filter Alertmanager, Prometheus, PrometheusAgent and ThanosRuler objects that it should reconcile. If the value isn't empty, the operator only reconciles objects with an operator.prometheus.io/controller-id annotation of the same value. Otherwise the operator reconciles all objects without the annotation or with an empty annotation value. | |||
-deny-namespaces value | |||
Namespaces not to scope the interaction of the Prometheus Operator (deny list). This is mutually exclusive with --namespaces. | |||
-disable-unmanaged-prometheus-configuration | |||
Disable support for unmanaged Prometheus configuration when all resource selectors are nil. Default: false. |
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.
(nit) let's provide more context why you might want to use the flag.
Disable support for unmanaged Prometheus configuration when all resource selectors are nil. Default: false. | |
Disable support for unmanaged Prometheus configuration when all resource selectors are nil. As stated in the API documentation, unmanaged Prometheus configuration is a deprecated feature which can be avoided with "additionalScrapeConfigs` or the ScrapeConfig CRD. Default: false. |
pkg/prometheus/server/operator.go
Outdated
@@ -91,6 +91,8 @@ type Operator struct { | |||
canReadStorageClass bool | |||
|
|||
eventRecorder record.EventRecorder | |||
|
|||
disableUnmanagedConfiguration bool |
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.
(nit) can we move it next to the other bool fields (e.g. at L92)?
pkg/prometheus/server/operator.go
Outdated
@@ -117,6 +119,14 @@ func WithStorageClassValidation() ControllerOption { | |||
} | |||
} | |||
|
|||
// WithUnmanagedConfigurationDisabled tells that the controller should deprecate | |||
// the custom configuration. | |||
func WithUnmanagedConfigurationDisabled() ControllerOption { |
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.
(nit)
func WithUnmanagedConfigurationDisabled() ControllerOption { | |
func WithoutUnmanagedConfiguration() ControllerOption { |
…ation behaviour
88d46cc
to
bc8c0c3
Compare
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.
A few nits but lgtm
Documentation/operator.md
Outdated
@@ -49,6 +49,8 @@ Usage of ./operator: | |||
Value used by the operator to filter Alertmanager, Prometheus, PrometheusAgent and ThanosRuler objects that it should reconcile. If the value isn't empty, the operator only reconciles objects with an operator.prometheus.io/controller-id annotation of the same value. Otherwise the operator reconciles all objects without the annotation or with an empty annotation value. | |||
-deny-namespaces value | |||
Namespaces not to scope the interaction of the Prometheus Operator (deny list). This is mutually exclusive with --namespaces. | |||
-disable-unmanaged-prometheus-configuration additionalScrapeConfigs |
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.
hmm, not sure why we have additionalScrapeConfigs
here but it looks like removing the backticks in the help text should fix it 🤯
cmd/operator/main.go
Outdated
@@ -183,7 +185,7 @@ func parseFlags(fs *flag.FlagSet) { | |||
fs.Var(&cfg.SecretListWatchLabelSelector, "secret-label-selector", "Label selector to filter Secrets to watch") | |||
|
|||
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).") | |||
|
|||
fs.BoolVar(&disableUnmanagedPrometheusConfiguration, "disable-unmanaged-prometheus-configuration", false, "Disable support for unmanaged Prometheus configuration when all resource selectors are nil. As stated in the API documentation, unmanaged Prometheus configuration is a deprecated feature which can be avoided with `additionalScrapeConfigs` or the ScrapeConfig CRD. Default: false.") |
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.
fs.BoolVar(&disableUnmanagedPrometheusConfiguration, "disable-unmanaged-prometheus-configuration", false, "Disable support for unmanaged Prometheus configuration when all resource selectors are nil. As stated in the API documentation, unmanaged Prometheus configuration is a deprecated feature which can be avoided with `additionalScrapeConfigs` or the ScrapeConfig CRD. Default: false.") | |
fs.BoolVar(&disableUnmanagedPrometheusConfiguration, "disable-unmanaged-prometheus-configuration", false, "Disable support for unmanaged Prometheus configuration when all resource selectors are nil. As stated in the API documentation, unmanaged Prometheus configuration is a deprecated feature which can be avoided with '.spec.additionalScrapeConfigs' or the ScrapeConfig CRD. Default: false.") |
cmd/operator/main.go
Outdated
@@ -274,6 +276,10 @@ func run(fs *flag.FlagSet) int { | |||
promControllerOptions = []prometheuscontroller.ControllerOption{} | |||
thanosControllerOptions = []thanoscontroller.ControllerOption{} | |||
) | |||
if disableUnmanagedPrometheusConfiguration { | |||
logger.Info("unmanaged Prometheus configuration is disabled") |
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.
logger.Info("unmanaged Prometheus configuration is disabled") | |
logger.Info("Disabling support for unmanaged Prometheus configurations") |
pkg/prometheus/server/operator.go
Outdated
// WithoutUnmanagedConfiguration tells that the controller should deprecate | ||
// the custom configuration. |
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.
// WithoutUnmanagedConfiguration tells that the controller should deprecate | |
// the custom configuration. | |
// WithoutUnmanagedConfiguration tells that the controller should not support | |
// unmanaged configurations. |
… deprecation behaviour
Thanks! |
* enhancement: allow toggling custom config deprecation behaviour --------- Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* enhancement: allow toggling custom config deprecation behaviour --------- Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* enhancement: allow toggling custom config deprecation behaviour --------- Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* enhancement: allow toggling custom config deprecation behaviour --------- Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* enhancement: allow toggling custom config deprecation behaviour --------- Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* enhancement: allow toggling custom config deprecation behaviour --------- Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* enhancement: allow toggling custom config deprecation behaviour --------- Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* enhancement: allow toggling custom config deprecation behaviour --------- Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* enhancement: allow toggling custom config deprecation behaviour --------- Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* enhancement: allow toggling custom config deprecation behaviour --------- Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* enhancement: allow toggling custom config deprecation behaviour --------- Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* enhancement: allow toggling custom config deprecation behaviour --------- Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* enhancement: allow toggling custom config deprecation behaviour --------- Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* enhancement: allow toggling custom config deprecation behaviour --------- Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* enhancement: allow toggling custom config deprecation behaviour --------- Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* enhancement: allow toggling custom config deprecation behaviour --------- Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* enhancement: allow toggling custom config deprecation behaviour --------- Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* enhancement: allow toggling custom config deprecation behaviour --------- Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
Description
Allow toggling custom config deprecation behaviour; helpful in scenarios where a controller disables all service discovery methods.
Type of change
CHANGE
(fix or feature that would cause existing functionality to not work as expected)FEATURE
(non-breaking change which adds functionality)BUGFIX
(non-breaking change which fixes an issue)ENHANCEMENT
(non-breaking change which improves existing functionality)NONE
(if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)Changelog entry