func (i *InteractionHandlersImpl) ContainerGetStdoutHandler(params interaction.ContainerGetStdoutParams) 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 stdout 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 stdout", params.ID) timeout = interactionTimeout } contConn, err := i.attachServer.Get(context.Background(), params.ID, timeout) if err != nil { err = fmt.Errorf("No stdout found for %s: %s", params.ID, err.Error()) log.Errorf("%s", err.Error()) return interaction.NewContainerGetStdoutNotFound() } detachableOut := NewFlushingReader(contConn.Stdout()) return NewContainerOutputHandler("stdout").WithPayload(detachableOut, params.ID) }
// ContainerGetStdoutHandler returns the stdout func (i *InteractionHandlersImpl) ContainerGetStdoutHandler(params interaction.ContainerGetStdoutParams) 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 stdout with deadline %s", params.ID, ctxDeadline.Format(time.UnixDate)) if timeout < 0 { e := &models.Error{Message: fmt.Sprintf("Deadline for stdout already passed for container %s", params.ID)} return interaction.NewContainerGetStdoutInternalServerError().WithPayload(e) } } else { log.Debugf("Attempting to get ssh session for container %s stdout", 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 stdout connection found (id: %s): %s", params.ID, err.Error()), } return interaction.NewContainerGetStdoutNotFound().WithPayload(e) */ return interaction.NewContainerGetStdoutNotFound() } return NewContainerOutputHandler("stdout").WithPayload( NewFlushingReader( session.Stdout(), ), params.ID, ) }