MCPcopy
hub / github.com/google/cadvisor / GetSpec

Method GetSpec

lib/container/raw/handler.go:121–157  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

119func (h *rawContainerHandler) Cleanup() {}
120
121func (h *rawContainerHandler) GetSpec() (info.ContainerSpec, error) {
122 const hasNetwork = false
123 hasFilesystem := isRootCgroup(h.name) || len(h.externalMounts) > 0
124 spec, err := common.GetSpec(h.cgroupPaths, h.machineInfoFactory, hasNetwork, hasFilesystem)
125 if err != nil {
126 return spec, err
127 }
128
129 if isRootCgroup(h.name) {
130 // Check physical network devices for root container.
131 nd, err := h.GetRootNetworkDevices()
132 if err != nil {
133 return spec, err
134 }
135 spec.HasNetwork = spec.HasNetwork || len(nd) != 0
136
137 // Get memory and swap limits of the running machine
138 memLimit, err := machine.GetMachineMemoryCapacity()
139 if err != nil {
140 klog.Warningf("failed to obtain memory limit for machine container")
141 spec.HasMemory = false
142 } else {
143 spec.Memory.Limit = uint64(memLimit)
144 // Spec is marked to have memory only if the memory limit is set
145 spec.HasMemory = true
146 }
147
148 swapLimit, err := machine.GetMachineSwapCapacity()
149 if err != nil {
150 klog.Warningf("failed to obtain swap limit for machine container")
151 } else {
152 spec.Memory.SwapLimit = uint64(swapLimit)
153 }
154 }
155
156 return spec, nil
157}
158
159func fsToFsStats(fs *fs.Fs) info.FsStats {
160 inodes := uint64(0)

Callers

nothing calls this directly

Calls 6

GetRootNetworkDevicesMethod · 0.95
GetSpecFunction · 0.92
GetMachineMemoryCapacityFunction · 0.92
GetMachineSwapCapacityFunction · 0.92
isRootCgroupFunction · 0.85
WarningfMethod · 0.80

Tested by

no test coverage detected