Migrate pkg/kubelet/cm/cpumanage/{topology/topology.go, policy_none.go, cpu_assignment.go} to structured logging

This commit is contained in:
lala123912 2021-03-12 10:41:03 +08:00
parent 5ae856c36f
commit b247240ad7
3 changed files with 5 additions and 6 deletions

View File

@ -160,7 +160,7 @@ func takeByTopology(topo *topology.CPUTopology, availableCPUs cpuset.CPUSet, num
// least a socket's-worth of CPUs.
if acc.needs(acc.topo.CPUsPerSocket()) {
for _, s := range acc.freeSockets() {
klog.V(4).Infof("[cpumanager] takeByTopology: claiming socket [%d]", s)
klog.V(4).InfoS("takeByTopology: claiming socket", "socket", s)
acc.take(acc.details.CPUsInSockets(s))
if acc.isSatisfied() {
return acc.result, nil
@ -175,7 +175,7 @@ func takeByTopology(topo *topology.CPUTopology, availableCPUs cpuset.CPUSet, num
// a core's-worth of CPUs.
if acc.needs(acc.topo.CPUsPerCore()) {
for _, c := range acc.freeCores() {
klog.V(4).Infof("[cpumanager] takeByTopology: claiming core [%d]", c)
klog.V(4).InfoS("takeByTopology: claiming core", "core", c)
acc.take(acc.details.CPUsInCores(c))
if acc.isSatisfied() {
return acc.result, nil
@ -190,7 +190,7 @@ func takeByTopology(topo *topology.CPUTopology, availableCPUs cpuset.CPUSet, num
// on the same sockets as the whole cores we have already taken in this
// allocation.
for _, c := range acc.freeCPUs() {
klog.V(4).Infof("[cpumanager] takeByTopology: claiming CPU [%d]", c)
klog.V(4).InfoS("takeByTopology: claiming CPU", "cpu", c)
if acc.needs(1) {
acc.take(cpuset.NewCPUSet(c))
}

View File

@ -41,7 +41,7 @@ func (p *nonePolicy) Name() string {
}
func (p *nonePolicy) Start(s state.State) error {
klog.Info("[cpumanager] none policy: Start")
klog.InfoS("None policy: Start")
return nil
}

View File

@ -236,8 +236,7 @@ func Discover(machineInfo *cadvisorapi.MachineInfo) (*CPUTopology, error) {
}
}
} else {
klog.Errorf("could not get unique coreID for socket: %d core %d threads: %v",
core.SocketID, core.Id, core.Threads)
klog.ErrorS(nil, "Could not get unique coreID for socket", "socket", core.SocketID, "core", core.Id, "threads", core.Threads)
return nil, err
}
}