Exemplo n.º 1
0
// PortForward prepares a streaming endpoint to forward ports from a PodSandbox, and returns the address.
func (ds *dockerService) PortForward(req *runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error) {
	if ds.streamingServer == nil {
		return nil, streaming.ErrorStreamingDisabled("port forward")
	}
	_, err := checkContainerStatus(ds.client, req.GetPodSandboxId())
	if err != nil {
		return nil, err
	}
	// TODO(timstclair): Verify that ports are exposed.
	return ds.streamingServer.GetPortForward(req)
}
// PortForward prepares a streaming endpoint to forward ports from a PodSandbox, and returns the address.
func (r *RemoteRuntimeService) PortForward(req *runtimeApi.PortForwardRequest) (*runtimeApi.PortForwardResponse, error) {
	ctx, cancel := getContextWithTimeout(r.timeout)
	defer cancel()

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

	return resp, nil
}
Exemplo n.º 3
0
func (s *server) GetPortForward(req *runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error) {
	if req.GetPodSandboxId() == "" {
		return nil, grpc.Errorf(codes.InvalidArgument, "missing required pod_sandbox_id")
	}
	token, err := s.cache.Insert(req)
	if err != nil {
		return nil, err
	}
	return &runtimeapi.PortForwardResponse{
		Url: s.buildURL("portforward", token),
	}, nil
}
Exemplo n.º 4
0
func (s *server) GetPortForward(req *runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error) {
	url := s.buildURL("portforward", req.GetPodSandboxId(), streamOpts{})
	return &runtimeapi.PortForwardResponse{
		Url: &url,
	}, nil
}