Skip to content

fixes #1452 set path separator to slash in interpolation and add a test case #1468

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lifubang
Copy link
Contributor

@lifubang lifubang commented Oct 22, 2018

Signed-off-by: Lifubang lifubang@acmcoder.com

- What I did
Please see issue #1452 , Variable type conversion in Compose file breaks if service name contains dot.

- How I did it
set path separator from dot to slash in interpolation and add a test case

- How to verify it
After this patch:

root@dockerdemo:~/testd# cat file2.yaml 
version: "3.0"
services:
  app.test_1:
    image: redis
    ulimits:
      nofile:
        soft: ${APP_NOFILE}
        hard: ${APP_NOFILE}
root@dockerdemo:~/testd#
root@dockerdemo:~/testd# APP_NOFILE=1 ~/gocode/src/github.com/docker/cli/build/docker stack deploy -c file2.yaml stk2
Creating service stk2_app.test_1

- Description for the changelog
set path separator from dot to slash in interpolation

- Addition info
But, but, the daemon said:
failed to create service stk2_app.test_1: Error response from daemon: rpc error: code = InvalidArgument desc = name must be valid as a DNS name component
The daemon's check regexp is ^[a-zA-Z0-9](?:[-_]*[A-Za-z0-9]+)*$, don't contain dot.
But I think this is another issue( see #1470 ).
At least, by this patch, we can get the right response.

Signed-off-by: Lifubang <lifubang@acmcoder.com>
@thaJeztah
Copy link
Member

thaJeztah commented Nov 8, 2018

Right, if I understand correctly, this only fixes that when parsing the YAML, so that it doesn't interpret foo.bar.baz: test as

foo
  bar
    baz: test

I don't think we should change this, as it would probably break people using the existing syntax

Servicenames are not allowed to contain a ., as they are also used in DNS, which may result in service-names conflicting.

The correct way to pass such a name would be to add quotes;

docker stack deploy -c- foo <<EOF
version: "3.0"
services:
  "app.test_1":
    image: redis
EOF

But of course, that would still return the daemon error (as expected);

Creating network foo_default
Creating service foo_app.test_1
failed to create service foo_app.test_1: Error response from daemon: rpc error: code = InvalidArgument desc = name must be valid as a DNS name component

@lifubang
Copy link
Contributor Author

lifubang commented Nov 9, 2018

The correct way to pass such a name would be to add quotes;

@thaJeztah if there were no ${APP_NOFILE}, everything will be OK. We don't need to add quotes.

But if there is ${APP_NOFILE}, docker cli needs to check the type of ulimits.nofile.soft, it will raise an incorrect error.

APP_NOFILE=1 build/docker stack deploy -c ~/t1.yaml foo
services.app.test_1.ulimits.nofile.soft must be a integer
(but APP_NOFILE is already a integer).

Even we add quotes, it raise the same incorrect error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants