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

docker/info use format JSON #1008

Merged
merged 1 commit into from
Aug 21, 2023
Merged

docker/info use format JSON #1008

merged 1 commit into from
Aug 21, 2023

Conversation

Dasio
Copy link
Contributor

@Dasio Dasio commented Jul 20, 2023

  • use host CPU from Host property if available

This partially fix #855

Test plan

I have run unit tests.
Also tried it locally with my podman.
Still getting some error regarding volumes and tmp files. But that seems more related to podman itself probably.

I need someone to test it also with docker. If it's still work.

  • tested, it should work

Copy link
Contributor

@mrnugget mrnugget left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks! But I think some comments would be super helpful.

internal/batches/docker/info.go Outdated Show resolved Hide resolved
@Dasio Dasio force-pushed the main branch 2 times, most recently from 7b42af5 to afacb29 Compare July 20, 2023 09:27
 - use host CPU from Host property if available
 - this allows to use podman
@Dasio
Copy link
Contributor Author

Dasio commented Jul 20, 2023

Docker doesn't have format=json, but we can use Go template {{ json .}} for both podman and docker

@mrnugget
Copy link
Contributor

Docker doesn't have format=json, but we can use Go template {{ json .}} for both podman and docker

It does, no?

φ docker info --format json
{"ID":"fdd17e44-fa14-44a6-bcea-675088894c15","Containers":0,"ContainersRunning":0,"ContainersPaused":0,"ContainersStopped":0,"Images":2,"Driver":"overlay2","DriverStatus":[["Backing Filesystem","extfs"],["Supports d_type","true"],["Using metacopy","false"],["Native Overlay Diff","true"],["userxattr","false"]],"Plugins":{"Volume":["local"],"Network":["bridge","host","ipvlan","macvlan","null","overlay"],"Authorization":null,"Log":["awslogs","fluentd","gcplogs","gelf","journald","json-file","local","logentries","splunk","syslog"]},"MemoryLimit":true,"SwapLimit":true,"CpuCfsPeriod":true,"CpuCfsQuota":true,"CPUShares":true,"CPUSet":true,"PidsLimit":true,"IPv4Forwarding":true,"BridgeNfIptables":true,"BridgeNfIp6tables":true,"Debug":false,"NFd":43,"OomKillDisable":false,"NGoroutines":64,"SystemTime":"2023-07-20T09:41:46.116258384Z","LoggingDriver":"json-file","CgroupDriver":"cgroupfs","CgroupVersion":"2","NEventsListener":9,"KernelVersion":"5.15.49-linuxkit-pr","OperatingSystem":"Docker Desktop","OSVersion":"","OSType":"linux","Architecture":"aarch64","IndexServerAddress":"https://index.docker.io/v1/","RegistryConfig":{"AllowNondistributableArtifactsCIDRs":null,"AllowNondistributableArtifactsHostnames":null,"InsecureRegistryCIDRs":["127.0.0.0/8"],"IndexConfigs":{"docker.io":{"Name":"docker.io","Mirrors":[],"Secure":true,"Official":true},"hubproxy.docker.internal:5555":{"Name":"hubproxy.docker.internal:5555","Mirrors":[],"Secure":false,"Official":false}},"Mirrors":null},"NCPU":5,"MemTotal":8337481728,"GenericResources":null,"DockerRootDir":"/var/lib/docker","HttpProxy":"http.docker.internal:3128","HttpsProxy":"http.docker.internal:3128","NoProxy":"hubproxy.docker.internal","Name":"docker-desktop","Labels":[],"ExperimentalBuild":false,"ServerVersion":"24.0.2","Runtimes":{"io.containerd.runc.v2":{"path":"runc"},"runc":{"path":"runc"}},"DefaultRuntime":"runc","Swarm":{"NodeID":"","NodeAddr":"","LocalNodeState":"inactive","ControlAvailable":false,"Error":"","RemoteManagers":null},"LiveRestoreEnabled":false,"Isolation":"","InitBinary":"docker-init","ContainerdCommit":{"ID":"3dce8eb055cbb6872793272b4f20ed16117344f8","Expected":"3dce8eb055cbb6872793272b4f20ed16117344f8"},"RuncCommit":{"ID":"v1.1.7-0-g860f061","Expected":"v1.1.7-0-g860f061"},"InitCommit":{"ID":"de40ad0","Expected":"de40ad0"},"SecurityOptions":["name=seccomp,profile=builtin","name=cgroupns"],"Warnings":null,"ClientInfo":{"Debug":false,"Version":"24.0.2","GitCommit":"cb74dfc","GoVersion":"go1.20.4","Os":"darwin","Arch":"arm64","BuildTime":"Thu May 25 21:51:16 2023","Context":"desktop-linux","Plugins":[{"SchemaVersion":"0.1.0","Vendor":"Docker Inc.","Version":"v0.10.5","ShortDescription":"Docker Buildx","Name":"buildx","Path":"/Users/thorstenball/.docker/cli-plugins/docker-buildx","ShadowedPaths":["/usr/local/lib/docker/cli-plugins/docker-buildx"]},{"SchemaVersion":"0.1.0","Vendor":"Docker Inc.","Version":"v2.18.1","ShortDescription":"Docker Compose","Name":"compose","Path":"/Users/thorstenball/.docker/cli-plugins/docker-compose","ShadowedPaths":["/usr/local/lib/docker/cli-plugins/docker-compose"]},{"SchemaVersion":"0.1.0","Vendor":"Docker Inc.","Version":"v0.1.0","ShortDescription":"Docker Dev Environments","Name":"dev","Path":"/Users/thorstenball/.docker/cli-plugins/docker-dev","ShadowedPaths":["/usr/local/lib/docker/cli-plugins/docker-dev"]},{"SchemaVersion":"0.1.0","Vendor":"Docker Inc.","Version":"v0.2.19","ShortDescription":"Manages Docker extensions","Name":"extension","Path":"/Users/thorstenball/.docker/cli-plugins/docker-extension","ShadowedPaths":["/usr/local/lib/docker/cli-plugins/docker-extension"]},{"SchemaVersion":"0.1.0","Vendor":"Docker Inc.","Version":"v0.1.0-beta.4","ShortDescription":"Creates Docker-related starter files for your project","Name":"init","Path":"/Users/thorstenball/.docker/cli-plugins/docker-init","ShadowedPaths":["/usr/local/lib/docker/cli-plugins/docker-init"]},{"SchemaVersion":"0.1.0","Vendor":"Anchore Inc.","Version":"0.6.0","ShortDescription":"View the packaged-based Software Bill Of Materials (SBOM) for an image","URL":"https://github.com/docker/sbom-cli-plugin","Name":"sbom","Path":"/Users/thorstenball/.docker/cli-plugins/docker-sbom","ShadowedPaths":["/usr/local/lib/docker/cli-plugins/docker-sbom"]},{"SchemaVersion":"0.1.0","Vendor":"Docker Inc.","Version":"v0.26.0","ShortDescription":"Docker Scan","Name":"scan","Path":"/Users/thorstenball/.docker/cli-plugins/docker-scan","ShadowedPaths":["/usr/local/lib/docker/cli-plugins/docker-scan"]},{"SchemaVersion":"0.1.0","Vendor":"Docker Inc.","Version":"v0.12.0","ShortDescription":"Command line tool for Docker Scout","Name":"scout","Path":"/Users/thorstenball/.docker/cli-plugins/docker-scout","ShadowedPaths":["/usr/local/lib/docker/cli-plugins/docker-scout"]}],"Warnings":null}}

@Dasio
Copy link
Contributor Author

Dasio commented Jul 20, 2023

Hm, my colleague tried it and it output just json nothing more.

His docker version output:

Client: Docker Engine - Community
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:03:23 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.11
  Git commit:       a89b842
  Built:            Mon Jun  6 23:01:15 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.6
  GitCommit:        10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc:
  Version:          1.1.2
  GitCommit:        v1.1.2-0-ga916309
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Maybe old version?

https://docs.docker.com/go/formatting/ here is no reference to json just -format='{{json .}}'

@mrnugget
Copy link
Contributor

If it's version dependent, then this would be a breaking change, I guess, right?

@Dasio
Copy link
Contributor Author

Dasio commented Jul 20, 2023

With -format='{{json .}}' it should be alright.

@mrnugget
Copy link
Contributor

Yeah, that works.

@Dasio Dasio requested a review from mrnugget July 20, 2023 11:27
Copy link
Member

@eseliger eseliger left a comment

Choose a reason for hiding this comment

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

Looks good to me, docker still works on my machine. Thanks!

@eseliger eseliger merged commit ee449a7 into sourcegraph:main Aug 21, 2023
2 checks passed
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.

src-cli doesn't work with podman
3 participants