| 230 | } |
| 231 | |
| 232 | func (d *Driver) wait(ctx context.Context, l progress.SubLogger) error { |
| 233 | try := 1 |
| 234 | for { |
| 235 | bufStdout := &bytes.Buffer{} |
| 236 | bufStderr := &bytes.Buffer{} |
| 237 | if err := d.run(ctx, []string{"buildctl", "debug", "workers"}, bufStdout, bufStderr); err != nil { |
| 238 | if try > 15 { |
| 239 | d.copyLogs(context.TODO(), l) |
| 240 | if bufStdout.Len() != 0 { |
| 241 | l.Log(1, bufStdout.Bytes()) |
| 242 | } |
| 243 | if bufStderr.Len() != 0 { |
| 244 | l.Log(2, bufStderr.Bytes()) |
| 245 | } |
| 246 | return err |
| 247 | } |
| 248 | select { |
| 249 | case <-ctx.Done(): |
| 250 | return context.Cause(ctx) |
| 251 | case <-time.After(time.Duration(try*120) * time.Millisecond): |
| 252 | try++ |
| 253 | continue |
| 254 | } |
| 255 | } |
| 256 | return nil |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | func (d *Driver) copyLogs(ctx context.Context, l progress.SubLogger) error { |
| 261 | rc, err := d.DockerAPI.ContainerLogs(ctx, d.Name, dockerclient.ContainerLogsOptions{ |