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

fix broken alias check is buildx is installed as alias for builder #3795

Merged
merged 1 commit into from
Sep 30, 2022

Conversation

thaJeztah
Copy link
Member

Commit cbec75e (#3429) updated runDocker() to load plugin-stubs before processAliases() was executed. As a result, plugin stubs were considered as "builtin commands", causing the alias verification to fail;

Without alias installed:

docker version
Client:
 Version:           22.06.0-beta.0-140-g3dad26ca2.m
 API version:       1.42
 Go version:        go1.19.1
 Git commit:        3dad26ca2
 Built:             Wed Sep 28 22:36:09 2022
 OS/Arch:           darwin/arm64
 Context:           default
...

After running docker buildx install;

./build/docker buildx install

cat ~/.docker/config.json
{
    "aliases": {
        "builder": "buildx"
    }
}

./build/docker version
not allowed to alias with builtin "buildx" as target

This patch moves loading the stubs after the call to processAliases(), so that verification passes. As an extra precaution, the processAliases() function is also updated to exclude plugin-stub commands.

Note that cbec75e (#3429) also introduced a performance regression (#3621), which may be related to the early loading of plugins (and creating stubs); it looks like various other code locations may also be loading plugins, for example tryPluginRun() calls pluginmanager.PluginRunCommand(), which also traverses plugin directories.

We should look under what circumstances the plugin stub-commands are actually needed, and make sure that they're only created in those situations.

- A picture of a cute animal (not mandatory but encouraged)

Commit cbec75e updated `runDocker()` to load
plugin-stubs before `processAliases()` was executed. As a result, plugin
stubs were considered as "builtin commands", causing the alias verification
to fail;

Without alias installed:

```bash
docker version
Client:
 Version:           22.06.0-beta.0-140-g3dad26ca2.m
 API version:       1.42
 Go version:        go1.19.1
 Git commit:        3dad26c
 Built:             Wed Sep 28 22:36:09 2022
 OS/Arch:           darwin/arm64
 Context:           default
...
```

After running `docker buildx install`;

```bash
./build/docker buildx install

cat ~/.docker/config.json
{
    "aliases": {
        "builder": "buildx"
    }
}

./build/docker version
not allowed to alias with builtin "buildx" as target
```

This patch moves loading the stubs _after_ the call to `processAliases()`, so
that verification passes. As an extra precaution, the `processAliases()` function
is also updated to exclude plugin-stub commands.

Note that cbec75e also introduced a performance
regression, which may be related to the early loading of plugins (and creating
stubs); it looks like various other code locations may also be loading plugins,
for example `tryPluginRun()` calls `pluginmanager.PluginRunCommand()`, which
also traverses plugin directories.

We should look under what circumstances the plugin stub-commands are actually
needed, and make sure that they're only created in those situations.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@codecov-commenter
Copy link

Codecov Report

Merging #3795 (a8d2479) into master (ef80de3) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

❗ Current head a8d2479 differs from pull request most recent head 7af8aac. Consider uploading reports for the commit 7af8aac to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3795      +/-   ##
==========================================
- Coverage   59.29%   59.29%   -0.01%     
==========================================
  Files         288      288              
  Lines       24640    24641       +1     
==========================================
  Hits        14610    14610              
- Misses       9160     9161       +1     
  Partials      870      870              

Copy link
Member

@crazy-max crazy-max left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah
Copy link
Member Author

thx; let me bring this one in 👍

@thaJeztah thaJeztah merged commit a496a7d into docker:master Sep 30, 2022
@thaJeztah thaJeztah deleted the ignore_stubs_in_aliases branch September 30, 2022 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[master / 22.06] docker buildx install breaks alias check
3 participants