Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate pkg/kubelet/nodestatus to structured logging #99001

Merged
merged 1 commit into from Feb 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions pkg/kubelet/nodestatus/setters.go
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down