當前位置: 首頁>>代碼示例>>Golang>>正文


Golang cgroups.IsNotFound函數代碼示例

本文整理匯總了Golang中github.com/opencontainers/runc/libcontainer/cgroups.IsNotFound函數的典型用法代碼示例。如果您正苦於以下問題:Golang IsNotFound函數的具體用法?Golang IsNotFound怎麽用?Golang IsNotFound使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了IsNotFound函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Apply

func (s *MemoryGroup) Apply(d *cgroupData) (err error) {
	path, err := d.path("memory")
	if err != nil && !cgroups.IsNotFound(err) {
		return err
	}
	if memoryAssigned(d.config) {
		if path != "" {
			if err := os.MkdirAll(path, 0755); err != nil {
				return err
			}
		}

		if err := s.Set(path, d.config); err != nil {
			return err
		}
	}

	defer func() {
		if err != nil {
			os.RemoveAll(path)
		}
	}()

	// We need to join memory cgroup after set memory limits, because
	// kmem.limit_in_bytes can only be set when the cgroup is empty.
	_, err = d.join("memory")
	if err != nil && !cgroups.IsNotFound(err) {
		return err
	}

	return nil
}
開發者ID:CtrlZvi,項目名稱:libnetwork,代碼行數:32,代碼來源:memory.go

示例2: Apply

func (s *MemoryGroup) Apply(d *cgroupData) (err error) {
	path, err := d.path("memory")
	if err != nil && !cgroups.IsNotFound(err) {
		return err
	}
	if memoryAssigned(d.config) {
		if path != "" {
			if err := os.MkdirAll(path, 0755); err != nil {
				return err
			}
		}
		// We have to set kernel memory here, as we can't change it once
		// processes have been attached.
		if err := s.SetKernelMemory(path, d.config); err != nil {
			return err
		}
	}

	defer func() {
		if err != nil {
			os.RemoveAll(path)
		}
	}()

	// We need to join memory cgroup after set memory limits, because
	// kmem.limit_in_bytes can only be set when the cgroup is empty.
	_, err = d.join("memory")
	if err != nil && !cgroups.IsNotFound(err) {
		return err
	}
	return nil
}
開發者ID:jimmidyson,項目名稱:runc,代碼行數:32,代碼來源:memory.go

示例3: Apply

func (m *Manager) Apply(pid int) (err error) {
	if m.Cgroups == nil {
		return nil
	}

	var c = m.Cgroups

	d, err := getCgroupData(m.Cgroups, pid)
	if err != nil {
		return err
	}

	if c.Paths != nil {
		paths := make(map[string]string)
		for name, path := range c.Paths {
			_, err := d.path(name)
			if err != nil {
				if cgroups.IsNotFound(err) {
					continue
				}
				return err
			}
			paths[name] = path
		}
		m.Paths = paths
		return cgroups.EnterPid(m.Paths, pid)
	}

	paths := make(map[string]string)
	defer func() {
		if err != nil {
			cgroups.RemovePaths(paths)
		}
	}()
	for _, sys := range subsystems {
		if err := sys.Apply(d); err != nil {
			return err
		}
		// TODO: Apply should, ideally, be reentrant or be broken up into a separate
		// create and join phase so that the cgroup hierarchy for a container can be
		// created then join consists of writing the process pids to cgroup.procs
		p, err := d.path(sys.Name())
		if err != nil {
			if cgroups.IsNotFound(err) {
				continue
			}
			return err
		}
		paths[sys.Name()] = p
	}
	m.Paths = paths
	return nil
}
開發者ID:CNDonny,項目名稱:scope,代碼行數:53,代碼來源:apply_raw.go

示例4: Apply

func (m *Manager) Apply(pid int) (err error) {
	if m.Cgroups == nil {
		return nil
	}

	var c = m.Cgroups

	d, err := getCgroupData(m.Cgroups, pid)
	if err != nil {
		return err
	}

	if c.Paths != nil {
		paths := make(map[string]string)
		for name, path := range c.Paths {
			_, err := d.path(name)
			if err != nil {
				if cgroups.IsNotFound(err) {
					continue
				}
				return err
			}
			paths[name] = path
		}
		m.Paths = paths
		return cgroups.EnterPid(m.Paths, pid)
	}

	m.mu.Lock()
	defer m.mu.Unlock()
	paths := make(map[string]string)
	for _, sys := range subsystems {
		if err := sys.Apply(d); err != nil {
			return err
		}
		// TODO: Apply should, ideally, be reentrant or be broken up into a separate
		// create and join phase so that the cgroup hierarchy for a container can be
		// created then join consists of writing the process pids to cgroup.procs
		p, err := d.path(sys.Name())
		if err != nil {
			// The non-presence of the devices subsystem is
			// considered fatal for security reasons.
			if cgroups.IsNotFound(err) && sys.Name() != "devices" {
				continue
			}
			return err
		}
		paths[sys.Name()] = p
	}
	m.Paths = paths
	return nil
}
開發者ID:RyanBinfeng,項目名稱:kubernetes,代碼行數:52,代碼來源:apply_raw.go

