mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
Migrate pkg/kubelet/nodestatus to structured logging
Migrate pkg/kubelet/nodestatus to structured logging Signed-off-by: Qi Wang <qiwan@redhat.com>
This commit is contained in:
parent
a2d5c58c76
commit
e84af0ac13
@ -83,13 +83,13 @@ func NodeAddress(nodeIPs []net.IP, // typically Kubelet.nodeIPs
|
||||
if err := validateNodeIPFunc(nodeIP); err != nil {
|
||||
return fmt.Errorf("failed to validate nodeIP: %v", err)
|
||||
}
|
||||
klog.V(4).Infof("Using node IP: %q", nodeIP.String())
|
||||
klog.V(4).InfoS("Using node IP", "IP", nodeIP.String())
|
||||
}
|
||||
if secondaryNodeIPSpecified {
|
||||
if err := validateNodeIPFunc(secondaryNodeIP); err != nil {
|
||||
return fmt.Errorf("failed to validate secondaryNodeIP: %v", err)
|
||||
}
|
||||
klog.V(4).Infof("Using secondary node IP: %q", secondaryNodeIP.String())
|
||||
klog.V(4).InfoS("Using secondary node IP", "IP", secondaryNodeIP.String())
|
||||
}
|
||||
|
||||
if externalCloudProvider {
|
||||
@ -191,11 +191,11 @@ func NodeAddress(nodeIPs []net.IP, // typically Kubelet.nodeIPs
|
||||
|
||||
if existingHostnameAddress == nil {
|
||||
// no existing Hostname address found, add it
|
||||
klog.Warningf("adding overridden hostname of %v to cloudprovider-reported addresses", hostname)
|
||||
klog.InfoS("adding overridden hostname to cloudprovider-reported addresses", "hostname", hostname)
|
||||
nodeAddresses = append(nodeAddresses, v1.NodeAddress{Type: v1.NodeHostName, Address: hostname})
|
||||
} else if existingHostnameAddress.Address != hostname {
|
||||
// override the Hostname address reported by the cloud provider
|
||||
klog.Warningf("replacing cloudprovider-reported hostname of %v with overridden hostname of %v", existingHostnameAddress.Address, hostname)
|
||||
klog.InfoS("replacing cloudprovider-reported hostname with overridden hostname", "cloudproviderHostname", existingHostnameAddress.Address, "overrideHostname", hostname)
|
||||
existingHostnameAddress.Address = hostname
|
||||
}
|
||||
}
|
||||
@ -300,7 +300,7 @@ func MachineInfo(nodeName string,
|
||||
node.Status.Capacity[v1.ResourceCPU] = *resource.NewMilliQuantity(0, resource.DecimalSI)
|
||||
node.Status.Capacity[v1.ResourceMemory] = resource.MustParse("0Gi")
|
||||
node.Status.Capacity[v1.ResourcePods] = *resource.NewQuantity(int64(maxPods), resource.DecimalSI)
|
||||
klog.Errorf("Error getting machine info: %v", err)
|
||||
klog.ErrorS(err, "Error getting machine info")
|
||||
} else {
|
||||
node.Status.NodeInfo.MachineID = info.MachineID
|
||||
node.Status.NodeInfo.SystemUUID = info.SystemUUID
|
||||
@ -340,13 +340,13 @@ func MachineInfo(nodeName string,
|
||||
devicePluginCapacity, devicePluginAllocatable, removedDevicePlugins = devicePluginResourceCapacityFunc()
|
||||
for k, v := range devicePluginCapacity {
|
||||
if old, ok := node.Status.Capacity[k]; !ok || old.Value() != v.Value() {
|
||||
klog.V(2).Infof("Update capacity for %s to %d", k, v.Value())
|
||||
klog.V(2).InfoS("Updated capacity for device plugin", "plugin", k, "capacity", v.Value())
|
||||
}
|
||||
node.Status.Capacity[k] = v
|
||||
}
|
||||
|
||||
for _, removedResource := range removedDevicePlugins {
|
||||
klog.V(2).Infof("Set capacity for %s to 0 on device removal", removedResource)
|
||||
klog.V(2).InfoS("Set capacity for removed resource to 0 on device removal", "device", removedResource)
|
||||
// Set the capacity of the removed resource to 0 instead of
|
||||
// removing the resource from the node status. This is to indicate
|
||||
// that the resource is managed by device plugin and had been
|
||||
@ -386,7 +386,7 @@ func MachineInfo(nodeName string,
|
||||
|
||||
for k, v := range devicePluginAllocatable {
|
||||
if old, ok := node.Status.Allocatable[k]; !ok || old.Value() != v.Value() {
|
||||
klog.V(2).Infof("Update allocatable for %s to %d", k, v.Value())
|
||||
klog.V(2).InfoS("Updated allocatable", "device", k, "allocatable", v.Value())
|
||||
}
|
||||
node.Status.Allocatable[k] = v
|
||||
}
|
||||
@ -574,7 +574,7 @@ func ReadyCondition(
|
||||
recordEventFunc(v1.EventTypeNormal, events.NodeReady)
|
||||
} else {
|
||||
recordEventFunc(v1.EventTypeNormal, events.NodeNotReady)
|
||||
klog.Infof("Node became not ready: %+v", newNodeReadyCondition)
|
||||
klog.InfoS("Node became not ready", "node", klog.KObj(node), "condition", newNodeReadyCondition)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@ -792,7 +792,7 @@ func VolumeLimits(volumePluginListFunc func() []volume.VolumePluginWithAttachLim
|
||||
for _, volumePlugin := range pluginWithLimits {
|
||||
attachLimits, err := volumePlugin.GetVolumeLimits()
|
||||
if err != nil {
|
||||
klog.V(4).Infof("Error getting volume limit for plugin %s", volumePlugin.GetPluginName())
|
||||
klog.V(4).InfoS("Error getting volume limit for plugin", "plugin", volumePlugin.GetPluginName())
|
||||
continue
|
||||
}
|
||||
for limitKey, value := range attachLimits {
|
||||
|
Loading…
Reference in New Issue
Block a user