retina icon indicating copy to clipboard operation
retina copied to clipboard

prevent the potential for misconfiguration of MetricsInterval

Open huntergregory opened this issue 1 year ago • 2 comments

In the agent's ConfigMap, MetricsInterval is meant to be a number in seconds: https://github.com/microsoft/retina/blob/30a128b985bc99fc8686ef21afa1cc7358dc7dfd/pkg/config/config.go#L54

But the type for MetricsInterval is time.Duration: https://github.com/microsoft/retina/blob/30a128b985bc99fc8686ef21afa1cc7358dc7dfd/pkg/config/config.go#L21 so someone could configure MetricsInterval: 5s, and unknowingly end up with an actual interval of 150 years 😬

huntergregory avatar Apr 18 '24 00:04 huntergregory

viper supports duration as config, so we should always expect this value to come in as a valid duration and not turn it in to one later

rbtr avatar Apr 18 '24 16:04 rbtr

Should we deprecate this field and replace it with say MetricsIntervalDuration? If we reuse the same field, if someone continues to use the current config of MetricsInterval: 10, they would then get a 10 nanosecond interval

huntergregory avatar Apr 18 '24 16:04 huntergregory

To address the potential misconfiguration of MetricsInterval, I agree with @huntergregory about introducing a new field in the YAML configuration, such as MetricsIntervalDuration. This new field would take precedence over the existing MetricsInterval, but we would include a conditional statement to maintain backward compatibility. This way, if MetricsIntervalDuration is present, it will be used; otherwise, we will fall back to MetricsInterval.

Here's a rough outline of the plan:

  • Introduce the new MetricsIntervalDuration field in the YAML configuration.
  • Implement a conditional check to prioritize MetricsIntervalDuration if it is set.
  • Ensure that if MetricsIntervalDuration is not set, the existing MetricsInterval field will be used. We can also add a log line here to highlight that it is deprecated.

Please let me know your thoughts on this approach!

ritwikranjan avatar Aug 21 '24 20:08 ritwikranjan

@ritwikranjan plan looks good

rbtr avatar Aug 21 '24 21:08 rbtr