示例5: joinNetPrio

func joinNetPrio(c *configs.Cgroup, pid int) error {
	_, err := join(c, "net_prio", pid)
	if err != nil && !cgroups.IsNotFound(err) {
		return err
	}
	return nil
}
開發者ID:immarvin,項目名稱:runc,代碼行數:7,代碼來源:apply_systemd.go

示例6: Apply

func (s *FreezerGroup) Apply(d *cgroupData) error {
	_, err := d.join("freezer")
	if err != nil && !cgroups.IsNotFound(err) {
		return err
	}
	return nil
}
開發者ID:40a,項目名稱:bootkube,代碼行數:7,代碼來源:freezer.go

示例7: Set

func (m *Manager) Set(container *configs.Config) error {
	for _, sys := range subsystems {
		// We can't set this here, because after being applied, memcg doesn't
		// allow a non-empty cgroup from having its limits changed.
		if sys.Name() == "memory" {
			continue
		}

		// Generate fake cgroup data.
		d, err := getCgroupData(container.Cgroups, -1)
		if err != nil {
			return err
		}
		// Get the path, but don't error out if the cgroup wasn't found.
		path, err := d.path(sys.Name())
		if err != nil && !cgroups.IsNotFound(err) {
			return err
		}

		if err := sys.Set(path, container.Cgroups); err != nil {
			return err
		}
	}

	if m.Paths["cpu"] != "" {
		if err := CheckCpushares(m.Paths["cpu"], container.Cgroups.Resources.CpuShares); err != nil {
			return err
		}
	}
	return nil
}
開發者ID:immarvin,項目名稱:runc,代碼行數:31,代碼來源:apply_raw.go

示例8: Apply

func (s *PerfEventGroup) Apply(d *cgroupData) error {
	// we just want to join this group even though we don't set anything
	if _, err := d.join("perf_event"); err != nil && !cgroups.IsNotFound(err) {
		return err
	}
	return nil
}
開發者ID:COLDTURNIP,項目名稱:kubernetes,代碼行數:7,代碼來源:perf_event.go

示例9: Apply

func (s *MemoryGroup) Apply(d *data) error {
	path, err := d.path("memory")
	if err != nil && !cgroups.IsNotFound(err) {
		return err
	}
	if err := os.MkdirAll(path, 0755); err != nil && !os.IsExist(err) {
		return err
	}
	if err := s.Set(path, d.c); err != nil {
		return err
	}

	// We need to join memory cgroup after set memory limits, because
	// kmem.limit_in_bytes can only be set when the cgroup is empty.
	_, err = d.join("memory")
	if err != nil {
		return err
	}
	defer func() {
		if err != nil {
			os.RemoveAll(path)
		}
	}()

	return nil
}
開發者ID:jalateras,項目名稱:runc,代碼行數:26,代碼來源:memory.go

示例10: joinPerfEvent

func joinPerfEvent(c *configs.Cgroup, pid int) error {
	_, err := join(c, "perf_event", pid)
	if err != nil && !cgroups.IsNotFound(err) {
		return err
	}
	return nil
}
開發者ID:immarvin,項目名稱:runc,代碼行數:7,代碼來源:apply_systemd.go

示例11: joinHugetlb

func joinHugetlb(c *configs.Cgroup, pid int) error {
	_, err := join(c, "hugetlb", pid)
	if err != nil && !cgroups.IsNotFound(err) {
		return err
	}
	return nil
}
開發者ID:immarvin,項目名稱:runc,代碼行數:7,代碼來源:apply_systemd.go

示例12: joinPids

func joinPids(c *configs.Cgroup, pid int) error {
	_, err := join(c, "pids", pid)
	if err != nil && !cgroups.IsNotFound(err) {
		return err
	}
	return nil
}
開發者ID:immarvin,項目名稱:runc,代碼行數:7,代碼來源:apply_systemd.go

示例13: Apply

func (s *NetClsGroup) Apply(d *cgroupData) error {
	_, err := d.join("net_cls")
	if err != nil && !cgroups.IsNotFound(err) {
		return err
	}
	return nil
}
開發者ID:CodeJuan,項目名稱:kubernetes,代碼行數:7,代碼來源:net_cls.go

示例14: joinFreezer

func joinFreezer(c *configs.Cgroup, pid int) error {
	_, err := join(c, "freezer", pid)
	if err != nil && !cgroups.IsNotFound(err) {
		return err
	}
	return nil
}
開發者ID:immarvin,項目名稱:runc,代碼行數:7,代碼來源:apply_systemd.go

示例15: Apply

func (s *PidsGroup) Apply(d *cgroupData) error {
	_, err := d.join("pids")
	if err != nil && !cgroups.IsNotFound(err) {
		return err
	}
	return nil
}
開發者ID:jfrazelle,項目名稱:magneto,代碼行數:7,代碼來源:pids.go


注:本文中的github.com/opencontainers/runc/libcontainer/cgroups.IsNotFound函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。