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 TaskSpec step container names aren't too long as well #550

Merged

Conversation

abayer
Copy link
Contributor

@abayer abayer commented Feb 22, 2019

Changes

PR #491 did the trick for generated resource containers, but not for TaskSpec-defined step container names. This fixes that.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

Release Notes

n/a

PR tektoncd#491 did the trick for generated resource containers, but not for
`TaskSpec`-defined step container names. This fixes that.
@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Feb 22, 2019
@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 22, 2019
@abayer
Copy link
Contributor Author

abayer commented Feb 22, 2019

/assign @pivotal-nader-ziada
/assign @dwnusbaum

@knative-prow-robot
Copy link

@abayer: GitHub didn't allow me to assign the following users: dwnusbaum.

Note that only knative members and repo collaborators can be assigned.
For more information please see the contributor guide

In response to this:

/assign @pivotal-nader-ziada
/assign @dwnusbaum

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Collaborator

@bobcatfish bobcatfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching and fixing this @abayer !

I have minor feedback about method naming - also trying to trick you into fixing what I think might be a related bug ;) ;) ;)

@@ -52,3 +56,10 @@ func (simpleNameGenerator) GenerateName(base string) string {
}
return fmt.Sprintf("%s-%s", base, utilrand.String(randomLength))
}

func (simpleNameGenerator) GenerateBuildStepName(base string) string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this name reflects how this function is being used, but maybe we could name it after what it's doing? It seems like the functionality we'll have is something like:

  • GenerateName - appends a random prefix AND truncates a string if it's too long (maybe call this RestrictLengthWithRandomPrefix - called as names.RestrictLengthWithRandomPrefix
  • GenerateBuildStepName - truncates a string if it's too long (name idea: RestrictLength - since it'd be called as names.RestrictLength)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -52,3 +56,10 @@ func (simpleNameGenerator) GenerateName(base string) string {
}
return fmt.Sprintf("%s-%s", base, utilrand.String(randomLength))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think there might actually be a bug here - the total length should be 63 or less, including the postfixed random string?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah good point, there is an off-by-one since the hyphen isn't accounted for in maxGeneratedNameLength, see https://github.com/knative/build-pipeline/pull/550/files#diff-0cd213308b34c799cb518fa9d6d1daacL46.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@abayer abayer force-pushed the resource-names-still-too-long branch from cb1a469 to 5a83f33 Compare February 22, 2019 22:15
@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 22, 2019
return fmt.Sprintf("%s-%s", base, utilrand.String(randomLength))
}

func (simpleNameGenerator) RestrictLength(base string) string {
if len(base) > maxGeneratedNameLength {
base = base[:maxGeneratedNameLength]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why maxGeneratedNameLength instead of maxNameLength? Callers adding suffixes should be using RestrictLengthWithRandomSuffix, so the return value of this function could go all the way up to 63 chars, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, oversight. Fixed it. =)

@abayer
Copy link
Contributor Author

abayer commented Feb 23, 2019

/test pull-knative-build-pipeline-integration-tests

@nader-ziada
Copy link
Member

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 26, 2019
@knative-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abayer, dwnusbaum, pivotal-nader-ziada

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [pivotal-nader-ziada]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 26, 2019
@dwnusbaum
Copy link
Contributor

/test pull-knative-build-pipeline-integration-tests

@shashwathi
Copy link
Contributor

@dwnusbaum : I am working on a PR to fix the flakiness you ran into.

shashwathi pushed a commit to shashwathi/build-pipeline that referenced this pull request Feb 26, 2019
- In PR tektoncd#550 the e2e test for taskrunTimeOut failed with reason " message: 'References a Task arendelle-2j8ft/giraffe that doesn''t exist:  translating
I0226 14:05:06.851]       Build to Pod: serviceaccounts "default" not found'"

Theory: ServiceAccount 'default' in test namespace is created with some delay but the
taskrun reconciliation is triggered before that which causes this type
of failure

Fix: Once namespace is created call wait function to make sure SA is
created.
@knative-prow-robot knative-prow-robot merged commit a89ad33 into tektoncd:master Feb 26, 2019
knative-prow-robot pushed a commit that referenced this pull request Feb 26, 2019
- In PR #550 the e2e test for taskrunTimeOut failed with reason " message: 'References a Task arendelle-2j8ft/giraffe that doesn''t exist:  translating
I0226 14:05:06.851]       Build to Pod: serviceaccounts "default" not found'"

Theory: ServiceAccount 'default' in test namespace is created with some delay but the
taskrun reconciliation is triggered before that which causes this type
of failure

Fix: Once namespace is created call wait function to make sure SA is
created.
abayer added a commit to abayer/knative-build-pipeline that referenced this pull request Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants