prometheus-k8s-operator
prometheus-k8s-operator copied to clipboard
Provider should raise if multiple jobs are declared but no job suffixes are set
Enhancement Proposal
If a charm author tries to declare more than one job while instantiating the MetricsEndpointProvider
, they need to set a job suffix. If they don't, the library should put the provider in an error status to make sure they fix it prior to releasing a new version of the charm.
Considering #427 and increasing complexity of use cases, this is something we should do.
Probably, we could log a warning. If len(jobs) > 1
, we could iterate over them, find the ones which don't have a job_name
set, automatically create one (based on the information we do have, like the charm name, scrape endpoint, etc), and log a warning. It still works, but a warning-level nag is hopefully high enough that it will be noticed.
Isn't it better we just block or error so the charm dev fixes it during development time, rather than having the user notice at runtime when trying to relate them together?
Sure, it's better, but it's perfectly possible for dynamically created jobs which are appended from the callable to violate this constraint at runtime even after relating when some other action (adding a new LXD unit, for example) mutates the list.
Fair point!