id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c27800
e.Encode(*t); err != nil { return err } return ioutil.WriteFile(path, w.Bytes(), 0644) }
c27801
if err := c.NetworkConfig.Validate(onExecution); err != nil { return errors.Wrapf(err, "network config") } return nil }
c27802
return errors.Wrapf(err, "invalid log_dir") } } return nil }
c27803
(len(split) == 3 && createconfig.IsValidDeviceMode(split[1])) { return fmt.Errorf("invalid device mode: %s", split[1]) } fallthrough case 1: if !strings.HasPrefix(split[0], "/dev/") { return fmt.Errorf("invalid device mode: %s", split[0]) } default: return fmt.Errorf("invalid device specific...
c27804
if err := os.MkdirAll(pluginDir, 0755); err != nil { return errors.Wrapf(err, "invalid plugin_dir entry") } } } return nil }
c27805
return false } if namespaceOptions.GetNetwork() == pb.NamespaceMode_NODE || namespaceOptions.GetPid() == pb.NamespaceMode_NODE || namespaceOptions.GetIpc() == pb.NamespaceMode_NODE { return true } return false }
c27806
conversion error") } if _, err := runtime.ValidateRuntimeHandler(handler); err != nil { return "", err } return handler, nil }
c27807
(resp *pb.RunPodSandboxResponse, err error) { // platform dependent call return s.runPodSandbox(ctx, req) }
c27808
(resp *pb.StopPodSandboxResponse, err error) { // platform dependent call return s.stopPodSandbox(ctx, req) }
c27809
err := s.StopPodSandbox(ctx, pod); err != nil { logrus.Warnf("could not StopPodSandbox %s: %v", sb.ID(), err) } } }
c27810
2)[0], "_", "-", 1) langString, ok := localeToLanguageMap[strings.ToLower(locale)] if !ok { langString = locale } return langString }
c27811
// a given container before its state gets stored c.runtime.UpdateContainerStatus(ctr) return nil }
c27812
err := ioutils.NewAtomicFileWriter(ctr.StatePath(), 0644) if err != nil { return err } defer jsonSource.Close() enc := json.NewEncoder(jsonSource) return enc.Encode(ctr.State()) }
c27813
fmt.Errorf("error reserving ctr name %s for id %s", name, id) logrus.Warn(err) return "", err } return name, nil }
c27814
fmt.Errorf("error reserving pod name %s for id %s", name, id) logrus.Warn(err) return "", err } return name, nil }
c27815
} sandbox.AddContainer(ctr) c.state.containers.Add(ctr.ID(), ctr) }
c27816
*oci.Container) { c.state.infraContainers.Add(ctr.ID(), ctr) }
c27817
return c.state.containers.Get(id) }
c27818
return c.state.infraContainers.Get(id) }
c27819
return c.state.containers.Get(id) != nil }
c27820
sb := c.state.sandboxes.Get(sbID) if sb == nil { return } sb.RemoveContainer(ctr) c.state.containers.Delete(ctr.ID()) }
c27821
*oci.Container) { c.state.infraContainers.Delete(ctr.ID()) }
c27822
for _, filter := range filters { if filter(container) { filteredContainers = append(filteredContainers, container) } } } return filteredContainers, nil }
c27823
defer c.stateLock.Unlock() return c.addSandboxPlatform(sb) }
c27824
*sandbox.Sandbox { return c.state.sandboxes.Get(id) }
c27825
nil { return nil } return sb.InfraContainer() }
c27826
return c.state.sandboxes.Get(id) != nil }
c27827
if err := c.removeSandboxPlatform(sb); err != nil { return err } c.state.sandboxes.Delete(id) return nil }
c27828
oci.ContainerStateRunning { rStatus = pb.PodSandboxState_SANDBOX_READY } linux := &pb.LinuxPodSandboxStatus{ Namespaces: &pb.Namespace{ Options: &pb.NamespaceOption{ Network: sb.NamespaceOptions().GetNetwork(), Ipc: sb.NamespaceOptions().GetIpc(), Pid: sb.NamespaceOptions().GetPid(), }...
c27829
networkCondition.Message = fmt.Sprintf("Network plugin returns error: %v", err) } resp = &pb.StatusResponse{ Status: &pb.RuntimeStatus{ Conditions: []*pb.RuntimeCondition{ runtimeCondition, networkCondition, }, }, } return resp, nil }
c27830
prometheus.MustRegister(CRIOOperationsLatency) prometheus.MustRegister(CRIOOperationsErrors) }) }
c27831
options.SourceCtx = &types.SystemContext{} } if srcRef.DockerReference() != nil { hostname := reference.Domain(srcRef.DockerReference()) if secure := svc.isSecureIndex(hostname); !secure { options.SourceCtx.DockerInsecureSkipTLSVerify = types.NewOptionalBool(!secure) } } return srcRef, nil }
c27832
defer func() { recordOperation(operation, time.Now()) recordError(operation, err) }() return &pb.UpdateRuntimeConfigResponse{}, nil }
c27833
%q: %v", containerID, err) } if err := ss.runtimeServer.Runtime().UpdateContainerStatus(c); err != nil { return err } cState := c.State() if !(cState.Status == oci.ContainerStateRunning || cState.Status == oci.ContainerStateCreated) { return fmt.Errorf("container is not created or running") } return ss.r...
c27834
} podIP = strings.Split(network.IPs[0].Address.String(), "/")[0] if len(sb.PortMappings()) > 0 { ip := net.ParseIP(podIP) if ip == nil { err = fmt.Errorf("failed to get valid ip address for sandbox %s(%s)", sb.Name(), sb.ID()) return } err = s.hostportManager.Add(sb.ID(), &hostport.PodPortMapping{ ...
c27835
res, err := cnicurrent.GetResult(result[0]) if err != nil { return "", fmt.Errorf("failed to get network JSON for pod sandbox %s(%s): %v", sb.Name(), sb.ID(), err) } return strings.Split(res.IPs[0].Address.String(), "/")[0], nil }
c27836
}); err != nil { logrus.Warnf("failed to remove hostport for pod sandbox %s(%s): %v", sb.Name(), sb.ID(), err) } podNetwork := newPodNetwork(sb) if err := s.netPlugin.TearDownPod(podNetwork); err != nil { logrus.Warnf("failed to destroy network for pod sandbox %s(%s): %v", sb.Name(), sb.ID(), err) } }
c27837
as numeric uid. uid, err := strconv.ParseInt(user, 10, 64) if err != nil { // If user is non numeric, assume it's user name. return nil, user } // If user is a numeric uid. return &uid, "" }
c27838
cState := c.State() if !(cState.Status == oci.ContainerStateRunning || cState.Status == oci.ContainerStateCreated) { return nil, fmt.Errorf("container is not created or running") } err = s.ContainerServer.Runtime().ReopenContainerLog(c) if err == nil { resp = &pb.ReopenContainerLogResponse{} } logrus.Deb...
c27839
!= nil { sel := fields.SelectorFromSet(filter.LabelSelector) if !sel.Matches(fields.Set(p.Labels)) { return false } } } return true }
c27840
return &pb.ListPodSandboxResponse{}, nil } sb := s.getSandbox(id) if sb == nil { podList = []*sandbox.Sandbox{} } else { podList = []*sandbox.Sandbox{sb} } } } for _, sb := range podList { // Skip sandboxes that aren't created yet if !sb.Created() { continue } podInfraContainer :...
c27841
// save container description to print c, err := s.GetContainerFromShortID(req.ContainerId) if err != nil { return nil, err } _, err = s.ContainerServer.Remove(ctx, req.ContainerId, true) if err != nil { return nil, err } logrus.Infof("Removed container %s", c.Description()) resp = &pb.RemoveContainerR...
c27842
w.writer.Close() return nil }
c27843
use UIDMappings with ManageNetworkNSLifecycle") } if c.GIDMappings != "" && c.ManageNetworkNSLifecycle { return fmt.Errorf("cannot use GIDMappings with ManageNetworkNSLifecycle") } if c.LogSizeMax >= 0 && c.LogSizeMax < oci.BufSize { return fmt.Errorf("log size max should be negative or >= %d", oci.BufSize) ...
c27844
path: handler.RuntimePath, root: handler.RuntimeRoot, } }
c27845
FIXME: state access should be serialized return sandboxes[j].createdAt.Before(sandboxes[i].createdAt) }
c27846
sandboxes[j] = sandboxes[j], sandboxes[i] }
c27847
return nil, err } return &ExecIO{ id: id, fifos: fifos, stdioPipes: stdio, closer: closer, }, nil }
c27848
out); err != nil { logrus.WithError(err).Errorf("Failed to pipe %q for container exec %q", t, e.id) } out.Close() stream.Close() if stdinStreamRC != nil { stdinStreamRC.Close() } e.closer.wg.Done() wg.Done() logrus.Infof("Finish piping %q of container exec %q", t, e.id) } if opts.Stdout != nil...
c27849
received += iface.RxBytes transmitted += iface.TxBytes } return }
c27850
cgroupLimit > physicalLimit { return physicalLimit } return cgroupLimit }
c27851
strings.Join([]string{id, name, string(stream)}, "-") }
c27852
*ContainerIO) error { c.fifos = fifos return nil } }
c27853
tty, stdin) if err != nil { return err } return WithFIFOs(fifos)(c) } }
c27854
nil, errors.New("fifos are not set") } // Create actual fifos. stdio, closer, err := newStdioPipes(c.fifos) if err != nil { return nil, err } c.stdioPipes = stdio c.closer = closer return c, nil }
c27855
{ logrus.WithError(err).Errorf("Failed to pipe stderr of container %q", c.id) } c.stderr.Close() c.stderrGroup.Close() wg.Done() logrus.Infof("Finish piping stderr of container %q", c.id) }() } }
c27856
nil { key := streamKey(c.id, name, Stderr) oldStderr = c.stderrGroup.Get(key) c.stderrGroup.Add(key, stderr) } return oldStdout, oldStderr }
c27857
seekInfo.Whence = 2 } t, err := tail.TailFile(logsFile, tail.Config{Follow: false, ReOpen: false, Location: seekInfo}) for line := range t.Lines { if since, err := logSinceTime(opts.SinceTime, line.Text); err != nil || !since { continue } logMessage := line.Text[secondSpaceIndex(line.Text):] logChan <-...
c27858
id: id, name: name, bundlePath: bundlePath, logPath: logPath, labels: labels, sandbox: sandbox, netns: netns, terminal: terminal, stdin: stdin, stdinOnce: stdinOnce, privileged: privileged, runtimeHandle...
c27859
:= strings.TrimPrefix(strings.ToUpper(c.stopSignal), "SIG") _, ok := signal.SignalMap[cleanSignal] if !ok { return defaultStopSignal } return cleanSignal }
c27860
:= strings.TrimPrefix(strings.ToUpper(c.stopSignal), "SIG") sig, ok := signal.SignalMap[cleanSignal] if !ok { return defaultStopSignalInt } return sig }
c27861
err != nil { return err } defer jsonSource.Close() dec := json.NewDecoder(jsonSource) return dec.Decode(c.state) }
c27862
is not populated") } if c.netns == "" { return fmt.Sprintf("/proc/%d/ns/net", c.state.Pid), nil } return c.netns, nil }
c27863
defer c.opLock.RUnlock() return c.state }
c27864
c.volumes = append(c.volumes, v) }
c27865
finished and started times c.state.Finished, c.state.Started = c.state.Created, c.state.Created if err != nil { c.state.Error = err.Error() } }
c27866
c.Labels()[types.KubernetesPodNameLabel], c.Labels()[types.KubernetesContainerNameLabel]) }
c27867
{ close := make(chan struct{}) return &writeCloseInformer{ close: close, wc: wc, }, close }
c27868
[]byte) (int, error) { return w.wc.Write(p) }
c27869
w.wc.Close() close(w.close) return err }
c27870
[]byte) (int, error) { return n.w.Write(p) }
c27871
defer s.mu.Unlock() return s.wc.Write(data) }
c27872
defer s.mu.Unlock() return s.wc.Close() }
c27873
// Make sure the kernel has CONFIG_SECCOMP_FILTER. if err := unix.Prctl(unix.PR_SET_SECCOMP, unix.SECCOMP_MODE_FILTER, 0, 0, 0); err != unix.EINVAL { enabled = true } } logrus.Debugf("seccomp status: %v", enabled) return enabled }
c27874
return setupSeccomp(config, specgen) }
c27875
return fmt.Errorf("decoding seccomp profile failed: %v", err) } return setupSeccomp(config, specgen) }
c27876
%s", ctrID) } } else { return "", errors.Errorf("cannot remove running container %s", ctrID) } } if err := c.runtime.DeleteContainer(ctr); err != nil { return "", errors.Wrapf(err, "failed to delete container %s", ctrID) } if err := os.Remove(filepath.Join(c.Config().RuntimeConfig.ContainerExitsDir, c...
c27877
panic(errors.Errorf("type registred with alternate path %q != %q", et, p)) } return } registry[t] = p }
c27878
err != nil { return false } return any.TypeUrl == url }
c27879
marshal = func(v interface{}) ([]byte, error) { return proto.Marshal(t) } default: marshal = json.Marshal } url, err := TypeURL(v) if err != nil { return nil, err } data, err := marshal(v) if err != nil { return nil, err } return &types.Any{ TypeUrl: url, Value: data, }, nil }
c27880
} v := reflect.New(t.t).Interface() if t.isProto { err = proto.Unmarshal(any.Value, v.(proto.Message)) } else { err = json.Unmarshal(any.Value, v) } return v, err }
c27881
err } if info.Mode()&os.ModeSymlink != os.ModeSymlink { return path, nil } if scope == "" { scope = "/" } return symlink.FollowSymlinkInScope(path, scope) }
c27882
if len(kubeCommands) == 0 && len(kubeArgs) == 0 { return nil, fmt.Errorf("no command specified") } // create entrypoint and args var entrypoint string var args []string if len(kubeCommands) != 0 { entrypoint = kubeCommands[0] args = append(kubeCommands[1:], kubeArgs...) } else { entrypoint = kubeArgs[0...
c27883
return err } mnt := rspec.Mount{ Type: "bind", Source: passwdPath, Destination: "/etc/passwd", Options: []string{"ro", "bind", "nodev", "nosuid", "noexec"}, } specgen.AddMount(mnt) } specgen.SetProcessUID(uid) specgen.SetProcessGID(gid) if sc.GetRunAsGroup() != nil { specgen...
c27884
We use the user from the image config if nothing is provided if userstr == "" { userstr = imageUser } if userstr == "" { return "" } return userstr }
c27885
secretMounts(defaultMounts, mountLabel, ctrRunDir, containerMounts) if err != nil { return nil, err } return mounts, nil }
c27886
// If the value is runtime/default, then return default profile. return s.appArmorProfile } return strings.TrimPrefix(profile, apparmorLocalHostPrefix) }
c27887
pauseImage: pauseImage, pauseImageAuthFile: pauseImageAuthFile, ctx: ctx, } }
c27888
:= History(c.all()) sandboxes.sort() return sandboxes }
c27889
if filter(cont) { return cont } } return nil }
c27890
if err = updateConfigName(configRuntimePath, name); err != nil { return err } configStoragePath := filepath.Join(ctr.Dir(), configFile) if err = updateConfigName(configStoragePath, name); err != nil { return err } // Update containers.json if err = c.store.SetNames(ctr.ID(), []string{name}); err != nil { ...
c27891
} return string(m) case "sandbox": metadata := runtime.PodSandboxMetadata{} err := json.Unmarshal([]byte(oldMetadata), &metadata) if err != nil { return oldMetadata } metadata.Name = name m, err := json.Marshal(metadata) if err != nil { return oldMetadata } return string(m) default: re...
c27892
// Walk does not follow symbolic links if err != nil { return err } dirSize += uint64(info.Size()) inodeCount++ return nil }) if err != nil { return 0, 0, err } return dirSize, inodeCount, err }
c27893
if cStatus.Status != oci.ContainerStateRunning { return "", errors.Errorf("cannot kill container %s: it is not running", container) } if err = c.runtime.SignalContainer(ctr, killSignal); err != nil { return "", err } c.ContainerStateToDisk(ctr) return ctr.ID(), nil }
c27894
if err != nil { return nil, err } n.netNS = netNS n.closed = false n.initialized = true return n, nil }
c27895
return err } fd, err := os.Open(symlinkPath) if err != nil { if removeErr := os.RemoveAll(symlinkPath); removeErr != nil { return removeErr } return err } n.symlink = fd return nil }
c27896
|| n.netNS == nil { return "" } return n.netNS.Path() }
c27897
|| n.netNS == nil { return nil } return n.netNS.Close() }
c27898
"/") if err != nil { return err } if mounted, err := mount.Mounted(fp); err == nil && mounted { if err := unix.Unmount(fp, unix.MNT_DETACH); err != nil { return err } } if n.Path() != "" { if err := os.RemoveAll(n.Path()); err != nil { return err } } } return nil }
c27899
tty) if err != nil { return nil, err } if !stdin { fifos.Stdin = "" } return fifos, nil }