Skip to content

Instantly share code, notes, and snippets.

@ihcsim
Last active February 4, 2020 06:15
Show Gist options
  • Select an option

  • Save ihcsim/86d530a491408ae1d2e966fb407618ad to your computer and use it in GitHub Desktop.

Select an option

Save ihcsim/86d530a491408ae1d2e966fb407618ad to your computer and use it in GitHub Desktop.
// 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
}
if resp.Url == "" {
errorMessage := "URL is not set"
klog.Errorf("Exec failed: %s", errorMessage)
return nil, errors.New(errorMessage)
}
return resp, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment