func (i *InteractionHandlersImpl) ContainerGetStderrHandler(params interaction.ContainerGetStderrParams) middleware.Responder { defer trace.End(trace.Begin(params.ID)) var ctxDeadline time.Time var timeout time.Duration // Calculate the timeout for the attach if the caller specified a deadline if params.Deadline != nil { ctxDeadline = time.Time(*params.Deadline) timeout = ctxDeadline.Sub(time.Now()) log.Printf("Attempting to get ssh session for container %s stderr with deadline %s", params.ID, ctxDeadline.Format(time.UnixDate)) if timeout < 0 { e := &models.Error{Message: fmt.Sprintf("Deadline for stdin already passed for container %s", params.ID)} return interaction.NewContainerGetStdoutInternalServerError().WithPayload(e) } } else { log.Printf("Attempting to get ssh session for container %s stderr", params.ID) timeout = interactionTimeout } contConn, err := i.attachServer.Get(context.Background(), params.ID, timeout) if err != nil { err = fmt.Errorf("No stderr found for %s: %s", params.ID, err.Error()) log.Errorf("%s", err.Error()) return interaction.NewContainerGetStderrNotFound() } detachableErr := NewFlushingReader(contConn.Stderr()) return NewContainerOutputHandler("stderr").WithPayload(detachableErr, params.ID) }
// ContainerGetStderrHandler returns the stderr func (i *InteractionHandlersImpl) ContainerGetStderrHandler(params interaction.ContainerGetStderrParams) middleware.Responder { defer trace.End(trace.Begin(params.ID)) var ctxDeadline time.Time var timeout time.Duration // Calculate the timeout for the attach if the caller specified a deadline if params.Deadline != nil { ctxDeadline = time.Time(*params.Deadline) timeout = ctxDeadline.Sub(time.Now()) log.Debugf("Attempting to get ssh session for container %s stderr with deadline %s", params.ID, ctxDeadline.Format(time.UnixDate)) if timeout < 0 { e := &models.Error{Message: fmt.Sprintf("Deadline for stderr already passed for container %s", params.ID)} return interaction.NewContainerGetStderrInternalServerError().WithPayload(e) } } else { log.Debugf("Attempting to get ssh session for container %s stderr", params.ID) timeout = interactionTimeout } session, err := i.attachServer.Get(context.Background(), params.ID, timeout) if err != nil { log.Errorf("%s", err.Error()) // FIXME (caglar10ur): Do not return an error here - https://github.com/vmware/vic/issues/2594 /* e := &models.Error{ Message: fmt.Sprintf("No stderr connection found (id: %s): %s", params.ID, err.Error()), } return interaction.NewContainerGetStderrNotFound().WithPayload(e) */ return interaction.NewContainerGetStderrNotFound() } return NewContainerOutputHandler("stderr").WithPayload( NewFlushingReader( session.Stderr(), ), params.ID, ) }