-
Notifications
You must be signed in to change notification settings - Fork 17
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
Replace slash and period with underscore for label names #237
Conversation
fb9490a
to
8900ec0
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
// app_kubernetes_io_instance | ||
func linearLabelKey(labelKey string) string { | ||
labelKey = strings.ReplaceAll(labelKey, "/", "_") | ||
labelKey = strings.ReplaceAll(labelKey, ".", "_") |
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 wondered if we should be doing the same for dashes
https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set
But actually it seems like ES would be fine with these, so no issue there
This change replaces all occurences of `.` and `/` in label keys. Occasionally a kubernetes label will take the form of a url, e.g. `app.kubernetes.io/instance`. In this case we would output that key prefixed by our given parameter. This can cause issues with systems such as ElasticSearch where it will see the `.` as an object path separator and attempt to build the object from the labels. This may work but is likely unintended behaviour and can be surprising. This issue is compounded if you have a matching key to the first segment of the domain-prefixed key, e.g. `app` in our case. This would conflict with the object that is being created by `app.kubernetes.io` and potentially cause errors to occur. By reducing the label key to a form similar to snake case we can avoid this issue and provide dependant systems with a label form that doesn't conflict. Additionaly we can provide more consistent behaviour. --- This change additionally includes some changes to the console integration tests to increase the amount of time we wait for a short duration. I've not confirmed this yet, but it appears that the amount of time it takes to run tests in kubebuilder's envtest has increased, leading to some flaky tests. Increasing the short timeout appears to fix this issue, which can also be seen on the `master` branch.
8900ec0
to
16c6dac
Compare
This change replaces all occurences of
.
and/
in labelkeys. Occasionally a kubernetes label will take the form of a url,
e.g.
app.kubernetes.io/instance
. In this case we would output thatkey prefixed by our given parameter.
This can cause issues with systems such as ElasticSearch where it will
see the
.
as an object path separator and attempt to build theobject from the labels. This may work but is likely unintended
behaviour and can be surprising.
This issue is compounded if you have a matching key to the first
segment of the domain-prefixed key, e.g.
app
in our case. This wouldconflict with the object that is being created by
app.kubernetes.io
and potentially cause errors to occur.
By reducing the label key to a form similar to snake case we can
avoid this issue and provide dependant systems with a label form that
doesn't conflict. Additionaly we can provide more consistent behaviour.