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

[BUG] writer associated with ctx via progress.WithContextWriter(ctx, writer) from external is not respeced #10091

Open
tigerinus opened this issue Dec 17, 2022 · 4 comments · May be fixed by #10097

Comments

@tigerinus
Copy link
Contributor

Description

Trying to write a code in Go to interact with docker compose. The interaction includes reading messages from a custom writer associated with ctx via progress.WithContextWriter(ctx, writer)

Steps To Reproduce

See code at https://go.dev/play/p/xBTIGKO3pzR

Notice the lines

	r, w, err := os.Pipe()

	writer, err := progress.NewWriter(w)
	if err != nil {
		panic(err)
	}

	progress.WithContextWriter(ctx, writer)

In the https://github.com/docker/compose/blob/v2/pkg/progress/writer.go, the custom writer is overriden:

image

Compose Version

$ docker compose version
Docker Compose version v2.14.1

Docker Environment

$ docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.9.1-docker)
  compose: Docker Compose (Docker Inc., v2.14.1)

Server:
 Containers: 2
  Running: 2
  Paused: 0
  Stopped: 0
 Images: 4
 Server Version: 20.10.21
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: a05d175400b1145e5e6a735a6710579d181e7fb0
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.15.0-1025-oracle
 Operating System: Ubuntu 22.04.1 LTS
 OSType: linux
 Architecture: aarch64
 CPUs: 4
 Total Memory: 23.43GiB
 Name: cloudberry-2
 ID: TSYZ:EZ4P:2AJ5:DJT7:SHHC:7XP5:5LBW:DB7Z:UGOZ:YIUF:THLR:FHV7
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

No response

@ndeloof
Copy link
Contributor

ndeloof commented Dec 18, 2022

I'm sorry, I don't understand what you expect here.
RunWithStatus is responsible for the lifetime of the Writer it's using, i.e it creates one, and MUST ensure it get stopped before returning. What would you suggest here? (feel free to open a Pull Request so this is easier to understand)

@tigerinus
Copy link
Contributor Author

@ndeloof thanks for looking into this.

I am writing a tool, which you can think of a frontend wrapper of docker compose. Part of the feature is to show the progress of image pulling when calling Pull, Create or Up methods of compose service.

I was expecting providing my own writer so I can capture something. However due to this bug (or design), it doesn't respect the custom writer and returns nothing.

@tigerinus
Copy link
Contributor Author

@ndeloof - please see my PR.

@stale
Copy link

stale bot commented Jun 18, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants