Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ls: fix duplicated builders for json format #2970

Merged
merged 1 commit into from
Feb 10, 2025

Conversation

crazy-max
Copy link
Member

fixes #2969

JSON format for ls command without Go template (--format json) should not set nodes in formatter context.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@crazy-max crazy-max added this to the v0.21.0 milestone Feb 7, 2025
@crazy-max crazy-max requested a review from tonistiigi February 7, 2025 09:27
@crazy-max crazy-max marked this pull request as ready for review February 7, 2025 09:28
@@ -159,6 +159,9 @@ func lsPrint(dockerCli command.Cli, current *store.NodeGroup, builders []*builde
}
continue
}
if ctx.Format.IsJSON() {
Copy link
Member

Choose a reason for hiding this comment

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

So JSON output does not allow seeing multi-node builders and their properties/endpoints?

Copy link
Member Author

Choose a reason for hiding this comment

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

json format marshals the builder with list of nodes:

buildx/commands/ls.go

Lines 211 to 213 in 0a4eb7e

func (c *lsContext) MarshalJSON() ([]byte, error) {
return json.Marshal(c.Builder)
}

{
   "Name":"builder",
   "Driver":"docker-container",
   "LastActivity":"2025-02-06T15:15:12Z",
   "Dynamic":false,
   "Nodes":[
      {
         "Name":"builder0",
         "Endpoint":"unix:///var/run/docker.sock",
         "Flags":[
            "--debug",
            "--allow-insecure-entitlement",
            "security.insecure",
            "--allow-insecure-entitlement",
            "network.host"
         ],
         "DriverOpts":{
            "env.BUILDKIT_STEP_LOG_MAX_SIZE":"10485760",
            "env.BUILDKIT_STEP_LOG_MAX_SPEED":"10485760",
            "env.JAEGER_TRACE":"localhost:6831",
            "image":"moby/buildkit:master"
         },
         "Status":"running",
         "Version":"4b36562",
         "IDs":[
            "v6u0iluh9v6ixuqwvybs60qzj"
         ],
         "Platforms":[
            "linux/amd64",
            "linux/amd64/v2",
            "linux/amd64/v3",
            "linux/arm64",
            "linux/riscv64",
            "linux/ppc64le",
            "linux/s390x",
            "linux/386",
            "linux/arm/v7",
            "linux/arm/v6"
         ],
         "GCPolicy":[
            {
               "all":false,
               "filter":[
                  "type==source.local,type==exec.cachemount,type==source.git.checkout"
               ],
               "keepDuration":172800000000000,
               "reservedSpace":0,
               "maxUsedSpace":512000000,
               "minFreeSpace":0
            },
            {
               "all":false,
               "filter":null,
               "keepDuration":5184000000000000,
               "reservedSpace":10000000000,
               "maxUsedSpace":100000000000,
               "minFreeSpace":202000000000
            },
            {
               "all":false,
               "filter":null,
               "keepDuration":0,
               "reservedSpace":10000000000,
               "maxUsedSpace":100000000000,
               "minFreeSpace":202000000000
            },
            {
               "all":true,
               "filter":null,
               "keepDuration":0,
               "reservedSpace":10000000000,
               "maxUsedSpace":100000000000,
               "minFreeSpace":202000000000
            }
         ],
         "Labels":{
            "org.mobyproject.buildkit.worker.executor":"oci",
            "org.mobyproject.buildkit.worker.hostname":"e885c15d9fbc",
            "org.mobyproject.buildkit.worker.network":"host",
            "org.mobyproject.buildkit.worker.oci.process-mode":"sandbox",
            "org.mobyproject.buildkit.worker.selinux.enabled":"false",
            "org.mobyproject.buildkit.worker.snapshotter":"overlayfs"
         }
      }
   ]
}

While table and go template output has an entry for each builder and node. This is similar to what docker service ps does: https://docs.docker.com/reference/cli/docker/service/ps/#examples.

@tonistiigi tonistiigi merged commit b8e9c28 into docker:master Feb 10, 2025
127 checks passed
@crazy-max crazy-max deleted the fix-ls-json branch February 10, 2025 17:28
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"docker buildx ls --format json" lists each entry twice
2 participants