This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| restStorageMap := map[string]rest.Storage{ | |
| "pods": podStorage.Pod, | |
| "pods/attach": podStorage.Attach, | |
| "pods/status": podStorage.Status, | |
| "pods/log": podStorage.Log, | |
| "pods/exec": podStorage.Exec, | |
| "pods/portforward": podStorage.PortForward, | |
| "pods/proxy": podStorage.Proxy, | |
| "pods/binding": podStorage.Binding, | |
| "bindings": podStorage.LegacyBinding, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if err := s.installAPIResources(apiPrefix, apiGroupInfo, openAPIModels); err != nil { | |
| return err | |
| } | |
| // Install the version handler. | |
| // Add a handler at /<apiPrefix> to enumerate the supported api versions. | |
| s.Handler.GoRestfulContainer.Add(discovery.NewLegacyRootAPIHandler(s.discoveryAddresses, s.Serializer, apiPrefix).WebService()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Connect returns a handler for the pod exec proxy | |
| func (r *ExecREST) Connect(ctx context.Context, name string, opts runtime.Object, responder rest.Responder) (http.Handler, error) { | |
| execOpts, ok := opts.(*api.PodExecOptions) | |
| if !ok { | |
| return nil, fmt.Errorf("invalid options object: %#v", opts) | |
| } | |
| location, transport, err := pod.ExecLocation(r.Store, r.KubeletConn, ctx, name, execOpts) | |
| if err != nil { | |
| return nil, err | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // NewServer initializes and configures a kubelet.Server object to handle HTTP requests. | |
| func NewServer( | |
| // ... | |
| criHandler http.Handler) Server { | |
| // ... | |
| if enableDebuggingHandlers { | |
| server.InstallDebuggingHandlers(criHandler) | |
| if enableContentionProfiling { | |
| goruntime.SetBlockProfileRate(1) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // InstallDebuggingHandlers registers the HTTP request patterns that serve logs or run commands/containers | |
| func (s *Server) InstallDebuggingHandlers(criHandler http.Handler) { | |
| // ... | |
| ws = new(restful.WebService) | |
| ws. | |
| Path("/exec") | |
| ws.Route(ws.GET("/{podNamespace}/{podID}/{containerName}"). | |
| To(s.getExec). | |
| Operation("getExec")) | |
| ws.Route(ws.POST("/{podNamespace}/{podID}/{containerName}"). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // getExec handles requests to run a command inside a container. | |
| func (s *Server) getExec(request *restful.Request, response *restful.Response) { | |
| // ... | |
| podFullName := kubecontainer.GetPodFullName(pod) | |
| url, err := s.host.GetExec(podFullName, params.podUID, params.containerName, params.cmd, *streamOpts) | |
| if err != nil { | |
| streaming.WriteError(err, response.ResponseWriter) | |
| return | |
| } | |
| // ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // GetExec gets the endpoint the runtime will serve the exec request from. | |
| func (m *kubeGenericRuntimeManager) GetExec(id kubecontainer.ContainerID, cmd []string, stdin, stdout, stderr, tty bool) (*url.URL, error) { | |
| // ... | |
| resp, err := m.runtimeService.Exec(req) | |
| if err != nil { | |
| return nil, err | |
| } | |
| return url.Parse(resp.Url) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (in instrumentedRuntimeService) Exec(req *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) { | |
| const operation = "exec" | |
| defer recordOperation(operation, time.Now()) | |
| resp, err := in.service.Exec(req) | |
| recordError(operation, err) | |
| return resp, err | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Exec prepares a streaming endpoint to execute a command in the container, and returns the address. | |
| func (r *RemoteRuntimeService) Exec(req *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) { | |
| ctx, cancel := getContextWithTimeout(r.timeout) | |
| defer cancel() | |
| resp, err := r.runtimeClient.Exec(ctx, req) | |
| if err != nil { | |
| klog.Errorf("Exec %s '%s' from runtime service failed: %v", req.ContainerId, strings.Join(req.Cmd, " "), err) | |
| return nil, err | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Exec prepares a streaming endpoint to execute a command in the container, and returns the address. | |
| func (ds *dockerService) Exec(_ context.Context, req *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) { | |
| if ds.streamingServer == nil { | |
| return nil, streaming.NewErrorStreamingDisabled("exec") | |
| } | |
| _, err := checkContainerStatus(ds.client, req.ContainerId) | |
| if err != nil { | |
| return nil, err | |
| } | |
| return ds.streamingServer.GetExec(req) |