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

identifiers: adjust requirements for identifiers #1108

Merged
merged 1 commit into from
Jun 28, 2017

Conversation

stevvooe
Copy link
Member

Based on feedback, a few adjustments have been made to the identifier
requirements. Identifiers that have components that start with a number
are now allowed. This violates RFC 1035 but does not do so for dns names
practically. A total length, of 76 characters is now also enforced. This
decision was completely arbitrary but satifies the requirement for a
maximum length. Often, this is used as the maximum length of a line in
editors, so it should be a good choice.

Signed-off-by: Stephen J Day stephen.day@docker.com

@stevvooe
Copy link
Member Author

cc @ijc @xiekeyang

@@ -43,6 +49,10 @@ func IsInvalid(err error) bool {
// In general, identifiers that pass this validation, should be safe for use as
// a domain identifier or filesystem path component.
func Validate(s string) error {
if len(s) > maxLength {
return errors.Wrapf(errIdentifierInvalid, "identifier %q greater than maximum length")

Choose a reason for hiding this comment

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

nit: to be,

return errors.Wrapf(errIdentifierInvalid, "identifier %q greater than maximum length(%d)",s, maxLength)

(at least omit %q, s )

@@ -15,6 +16,9 @@ func TestValidIdentifiers(t *testing.T) {
"foo.boo",
"swarmkit.docker.io",
"zn--e9.org", // or something like it!
"0912341234",
"task.0.0123456789",
strings.Repeat("a", 76),

Choose a reason for hiding this comment

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

to use const maxLength here?

@@ -34,6 +38,7 @@ func TestInvalidIdentifiers(t *testing.T) {
"-foo.boo",
"foo.boo-",
"foo_foo.boo_underscores", // boo-urns?
strings.Repeat("a", 77),

Choose a reason for hiding this comment

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

to use const maxLength+1 here?

@ijc
Copy link
Contributor

ijc commented Jun 28, 2017

I tested this with the swarmd containerd executor and it fixes the issues I mentioned in #1083 (comment), thanks!

In #1083 (comment) you mentioned hex identifiers, you've gone wider than that here but I just wanted to mention (even though I'm sure you know) that swarmkit identifiers aren't hex, they're base36, plus . as a separator.

@ijc
Copy link
Contributor

ijc commented Jun 28, 2017

plus . as a separator.

Actually that's not quite accurate, the full swarmkit task names (which I'm using as the containerd id) are servicename.slotnumber.taskid, the taskid is base36 but slotnumber is a decimal and servicename is user supplied and must be a valid DNS name, which can be mixed case, so it's [0-9A-Za-z] + . + - + _ as an upper bound I think.

@ijc
Copy link
Contributor

ijc commented Jun 28, 2017

Code looks good to me, apart from the errors.Wrapf missing format argument which @xiekeyang pointed out.

CI fail is:

./container_test.go:769: cannot use &limit (type *uint64) as type *int64 in field value
./container_test.go:812: cannot use &limit (type *uint64) as type *int64 in field value

which I don't see how this PR causes...

@ijc
Copy link
Contributor

ijc commented Jun 28, 2017

CI is due to #1109

ijc pushed a commit to ijc/swarmkit that referenced this pull request Jun 28, 2017
Introduced in containerd/containerd#1083 but might
change (see comments on containerd#1083 and
https://dockercommunity.slackarchive.io/containerd/page-26/ts-1498485227137668)

This can be dropped when containerd/containerd#1108 or
something similar is merged.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
Copy link
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

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

agree with @xiekeyang on the nit to use maxLength const in the test definitions so any changes in the future will automatically follow through to tests.

Beyond that, LGTM

@mlaventure
Copy link
Contributor

LGTM, but I'd also like the maxlength to be shown in the error message (and used in the test)

ijc pushed a commit to ijc/swarmkit that referenced this pull request Jun 28, 2017
Introduced in containerd/containerd#1083 but might
change (see comments on containerd#1083 and
https://dockercommunity.slackarchive.io/containerd/page-26/ts-1498485227137668)

This can be dropped when containerd/containerd#1108 or
something similar is merged.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
@stevvooe stevvooe force-pushed the adjust-identifier-requirements branch from 0ef5531 to 0c29e75 Compare June 28, 2017 18:22
Based on feedback, a few adjustments have been made to the identifier
requirements. Identifiers that have components that start with a number
are now allowed. This violates RFC 1035 but does not do so for dns names
practically. A total length, of 76 characters is now also enforced. This
decision was completely arbitrary but satifies the requirement for a
maximum length. Often, this is used as the maximum length of a line in
editors, so it should be a good choice.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
@stevvooe stevvooe force-pushed the adjust-identifier-requirements branch from 0c29e75 to 0e34531 Compare June 28, 2017 18:30
@stevvooe stevvooe merged commit 917914f into containerd:master Jun 28, 2017
@stevvooe stevvooe deleted the adjust-identifier-requirements branch June 28, 2017 19:54
@codecov-io
Copy link

codecov-io commented Jun 28, 2017

Codecov Report

Merging #1108 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1108   +/-   ##
=======================================
  Coverage   54.51%   54.51%           
=======================================
  Files          16       16           
  Lines        1229     1229           
=======================================
  Hits          670      670           
  Misses        386      386           
  Partials      173      173

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 7ec1497...0e34531. Read the comment docs.

ijc pushed a commit to ijc/swarmkit that referenced this pull request Jun 29, 2017
Introduced in containerd/containerd#1083 but might
change (see comments on containerd#1083 and
https://dockercommunity.slackarchive.io/containerd/page-26/ts-1498485227137668)

This can be dropped when containerd/containerd#1108 or
something similar is merged.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
ianlewis pushed a commit to ianlewis/containerd that referenced this pull request Dec 8, 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.

6 participants