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 resource names do not exceed limit of 63 characters #491

Merged
merged 2 commits into from
Feb 14, 2019

Conversation

nader-ziada
Copy link
Member

Fixes: #481

Proposed changes

  • Generated names for taskruns and build steps get a random suffix
    of five alphanumerics. The string is guaranteed to not exceed the
    length of a standard Kubernetes name (63 characters)
  • Update tests using fixed seed for the name generation
  • Remove rand string func from test folder and use GenerateName()
  • CRD types already have validation for names in validateObjectMetadata()

This PR was co-authored by @bobcatfish, but will not put her name in the commit to avoid CLA hassle, (sorry Christie 🤷‍♂️)

@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Feb 12, 2019
@knative-prow-robot knative-prow-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 12, 2019
@abayer
Copy link
Contributor

abayer commented Feb 12, 2019

cc @dwnusbaum

@nader-ziada
Copy link
Member Author

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

@bobcatfish
Copy link
Collaborator

(sorry Christie )

haha np :)

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.

This looks great to me, but I think someone other than me should review it since I was part of creating it 😇

@@ -116,7 +117,7 @@ func (b *ArtifactBucket) GetSecretsVolumes() []corev1.Volume {
volumes := []corev1.Volume{}
for _, sec := range b.Secrets {
volumes = append(volumes, corev1.Volume{
Name: fmt.Sprintf("bucket-secret-volume-%s", sec.SecretName),
Name: names.SimpleNameGenerator.GenerateName(fmt.Sprintf("bucket-secret-%s", sec.SecretName)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

i had one thought, maybe overkill tho: we could make a GenerateNamef, something like:

names.SimpleNameGenerator.GenerateNamef("bucket-secret-%s", sec.SecretName)

Since we're so often passing the output of fmt.Sprintf in here anyway 🤷‍♀️

Copy link
Member Author

Choose a reason for hiding this comment

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

nice idea

wantServiceAccountName string
wantPodVolume []corev1.Volume
wantPreSteps []corev1.Container
wantSteps []corev1.Container
Copy link
Collaborator

Choose a reason for hiding this comment

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

oh man you got through it! thanks so much for fixing this up @pivotal-nader-ziada ❤️ ❤️ ❤️ i think this is definitely better going forward

Copy link
Contributor

@dwnusbaum dwnusbaum Feb 12, 2019

Choose a reason for hiding this comment

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

Yeah, this is great! I have given you quite a few merge conflicts though because of #488, sorry! I would lean towards using a single wantPod field instead of using all of the individual fields so that we can match on anything in ObjectMeta or any additional fields as needed in the future as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

haha, that one file took more time than the rest of the PR :D

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would lean towards using a single wantPod field instead of using all of the individual fields so that we can match on anything in ObjectMeta or any additional fields as needed in the future as well.

The only "trouble" here @dwnusbaum is that there ends up being a lot of repetition between the pods so the cases become pretty verbose :S (maybe it's worth it tho?)

Side note: might start looking a bit better if we add pod builders in test/builder but that's probably a PR in itself :D

Copy link
Contributor

Choose a reason for hiding this comment

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

might start looking a bit better if we add pod builders in test/builder

Yeah that was what I was thinking, but like you said probably best left for another PR since the current code gets the job done.


_See [randstring.go](./randstring.go)._
namespace := names.SimpleNameGenerator.GenerateName("arendelle")
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice catch, thanks for updating the docs!

},
}},
},
} {
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 if we wanted to we could make some of these a bit less verbose but this is fine for now if we want to iterate on it :D

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, agreed, just wanted to get everything working first, then we can improve on it

Copy link
Contributor

@shashwathi shashwathi left a comment

Choose a reason for hiding this comment

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

This looks great @pivotal-nader-ziada @bobcatfish 👍

@shashwathi
Copy link
Contributor

/assign @shashwathi

@nader-ziada
Copy link
Member Author

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

1 similar comment
@nader-ziada
Copy link
Member Author

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

test/cancel_test.go Outdated Show resolved Hide resolved
@nader-ziada nader-ziada force-pushed the long-name branch 3 times, most recently from f8faa05 to 219a340 Compare February 14, 2019 17:01
- generated names for taskruns and build steps get a random suffix
of five alphanumerics. The string is guaranteed to not exceed the
length of a standard Kubernetes name (63 characters)
- updated tests using fixed seed for the name generation
- remove rand string func from test folder
- use new rand string already used for generated names
Pipelinerun resolution now checking if taskrun already created so it
doesn't generate a new random suffix to it

updated e2e tests to work with variable taskrun names

Signed-off-by: Nader Ziada <[email protected]>
@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-build-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go 85.0% 84.9% -0.1
pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution.go 88.5% 88.9% 0.4
pkg/reconciler/v1alpha1/taskrun/resources/pod.go 83.6% 83.7% 0.1
pkg/reconciler/v1alpha1/taskrun/taskrun.go 74.6% 74.1% -0.5

@shashwathi
Copy link
Contributor

/lgtm

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

@shashwathi shashwathi left a comment

Choose a reason for hiding this comment

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

Great PR. 👍

@knative-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

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

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,shashwathi]

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 merged commit 0502dbe into tektoncd:master Feb 14, 2019
@bobcatfish
Copy link
Collaborator

nice ooooone @pivotal-nader-ziada !! 🎉

abayer added a commit to abayer/tektoncd-pipeline that referenced this pull request Feb 22, 2019
PR tektoncd#491 did the trick for generated resource containers, but not for
`TaskSpec`-defined step container names. This fixes that.
knative-prow-robot pushed a commit that referenced this pull request Feb 26, 2019
PR #491 did the trick for generated resource containers, but not for
`TaskSpec`-defined step container names. This fixes that.
@nader-ziada nader-ziada deleted the long-name branch March 7, 2019 16:35
piyush-garg pushed a commit to piyush-garg/pipeline that referenced this pull request Aug 17, 2020
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Resource name too long, cannot create taskrun
8 participants