-
Notifications
You must be signed in to change notification settings - Fork 345
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
Make sure truncated labels are valid #1055
Conversation
Signed-off-by: Ruben Vargas <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #1055 +/- ##
==========================================
+ Coverage 64.58% 64.70% +0.11%
==========================================
Files 84 85 +1
Lines 6715 6904 +189
==========================================
+ Hits 4337 4467 +130
- Misses 2236 2279 +43
- Partials 142 158 +16
Continue to review full report at Codecov.
|
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 - just one nit so fix and you can merge.
pkg/util/truncate.go
Outdated
func init() { | ||
regexpEndReplace, _ = regexp.Compile("[^A-Za-z0-9]+$") | ||
regexpBeginReplace, _ = regexp.Compile("^[^A-Za-z0-9]+") | ||
|
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.
nit: Can you remove this line.
Signed-off-by: Ruben Vargas <[email protected]>
Signed-off-by: Ruben Vargas [email protected]
While I was working on fix token propagation on OLM I saw a couple of errors on operator logs:
time="2020-05-07T16:28:25Z" level=error msg="failed to apply the changes" error="ClusterRoleBinding.rbac.authorization.k8s.io \"osdk-e2e-3bed6aed-720f-4eca-9cbc-7aa27c919f34-token-prop-oauth-proxy-auth-delegator\" is invalid: metadata.labels: Invalid value: \"osdk-e2e-3bed6aed-720f-4eca-9cbc-7aa27c919f34-token-prop-oauth-\": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')" execution="2020-05-07 16:28:25.056741381 +0000 UTC" instance=token-prop namespace=osdk-e2e-3bed6aed-720f-4eca-9cbc-7aa27c919f34
I realized that this was due the truncation of labels to a maximum of 63 characters, That truncation process could produces labels that ends with "-" (at least in this case). A quick fix was to change the name of the Jaeger instance in token propagation tests to
tokenprop
so all the truncated label ends with an alphanumeric. I think that is not a definitive way to fix the issue, so I created this PR.