prometheus-k8s-operator icon indicating copy to clipboard operation
prometheus-k8s-operator copied to clipboard

Provider should raise if multiple jobs are declared but no job suffixes are set

Open simskij opened this issue 2 years ago • 4 comments

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.

simskij avatar Jun 21 '22 16:06 simskij

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.

rbarry82 avatar Jan 21 '23 03:01 rbarry82

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?

simskij avatar Feb 06 '23 09:02 simskij

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.

rbarry82 avatar Feb 06 '23 09:02 rbarry82

Fair point!

simskij avatar Feb 06 '23 12:02 simskij