Skip to content
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

Merged
merged 2 commits into from
May 14, 2020

Conversation

rubenvp8510
Copy link
Collaborator

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.

@codecov
Copy link

codecov bot commented May 7, 2020

Codecov Report

Merging #1055 into master will increase coverage by 0.11%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
pkg/util/truncate.go 92.00% <100.00%> (+2.52%) ⬆️
pkg/strategy/all_in_one.go 90.69% <0.00%> (-4.43%) ⬇️
pkg/deployment/agent.go 96.18% <0.00%> (-3.82%) ⬇️
pkg/deployment/ingester.go 96.24% <0.00%> (-3.76%) ⬇️
pkg/deployment/collector.go 96.77% <0.00%> (-3.23%) ⬇️
pkg/strategy/production.go 97.14% <0.00%> (-2.86%) ⬇️
pkg/inject/sidecar.go 94.17% <0.00%> (-2.47%) ⬇️
pkg/strategy/streaming.go 96.96% <0.00%> (-1.50%) ⬇️
pkg/strategy/strategy.go 95.53% <0.00%> (-0.67%) ⬇️
pkg/account/main.go 100.00% <0.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce5d575...a40d39f. Read the comment docs.

pkg/util/util.go Outdated Show resolved Hide resolved
@rubenvp8510 rubenvp8510 requested a review from objectiser May 13, 2020 02:45
Copy link
Contributor

@objectiser objectiser left a 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.

func init() {
regexpEndReplace, _ = regexp.Compile("[^A-Za-z0-9]+$")
regexpBeginReplace, _ = regexp.Compile("^[^A-Za-z0-9]+")

Copy link
Contributor

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.

@objectiser objectiser merged commit ae58a9c into jaegertracing:master May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants