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

Only parse global args once #1802

Merged
merged 5 commits into from
Apr 3, 2019
Merged

Conversation

ijc
Copy link
Contributor

@ijc ijc commented Apr 3, 2019

- What I did

Fixed #1801 by ensuring the monolithic CLI and plugins themselves only parse their global arguments once. Along the way I noticed that the cli-plugins e2e tests lacked a TestMain (and thus a call to environment.Setup) and fixed that as well as tightening the checks on a couple of existing tests.

Fixes #1801.

- How I did it

After parsing the global args (which we do manually due to #1722) reset the cmd's args to only the remaining ones.

- How to verify it

New e2e tests TestGlobalArgsOnlyParsedOnce/* validate this, existing tests should cover the rest.

- Description for the changelog

N/A (haven't released the bug yet)

This checks for actual emptiness, while `""` means "don't care".

Signed-off-by: Ian Campbell <[email protected]>
Copy link
Contributor

@simonferquel simonferquel left a comment

Choose a reason for hiding this comment

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

It looks like the args filtering was already done and just missed to be plugged in.
Nice!

@ijc
Copy link
Contributor Author

ijc commented Apr 3, 2019

Yep. I'll investigate the CI failures after lunch, looks like I regressed something...

@ijc
Copy link
Contributor Author

ijc commented Apr 3, 2019

Adding TestMain means that tests now see a $DOCKER_HOST which they didn't before, in the ssh connhelper variant this means that tests which use -D etc now get some extra/different output on stderr due to the extra login.

I'll sort it shortly.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM once CI is fixed 😅

e2e/cli-plugins/flags_test.go Show resolved Hide resolved
Ian Campbell added 4 commits April 3, 2019 15:06
This was omitted when these tests were added.

Adding this means that the tests now see the `$DOCKER_HOST` configured (via
`$TEST_DOCKER_HOST`) where they didn't before. In some cases (specifically the
`test-e2e-connhelper-ssh` case) this results in additional output on stderr
when `-D` (debug) is used:

    time="2019-04-03T11:10:27Z" level=debug msg="commandconn: starting ssh with [-l penguin 172.20.0.2 -- docker system dial-stdio]"

Address this by switching the affected test cases to use `-l info` instead of
`-D`, they all just require some option not specifically `-D`. Note that `info`
is the default log level so this is effectively a nop (which is good).

Signed-off-by: Ian Campbell <[email protected]>
These currently fail.

Signed-off-by: Ian Campbell <[email protected]>
Before calling `cmd.Execute` we need to reset the arguments to be used to not
include the global arguments which we have already parsed. This is precisely
the `args` which we have in our hand at this point.

This fixes `TestGlobalArgsOnlyParsedOnce/builtin` in the cli-plugins e2e tests.

`TestGlobalArgsOnlyParsedOnce/plugin` is still broken will be fixed next.

Signed-off-by: Ian Campbell <[email protected]>
This fixes `TestGlobalArgsOnlyParsedOnce/plugin` in the cli-plugins e2e tests.

Signed-off-by: Ian Campbell <[email protected]>
@ijc ijc force-pushed the only-parse-global-args-once branch from c2453a6 to 1425aeb Compare April 3, 2019 14:07
@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@5bbb56b). Click here to learn what that means.
The diff coverage is 0%.

@@            Coverage Diff            @@
##             master    #1802   +/-   ##
=========================================
  Coverage          ?   56.28%           
=========================================
  Files             ?      308           
  Lines             ?    21300           
  Branches          ?        0           
=========================================
  Hits              ?    11988           
  Misses            ?     8437           
  Partials          ?      875

@ijc
Copy link
Contributor Author

ijc commented Apr 3, 2019

I pushed an update to fix the CI. The change was in e2e: Add a TestMain for cli plugins tests (ef40743 right now).

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@thaJeztah thaJeztah merged commit 971343e into docker:master Apr 3, 2019
@GordonTheTurtle GordonTheTurtle added this to the 19.03.0 milestone Apr 3, 2019
@ijc ijc deleted the only-parse-global-args-once branch April 3, 2019 15:23
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.

docker -H /var/run/docker.sock always fail
5 participants