Example #1
0
// Attach prepares a streaming endpoint to attach to a running container, and returns the address.
func (ds *dockerService) Attach(req *runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error) {
	if ds.streamingServer == nil {
		return nil, streaming.ErrorStreamingDisabled("attach")
	}
	_, err := checkContainerStatus(ds.client, req.GetContainerId())
	if err != nil {
		return nil, err
	}
	return ds.streamingServer.GetAttach(req)
}
Example #2
0
func (s *server) GetAttach(req *runtimeapi.AttachRequest, tty bool) (*runtimeapi.AttachResponse, error) {
	url := s.buildURL("attach", req.GetContainerId(), streamOpts{
		stdin:  req.GetStdin(),
		stdout: true,
		stderr: !tty, // For TTY connections, both stderr is combined with stdout.
		tty:    tty,
	})
	return &runtimeapi.AttachResponse{
		Url: &url,
	}, nil
}
// Attach prepares a streaming endpoint to attach to a running container, and returns the address.
func (r *RemoteRuntimeService) Attach(req *runtimeApi.AttachRequest) (*runtimeApi.AttachResponse, error) {
	ctx, cancel := getContextWithTimeout(r.timeout)
	defer cancel()

	resp, err := r.runtimeClient.Attach(ctx, req)
	if err != nil {
		glog.Errorf("Attach %s from runtime service failed: %v", req.GetContainerId(), err)
		return nil, err
	}

	return resp, nil
}
Example #4
0
func (s *server) GetAttach(req *runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error) {
	if req.GetContainerId() == "" {
		return nil, grpc.Errorf(codes.InvalidArgument, "missing required container_id")
	}
	token, err := s.cache.Insert(req)
	if err != nil {
		return nil, err
	}
	return &runtimeapi.AttachResponse{
		Url: s.buildURL("attach", token),
	}, nil
}
func (r *FakeRuntime) Attach(req *runtimeApi.AttachRequest) (*runtimeApi.AttachResponse, error) {
	url := "http://" + FakeStreamingHost + ":" + FakeStreamingPort + "/attach/" + req.GetContainerId()
	return &runtimeApi.AttachResponse{
		Url: &url,
	}, nil
}