Documentation ¶
Index ¶
- Constants
- Variables
- func DoHTTPGet(methodName string, ip string, port int, timeout int) ([]byte, error)
- func DumpJSON(o interface{}) string
- func FindContainerIdAndStatusByName(status *corev1.PodStatus, name string) (string, *corev1.ContainerStatus, error)
- func FindContainerStatusByID(pod *corev1.Pod, containerID string) *corev1.ContainerStatus
- func GenerateCPUSetStr(cpuset []int32) string
- func GetCPUStatUsageTicks() (uint64, error)
- func GetContainerBaseCFSQuota(container *corev1.Container) int64
- func GetContainerCPUStatUsageTicks(podCgroupDir string, c *corev1.ContainerStatus) (uint64, error)
- func GetContainerCgroupCFSBurstPath(podParentDir string, c *corev1.ContainerStatus) (string, error)
- func GetContainerCgroupCFSPeriodPath(podParentDir string, c *corev1.ContainerStatus) (string, error)
- func GetContainerCgroupCFSQuotaPath(podParentDir string, c *corev1.ContainerStatus) (string, error)
- func GetContainerCgroupCPUAcctProcStatPath(podParentDir string, c *corev1.ContainerStatus) (string, error)
- func GetContainerCgroupCPUSharePath(podParentDir string, c *corev1.ContainerStatus) (string, error)
- func GetContainerCgroupCPUStatPath(podParentDir string, c *corev1.ContainerStatus) (string, error)
- func GetContainerCgroupMemLimitPath(podParentDir string, c *corev1.ContainerStatus) (string, error)
- func GetContainerCgroupMemStatPath(podParentDir string, c *corev1.ContainerStatus) (string, error)
- func GetContainerCgroupPathWithKube(podParentDir string, c *corev1.ContainerStatus) (string, error)
- func GetContainerCurCFSPeriod(podParentDir string, c *corev1.ContainerStatus) (int64, error)
- func GetContainerCurCFSQuota(podParentDir string, c *corev1.ContainerStatus) (int64, error)
- func GetContainerCurCPUShare(podParentDir string, c *corev1.ContainerStatus) (int64, error)
- func GetContainerCurMemLimitBytes(podParentDir string, c *corev1.ContainerStatus) (int64, error)
- func GetContainerCurTasks(podParentDir string, c *corev1.ContainerStatus) ([]int, error)
- func GetContainerCurTasksPath(podParentDir string, c *corev1.ContainerStatus) (string, error)
- func GetContainerMemStatUsageBytes(podCgroupDir string, c *corev1.ContainerStatus) (int64, error)
- func GetContainerMemoryByteLimit(c *corev1.Container) int64
- func GetContainerMilliCPULimit(c *corev1.Container) int64
- func GetKubeQosClass(pod *corev1.Pod) corev1.PodQOSClass
- func GetKubeQosRelativePath(qosClass corev1.PodQOSClass) string
- func GetMemInfoUsageKB() (int64, error)
- func GetMilliQuant(quant resource.Quantity) resource.Quantity
- func GetNodeKey(node *corev1.Node) string
- func GetNodeMetricKey(nodeMetric *slov1alpha1.NodeMetric) string
- func GetPodCPUStatUsageTicks(podCgroupDir string) (uint64, error)
- func GetPodCgroupCFSPeriodPath(podParentDir string) string
- func GetPodCgroupCFSQuotaPath(podParentDir string) string
- func GetPodCgroupCPUAcctProcStatPath(podParentDir string) string
- func GetPodCgroupCPUBvtPath(podParentDir string) string
- func GetPodCgroupCPUSetPath(podParentDir string) string
- func GetPodCgroupCPUSharePath(podParentDir string) string
- func GetPodCgroupCPUStatPath(podParentDir string) string
- func GetPodCgroupDirWithKube(podKubeRelativeDir string) string
- func GetPodCgroupMemLimitPath(podParentDir string) string
- func GetPodCgroupMemStatPath(podParentDir string) string
- func GetPodCurBvtValue(podParentDir string) (int64, error)
- func GetPodCurCFSPeriod(podParentDir string) (int64, error)
- func GetPodCurCFSQuota(podParentDir string) (int64, error)
- func GetPodCurCPUShare(podParentDir string) (int64, error)
- func GetPodCurMemLimitBytes(podParentDir string) (int64, error)
- func GetPodKey(pod *corev1.Pod) string
- func GetPodKubeRelativePath(pod *corev1.Pod) string
- func GetPodMemStatUsageBytes(podCgroupDir string) (int64, error)
- func GetPodMemoryByteLimit(pod *corev1.Pod) int64
- func GetPodMetricKey(podMetric *slov1alpha1.PodMetricInfo) string
- func GetPodMilliCPULimit(pod *corev1.Pod) int64
- func GetPodQoSRelativePath(qosClass corev1.PodQOSClass) string
- func GetPodRequest(pod *corev1.Pod) corev1.ResourceList
- func GetRootCgroupCPUSetDir(qosClass corev1.PodQOSClass) string
- func GetRootCgroupCPUStatUsageTicks(qosClass corev1.PodQOSClass) (uint64, error)
- func GetRootCgroupCurCFQuota(qosClass corev1.PodQOSClass) (int64, error)
- func GetRootCgroupCurCFSPeriod(qosClass corev1.PodQOSClass) (int64, error)
- func GetRootCgroupCurCPUSet(qosClass corev1.PodQOSClass) ([]int32, error)
- func IsResourceDiff(oldResourceList, newResourceList corev1.ResourceList, resourceName string, ...) bool
- func MaxInt64(i, j int64) int64
- func MergeCPUSet(old, new []int32) []int32
- func MergeCfg(old, new interface{}) (interface{}, error)
- func MinInt64(i, j int64) int64
- func MultiplyMilliQuant(quant resource.Quantity, factor float64) resource.Quantity
- func MultiplyQuant(quant resource.Quantity, factor float64) resource.Quantity
- func NewZeroResourceList() corev1.ResourceList
- func ParseCPUSetStr(cpusetStr string) ([]int32, error)
- func ParseContainerID(basename string) (string, error)
- func ParseContainerId(data string) (cType, cID string, err error)
- func ParsePodID(basename string) (string, error)
- func RunFeature(moduleFunc func(), featureDependency []featuregate.Feature, interval int, ...) bool
- func RunFeatureWithInit(moduleInit func() error, moduleFunc func(), ...) (bool, error)
- func WriteCgroupCPUSet(cgroupFileDir, cpusetStr string) error
- type CPUBasicInfo
- type CPUTotalInfo
- type LocalCPUInfo
- type MemInfo
- type ProcessorInfo
Constants ¶
const ( Docker = "docker" Containerd = "containerd" )
const (
ProcMemInfoPath = "/proc/meminfo"
)
Variables ¶
var (
CpuacctUsageTypeStat = sets.NewString("user", "nice", "system", "irq", "softirq")
)
Functions ¶
func FindContainerStatusByID ¶
func FindContainerStatusByID(pod *corev1.Pod, containerID string) *corev1.ContainerStatus
func GenerateCPUSetStr ¶
GenerateCPUSetStr generates the cpuset string from the cpuset slice eg. [3,2,1,0] => "3,2,1,0"
func GetCPUStatUsageTicks ¶
GetCPUStatUsageTicks returns the node's CPU usage ticks
func GetContainerCPUStatUsageTicks ¶
func GetContainerCPUStatUsageTicks(podCgroupDir string, c *corev1.ContainerStatus) (uint64, error)
func GetContainerCgroupCFSBurstPath ¶
func GetContainerCgroupCFSBurstPath(podParentDir string, c *corev1.ContainerStatus) (string, error)
func GetContainerCgroupCFSPeriodPath ¶
func GetContainerCgroupCFSPeriodPath(podParentDir string, c *corev1.ContainerStatus) (string, error)
func GetContainerCgroupCFSQuotaPath ¶
func GetContainerCgroupCFSQuotaPath(podParentDir string, c *corev1.ContainerStatus) (string, error)
func GetContainerCgroupCPUAcctProcStatPath ¶
func GetContainerCgroupCPUAcctProcStatPath(podParentDir string, c *corev1.ContainerStatus) (string, error)
func GetContainerCgroupCPUSharePath ¶
func GetContainerCgroupCPUSharePath(podParentDir string, c *corev1.ContainerStatus) (string, error)
func GetContainerCgroupCPUStatPath ¶
func GetContainerCgroupCPUStatPath(podParentDir string, c *corev1.ContainerStatus) (string, error)
func GetContainerCgroupMemLimitPath ¶
func GetContainerCgroupMemLimitPath(podParentDir string, c *corev1.ContainerStatus) (string, error)
func GetContainerCgroupMemStatPath ¶
func GetContainerCgroupMemStatPath(podParentDir string, c *corev1.ContainerStatus) (string, error)
func GetContainerCgroupPathWithKube ¶
func GetContainerCgroupPathWithKube(podParentDir string, c *corev1.ContainerStatus) (string, error)
@parentDir kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/ @return kubepods.slice/kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/****.scope
func GetContainerCurCFSPeriod ¶
func GetContainerCurCFSPeriod(podParentDir string, c *corev1.ContainerStatus) (int64, error)
func GetContainerCurCFSQuota ¶
func GetContainerCurCFSQuota(podParentDir string, c *corev1.ContainerStatus) (int64, error)
func GetContainerCurCPUShare ¶
func GetContainerCurCPUShare(podParentDir string, c *corev1.ContainerStatus) (int64, error)
func GetContainerCurMemLimitBytes ¶
func GetContainerCurMemLimitBytes(podParentDir string, c *corev1.ContainerStatus) (int64, error)
func GetContainerCurTasks ¶
func GetContainerCurTasks(podParentDir string, c *corev1.ContainerStatus) ([]int, error)
func GetContainerCurTasksPath ¶
func GetContainerCurTasksPath(podParentDir string, c *corev1.ContainerStatus) (string, error)
func GetContainerMemStatUsageBytes ¶
func GetContainerMemStatUsageBytes(podCgroupDir string, c *corev1.ContainerStatus) (int64, error)
func GetKubeQosClass ¶
func GetKubeQosClass(pod *corev1.Pod) corev1.PodQOSClass
func GetKubeQosRelativePath ¶
func GetKubeQosRelativePath(qosClass corev1.PodQOSClass) string
@output like kubepods.slice/kubepods-besteffort.slice/
func GetMemInfoUsageKB ¶
GetMemInfoUsageKB returns the node's memory usage quantity (kB)
func GetMilliQuant ¶
GetMilliQuant returns the milli-valued quantity
func GetNodeKey ¶
GetNodeKey returns a generated key with given node
func GetNodeMetricKey ¶
func GetNodeMetricKey(nodeMetric *slov1alpha1.NodeMetric) string
GetNodeMetricKey returns a generated key with given nodeMetric
func GetPodCPUStatUsageTicks ¶
GetPodCPUStatUsageTicks returns the pod's CPU usage ticks
func GetPodCgroupCFSPeriodPath ¶
@podParentDir kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/ @output /sys/fs/cgroup/cpu/kubepods.slice/kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/cpu.cfs_period_us
func GetPodCgroupCFSQuotaPath ¶
@podParentDir kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/ @output /sys/fs/cgroup/cpu/kubepods.slice/kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/cpu.cfs_quota_us
func GetPodCgroupCPUAcctProcStatPath ¶
@podParentDir kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/ @output /sys/fs/cgroup/cpuacct/kubepods.slice/kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/cpuacct.proc_stat
func GetPodCgroupCPUBvtPath ¶
@podParentDir kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/ @output /sys/fs/cgroup/cpu/kubepods.slice/kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/cpu.bvt_warp_ns
func GetPodCgroupCPUSetPath ¶
@podParentDir kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/ @output /sys/fs/cgroup/cpuset/kubepods.slice/kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/cpuset.cpus
func GetPodCgroupCPUSharePath ¶
@podParentDir kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/ @output /sys/fs/cgroup/cpu/kubepods.slice/kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/cpu.shares
func GetPodCgroupCPUStatPath ¶
@podParentDir kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/ @output /sys/fs/cgroup/cpu/kubepods.slice/kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/cpu.stat
func GetPodCgroupDirWithKube ¶
@kubeRelativeDir kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/ @return kubepods.slice/kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/
func GetPodCgroupMemLimitPath ¶
@podParentDir kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/ @output /sys/fs/cgroup/memory/kubepods.slice/kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/memory.limit_in_bytes
func GetPodCgroupMemStatPath ¶
@podParentDir kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/ @output /sys/fs/cgroup/cpuacct/kubepods.slice/kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/cpuacct.proc_stat
func GetPodCurBvtValue ¶
func GetPodCurCFSPeriod ¶
func GetPodCurCFSQuota ¶
func GetPodCurCPUShare ¶
func GetPodCurMemLimitBytes ¶
func GetPodKubeRelativePath ¶
@return like kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/
func GetPodMemStatUsageBytes ¶
GetPodMemStatUsageBytes returns the pod's memory usage quantity (Byte)
func GetPodMemoryByteLimit ¶
func GetPodMetricKey ¶
func GetPodMetricKey(podMetric *slov1alpha1.PodMetricInfo) string
func GetPodMilliCPULimit ¶
func GetPodQoSRelativePath ¶
func GetPodQoSRelativePath(qosClass corev1.PodQOSClass) string
@return like kubepods.slice/kubepods-burstable.slice/
func GetPodRequest ¶
func GetPodRequest(pod *corev1.Pod) corev1.ResourceList
GetPodRequest get pod request resource
func GetRootCgroupCPUSetDir ¶
func GetRootCgroupCPUSetDir(qosClass corev1.PodQOSClass) string
GetRootCgroupCPUSetDir gets the cpuset parent directory of the specified podQos' root cgroup @output /sys/fs/cgroup/cpuset/kubepods.slice/kubepods-besteffort.slice
func GetRootCgroupCPUStatUsageTicks ¶
func GetRootCgroupCPUStatUsageTicks(qosClass corev1.PodQOSClass) (uint64, error)
func GetRootCgroupCurCFQuota ¶
func GetRootCgroupCurCFQuota(qosClass corev1.PodQOSClass) (int64, error)
func GetRootCgroupCurCFSPeriod ¶
func GetRootCgroupCurCFSPeriod(qosClass corev1.PodQOSClass) (int64, error)
func GetRootCgroupCurCPUSet ¶
func GetRootCgroupCurCPUSet(qosClass corev1.PodQOSClass) ([]int32, error)
GetRootCgroupCurCPUSet gets the current cpuset of the specified podQos' root cgroup
func IsResourceDiff ¶
func IsResourceDiff(oldResourceList, newResourceList corev1.ResourceList, resourceName string, diffThreshold float64) bool
IsResourceDiff returns whether the new resource has big enough difference with the old one or not
func MergeCPUSet ¶
MergeCPUSet merges the old cpuset with the new one, and also deduplicate and keeps a desc order by processor ids e.g. [1,0], [3,2,2,1] => [3,2,1,0]
func MergeCfg ¶
func MergeCfg(old, new interface{}) (interface{}, error)
MergeCfg merges the old cfg with the new one, where new's values take precedence over old's when both fields exist. It would throw an error if:
- either of the inputs was nil;
- the inputs were not a pointer of the same json struct.
func MultiplyMilliQuant ¶
MultiplyMilliQuant scales quantity by factor
func MultiplyQuant ¶
MultiplyQuant scales quantity by factor
func NewZeroResourceList ¶
func NewZeroResourceList() corev1.ResourceList
func ParseCPUSetStr ¶
ParseCPUSetStr parses cpuset string into a slice eg. "0-5,34,46-48" => [0,1,2,3,4,5,34,46,47,48]
func ParseContainerID ¶
@return 7712555c_ce62_454a_9e18_9ff0217b8941 from docker-7712555c_ce62_454a_9e18_9ff0217b8941.scope
func ParseContainerId ¶
func ParsePodID ¶
@return 7712555c_ce62_454a_9e18_9ff0217b8941 from kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice
func RunFeature ¶
func RunFeature(moduleFunc func(), featureDependency []featuregate.Feature, interval int, stopCh <-chan struct{}) bool
RunFeature runs moduleFunc only if interval > 0 AND at least one feature dependency is enabled
func RunFeatureWithInit ¶
func RunFeatureWithInit(moduleInit func() error, moduleFunc func(), featureDependency []featuregate.Feature, interval int, stopCh <-chan struct{}) (bool, error)
RunFeatureWithInit runs moduleFunc only if interval > 0 , at least one feature dependency is enabled and moduleInit function returns nil
func WriteCgroupCPUSet ¶
WriteCgroupCPUSet writes the cgroup cpuset file according to the specified cgroup dir
Types ¶
type CPUBasicInfo ¶
type CPUBasicInfo struct { HyperThreadEnabled bool `json:"hyperThreadEnabled,omitempty"` CatL3CbmMask string `json:"catL3CbmMask,omitempty"` }
CPUBasicInfo describes the cpu basic features and status
type CPUTotalInfo ¶
type CPUTotalInfo struct { NumberCPUs int32 `json:"numberCPUs"` NumberCores int32 `json:"numberCores"` NumberSockets int32 `json:"numberSockets"` NumberNodes int32 `json:"numberNodes"` NumberL3s int32 `json:"numberL3s"` }
CPUTotalInfo describes the total number infos of the local cpu, e.g. the number of cores, the number of numa nodes
type LocalCPUInfo ¶
type LocalCPUInfo struct { // BasicInfo describe the cpu features and their status BasicInfo CPUBasicInfo `json:"basicInfo,omitempty"` // ProcessorInfos contains topology information of all available CPUs ProcessorInfos []ProcessorInfo `json:"processorInfos,omitempty"` // TotalInfo stores the numbers of cpu processors, cores, sockets and nodes TotalInfo CPUTotalInfo `json:"totalInfo,omitempty"` }
LocalCPUInfo contains the cpu information collected from the node
func GetLocalCPUInfo ¶
func GetLocalCPUInfo() (*LocalCPUInfo, error)
GetLocalCPUInfo returns the local cpu info for cpuset allocation, NUMA-aware scheduling
type MemInfo ¶
type MemInfo struct { MemTotal uint64 `json:"mem_total"` MemFree uint64 `json:"mem_free"` MemAvailable uint64 `json:"mem_available"` Buffers uint64 `json:"buffers"` Cached uint64 `json:"cached"` SwapCached uint64 `json:"swap_cached"` Active uint64 `json:"active"` Inactive uint64 `json:"inactive"` ActiveAnon uint64 `json:"active_anon" field:"Active(anon)"` InactiveAnon uint64 `json:"inactive_anon" field:"Inactive(anon)"` ActiveFile uint64 `json:"active_file" field:"Active(file)"` InactiveFile uint64 `json:"inactive_file" field:"Inactive(file)"` Unevictable uint64 `json:"unevictable"` Mlocked uint64 `json:"mlocked"` SwapTotal uint64 `json:"swap_total"` SwapFree uint64 `json:"swap_free"` Dirty uint64 `json:"dirty"` Writeback uint64 `json:"write_back"` AnonPages uint64 `json:"anon_pages"` Mapped uint64 `json:"mapped"` Shmem uint64 `json:"shmem"` Slab uint64 `json:"slab"` SReclaimable uint64 `json:"s_reclaimable"` SUnreclaim uint64 `json:"s_unclaim"` KernelStack uint64 `json:"kernel_stack"` PageTables uint64 `json:"page_tables"` NFS_Unstable uint64 `json:"nfs_unstable"` Bounce uint64 `json:"bounce"` WritebackTmp uint64 `json:"writeback_tmp"` CommitLimit uint64 `json:"commit_limit"` Committed_AS uint64 `json:"committed_as"` VmallocTotal uint64 `json:"vmalloc_total"` VmallocUsed uint64 `json:"vmalloc_used"` VmallocChunk uint64 `json:"vmalloc_chunk"` HardwareCorrupted uint64 `json:"hardware_corrupted"` AnonHugePages uint64 `json:"anon_huge_pages"` HugePages_Total uint64 `json:"huge_pages_total"` HugePages_Free uint64 `json:"huge_pages_free"` HugePages_Rsvd uint64 `json:"huge_pages_rsvd"` HugePages_Surp uint64 `json:"huge_pages_surp"` Hugepagesize uint64 `json:"hugepagesize"` DirectMap4k uint64 `json:"direct_map_4k"` DirectMap2M uint64 `json:"direct_map_2M"` DirectMap1G uint64 `json:"direct_map_1G"` }
type ProcessorInfo ¶
type ProcessorInfo struct { // logic CPU/ processor ID CPUID int32 `json:"cpu"` // physical CPU core ID CoreID int32 `json:"core"` // cpu socket ID SocketID int32 `json:"socket"` // numa node ID NodeID int32 `json:"node"` // L1 L2 cache ID L1dl1il2 string `json:"l1dl1il2"` // L3 cache ID L3 int32 `json:"l3"` // online Online string `json:"online"` }
ProcessorInfo describes the processor topology information of a single logic cpu, including the core, socket and numa node it belongs to