@@ -207,7 +207,7 @@ func getContainerWait(ctx context.Context, address string, config *logging.Confi
207207
208208type ContainerWaitFunc func (ctx context.Context , address string , config * logging.Config ) (<- chan containerd.ExitStatus , error )
209209
210- func loggingProcessAdapter (ctx context.Context , driver Driver , dataStore , address string , getContainerWait ContainerWaitFunc , config * logging.Config ) error {
210+ func loggingProcessAdapter (ctx context.Context , driver Driver , dataStore string , config * logging.Config ) error {
211211 if err := driver .PreProcess (ctx , dataStore , config ); err != nil {
212212 return err
213213 }
@@ -220,6 +220,17 @@ func loggingProcessAdapter(ctx context.Context, driver Driver, dataStore, addres
220220 if err != nil {
221221 return err
222222 }
223+
224+ stdoutChan , err := waitIOClose (config .Stdout )
225+ if err != nil {
226+ return err
227+ }
228+
229+ stderrChan , err := waitIOClose (config .Stderr )
230+ if err != nil {
231+ return err
232+ }
233+
223234 go func () {
224235 <- ctx .Done () // delivered on SIGTERM
225236 stdoutR .Cancel ()
@@ -273,13 +284,8 @@ func loggingProcessAdapter(ctx context.Context, driver Driver, dataStore, addres
273284 // close pipeStdoutW and pipeStderrW upon container exit
274285 defer pipeStdoutW .Close ()
275286 defer pipeStderrW .Close ()
276-
277- exitCh , err := getContainerWait (ctx , address , config )
278- if err != nil {
279- log .G (ctx ).Errorf ("failed to get container task wait channel: %v" , err )
280- return
281- }
282- <- exitCh
287+ <- stdoutChan
288+ <- stderrChan
283289 }()
284290 wg .Wait ()
285291 return driver .PostProcess ()
@@ -314,7 +320,7 @@ func loggerFunc(dataStore string) (logging.LoggerFunc, error) {
314320 return err
315321 }
316322 // getContainerWait is extracted as parameter to allow mocking in tests.
317- return loggingProcessAdapter (ctx , driver , dataStore , logConfig . Address , getContainerWait , config )
323+ return loggingProcessAdapter (ctx , driver , dataStore , config )
318324 })
319325 } else if ! errors .Is (err , os .ErrNotExist ) {
320326 // the file does not exist if the container was created with nerdctl < 0.20
0 commit comments