-
Notifications
You must be signed in to change notification settings - Fork 1
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
Validate the table name in NewTable #52
Conversation
To avoid constructing table names which are not usable for metrics (e.g. as Prometheus metrics label), restrict the allowed name to "^[a-z][a-z0-9_\\-]{1,30}$". Signed-off-by: Jussi Maki <[email protected]>
4c65b74
to
84a92b9
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.
LGTM.
TODO, I think we need to put a validation on the jobgroups too, they also emit metrics.
malformed, for example if `IDIndex` is not unique (primary index has to be), or if | ||
the indexers have overlapping names. | ||
more secondary indexes. The table name must match the regular expression | ||
"^[a-z][a-z0-9_\\-]{0,30}$". |
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.
Should we allow _
or should we enforce -
to be used always?
Is there a particular reason for selecting 30? 30 chars -> ~4-8 words.
Considering a metric name needs to be usually below 200 chars, but the table name could be used in situation like jobgroup prefix -> table name -> suffix, I think it's more than enough.
The largest table name we currently have is 16 chars, bandwidth-qdiscs
which IMO is fine.
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.
There's two parts to the names in the job
library. One is the name used in the module health and that is concat of the full module id (agent.control-plane.foo
) and the job name (job-control-loop
). The module ids are already validated, but indeed we don't validate the job name (e.g. the name
argument passed to job.OneShot
for example).
Would you be interested in doing a PR for cilium/hive
to add this validation? Probably same or similar constraint as used here makes sense.
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.
Should we allow _ or should we enforce - to be used always?
I think allowing both is fine and using a similar constraint as we use in e.g. cilium/hive
for module ids makes it easier to guess what is allowed.
To avoid constructing table names which are not usable for metrics (e.g. as Prometheus metrics label), restrict the allowed name to "^[a-z][a-z0-9_\-]{0,30}$", e.g. must be lower-case, start with letter and be between 1-31 characters long (is this long enough limit?)