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

rm: display removed builder and disallow removing context builders#1128

Merged
merged 3 commits into from
May 24, 2022

Conversation

crazy-max
Copy link
Member

was looking at allowing removing multiple builders with a single invocation of rm command and also fixing removing timed out runners not in running state with --all-inactive but before that small enhancements:

  • display error message if trying to remove default builder

atm if "default" is used and try to remove it, command exits without saying it cannot be removed. this PR fixes it and now error if we try to do so:

$ docker buildx use default
$ docker buildx rm # or docker buildx rm default
ERROR: default builder cannot be removed
  • display name of removed builder

we don't log anything if the builder has been effectively removed. It's useful in case we don't specify the builder so we know what has been removed:

$ docker buildx create --use
nostalgic_gould
$ docker buildx rm # or docker buildx rm nostalgic_gould
nostalgic_gould removed

also adds another commit to uppercase error level to match the one of logrus.

@crazy-max crazy-max requested review from tonistiigi and jedevc May 13, 2022 16:18
commands/rm.go Outdated Show resolved Hide resolved
commands/rm.go Outdated Show resolved Hide resolved
@crazy-max crazy-max force-pushed the rm branch 2 times, most recently from 7e73a0f to c3247f3 Compare May 15, 2022 02:41
@crazy-max crazy-max changed the title rm: display removed builder and error if removing default builder rm: display removed builder and disallow removing default or context builders May 15, 2022
@crazy-max crazy-max changed the title rm: display removed builder and disallow removing default or context builders rm: display removed builder and disallow removing context builders May 15, 2022
commands/rm.go Outdated
if err := txn.Remove(ng.Name); err != nil {
return err
for _, cb := range ctxbuilders {
if ng.Name == "default" && len(ng.Nodes) == 1 && ng.Nodes[0].Endpoint == cb.Name {
Copy link
Member

Choose a reason for hiding this comment

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

Not sure why there is a "default" name check in here. Shouldn't it check that ng.Driver == "docker" ? What does the "default" mean in here?

Didn't we already have an error suggesting to use docker context somewhere or am I mixing it up with some other case.

Copy link
Member Author

@crazy-max crazy-max May 19, 2022

Choose a reason for hiding this comment

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

Not sure why there is a "default" name check in here.

This is how it's populated from store util for context instances:

return &store.NodeGroup{
Name: "default",
Nodes: []store.Node{
{
Name: "default",
Endpoint: name,
},
},

Shouldn't it check that ng.Driver == "docker" ?

I don't think it will work in standalone where docker is not available so a docker-container builder will be the "default": #1128 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

docker-container is not the default ever, it always requires an instance to be created and therefore can always be removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

as discussed I switched to the cond on the driver name.

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
@tonistiigi tonistiigi merged commit 35f4268 into docker:master May 24, 2022
@crazy-max crazy-max deleted the rm branch May 24, 2022 21:07
@crazy-max crazy-max added this to the v0.9.0 milestone Jun 5, 2022
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.

3 participants