Skip to content

Commit 61b6233

Browse files
authored
Merge pull request kubernetes#104148 from markusthoemmes/structured-logging-2
Add the pod field to all volumeToMount info level logs
2 parents e96652e + ff0e1f4 commit 61b6233

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

pkg/volume/util/operationexecutor/operation_generator.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
584584
devicePath := volumeToMount.DevicePath
585585
if volumeAttacher != nil {
586586
// Wait for attachable volumes to finish attaching
587-
klog.Infof(volumeToMount.GenerateMsgDetailed("MountVolume.WaitForAttach entering", fmt.Sprintf("DevicePath %q", volumeToMount.DevicePath)))
587+
klog.InfoS(volumeToMount.GenerateMsgDetailed("MountVolume.WaitForAttach entering", fmt.Sprintf("DevicePath %q", volumeToMount.DevicePath)), "pod", klog.KObj(volumeToMount.Pod))
588588

589589
devicePath, err = volumeAttacher.WaitForAttach(
590590
volumeToMount.VolumeSpec, devicePath, volumeToMount.Pod, waitForAttachTimeout)
@@ -594,7 +594,7 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
594594
return volumetypes.NewOperationContext(eventErr, detailedErr, migrated)
595595
}
596596

597-
klog.Infof(volumeToMount.GenerateMsgDetailed("MountVolume.WaitForAttach succeeded", fmt.Sprintf("DevicePath %q", devicePath)))
597+
klog.InfoS(volumeToMount.GenerateMsgDetailed("MountVolume.WaitForAttach succeeded", fmt.Sprintf("DevicePath %q", devicePath)), "pod", klog.KObj(volumeToMount.Pod))
598598
}
599599

600600
var resizeDone bool
@@ -627,7 +627,7 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
627627
return volumetypes.NewOperationContext(eventErr, detailedErr, migrated)
628628
}
629629

630-
klog.Infof(volumeToMount.GenerateMsgDetailed("MountVolume.MountDevice succeeded", fmt.Sprintf("device mount path %q", deviceMountPath)))
630+
klog.InfoS(volumeToMount.GenerateMsgDetailed("MountVolume.MountDevice succeeded", fmt.Sprintf("device mount path %q", deviceMountPath)), "pod", klog.KObj(volumeToMount.Pod))
631631

632632
// Update actual state of world to reflect volume is globally mounted
633633
markDeviceMountedErr := actualStateOfWorld.MarkDeviceAsMounted(
@@ -659,9 +659,9 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
659659
volumeToMount.VolumeName, devicePath, deviceMountPath)
660660
if markDeviceUncertainErr != nil {
661661
// just log, return the resizeError error instead
662-
klog.Infof(volumeToMount.GenerateMsgDetailed(
662+
klog.InfoS(volumeToMount.GenerateMsgDetailed(
663663
"MountVolume.MountDevice failed to mark volume as uncertain",
664-
markDeviceUncertainErr.Error()))
664+
markDeviceUncertainErr.Error()), "pod", klog.KObj(volumeToMount.Pod))
665665
}
666666
eventErr, detailedErr := volumeToMount.GenerateError("MountVolume.MountDevice failed while expanding volume", resizeError)
667667
return volumetypes.NewOperationContext(eventErr, detailedErr, migrated)
@@ -704,12 +704,12 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
704704
return volumetypes.NewOperationContext(eventErr, detailedErr, migrated)
705705
}
706706

707-
_, detailedMsg := volumeToMount.GenerateMsg("MountVolume.SetUp succeeded", "")
707+
detailedMsg := volumeToMount.GenerateMsgDetailed("MountVolume.SetUp succeeded", "")
708708
verbosity := klog.Level(1)
709709
if isRemount {
710710
verbosity = klog.Level(4)
711711
}
712-
klog.V(verbosity).Infof(detailedMsg)
712+
klog.V(verbosity).InfoS(detailedMsg, "pod", klog.KObj(volumeToMount.Pod))
713713
resizeOptions.DeviceMountPath = volumeMounter.GetPath()
714714
resizeOptions.CSIVolumePhase = volume.CSIVolumePublished
715715

@@ -1070,7 +1070,7 @@ func (og *operationGenerator) GenerateMapVolumeFunc(
10701070
}
10711071
if volumeAttacher != nil {
10721072
// Wait for attachable volumes to finish attaching
1073-
klog.Infof(volumeToMount.GenerateMsgDetailed("MapVolume.WaitForAttach entering", fmt.Sprintf("DevicePath %q", volumeToMount.DevicePath)))
1073+
klog.InfoS(volumeToMount.GenerateMsgDetailed("MapVolume.WaitForAttach entering", fmt.Sprintf("DevicePath %q", volumeToMount.DevicePath)), "pod", klog.KObj(volumeToMount.Pod))
10741074

10751075
devicePath, err = volumeAttacher.WaitForAttach(
10761076
volumeToMount.VolumeSpec, volumeToMount.DevicePath, volumeToMount.Pod, waitForAttachTimeout)
@@ -1080,7 +1080,7 @@ func (og *operationGenerator) GenerateMapVolumeFunc(
10801080
return volumetypes.NewOperationContext(eventErr, detailedErr, migrated)
10811081
}
10821082

1083-
klog.Infof(volumeToMount.GenerateMsgDetailed("MapVolume.WaitForAttach succeeded", fmt.Sprintf("DevicePath %q", devicePath)))
1083+
klog.InfoS(volumeToMount.GenerateMsgDetailed("MapVolume.WaitForAttach succeeded", fmt.Sprintf("DevicePath %q", devicePath)), "pod", klog.KObj(volumeToMount.Pod))
10841084

10851085
}
10861086
// Call SetUpDevice if blockVolumeMapper implements CustomBlockVolumeMapper
@@ -1188,13 +1188,13 @@ func (og *operationGenerator) GenerateMapVolumeFunc(
11881188
simpleMsg, detailedMsg := volumeToMount.GenerateMsg("MapVolume.MapPodDevice succeeded", fmt.Sprintf("globalMapPath %q", globalMapPath))
11891189
verbosity := klog.Level(4)
11901190
og.recorder.Eventf(volumeToMount.Pod, v1.EventTypeNormal, kevents.SuccessfulMountVolume, simpleMsg)
1191-
klog.V(verbosity).Infof(detailedMsg)
1191+
klog.V(verbosity).InfoS(detailedMsg, "pod", klog.KObj(volumeToMount.Pod))
11921192

11931193
// Device mapping for pod device map path succeeded
11941194
simpleMsg, detailedMsg = volumeToMount.GenerateMsg("MapVolume.MapPodDevice succeeded", fmt.Sprintf("volumeMapPath %q", volumeMapPath))
11951195
verbosity = klog.Level(1)
11961196
og.recorder.Eventf(volumeToMount.Pod, v1.EventTypeNormal, kevents.SuccessfulMountVolume, simpleMsg)
1197-
klog.V(verbosity).Infof(detailedMsg)
1197+
klog.V(verbosity).InfoS(detailedMsg, "pod", klog.KObj(volumeToMount.Pod))
11981198

11991199
resizeOptions := volume.NodeResizeOptions{
12001200
DevicePath: devicePath,
@@ -1520,7 +1520,7 @@ func (og *operationGenerator) GenerateVerifyControllerAttachedVolumeFunc(
15201520
if attachedVolume.Name == volumeToMount.VolumeName {
15211521
addVolumeNodeErr := actualStateOfWorld.MarkVolumeAsAttached(
15221522
v1.UniqueVolumeName(""), volumeToMount.VolumeSpec, nodeName, attachedVolume.DevicePath)
1523-
klog.Infof(volumeToMount.GenerateMsgDetailed("Controller attach succeeded", fmt.Sprintf("device path: %q", attachedVolume.DevicePath)))
1523+
klog.InfoS(volumeToMount.GenerateMsgDetailed("Controller attach succeeded", fmt.Sprintf("device path: %q", attachedVolume.DevicePath)), "pod", klog.KObj(volumeToMount.Pod))
15241524
if addVolumeNodeErr != nil {
15251525
// On failure, return error. Caller will log and retry.
15261526
eventErr, detailedErr := volumeToMount.GenerateError("VerifyControllerAttachedVolume.MarkVolumeAsAttached failed", addVolumeNodeErr)
@@ -1835,7 +1835,7 @@ func (og *operationGenerator) nodeExpandVolume(
18351835
pvSpecCap := pv.Spec.Capacity[v1.ResourceStorage]
18361836
if pvcStatusCap.Cmp(pvSpecCap) < 0 {
18371837
// File system resize was requested, proceed
1838-
klog.V(4).Infof(volumeToMount.GenerateMsgDetailed("MountVolume.NodeExpandVolume entering", fmt.Sprintf("DevicePath %q", volumeToMount.DevicePath)))
1838+
klog.V(4).InfoS(volumeToMount.GenerateMsgDetailed("MountVolume.NodeExpandVolume entering", fmt.Sprintf("DevicePath %q", volumeToMount.DevicePath)), "pod", klog.KObj(volumeToMount.Pod))
18391839

18401840
if volumeToMount.VolumeSpec.ReadOnly {
18411841
simpleMsg, detailedMsg := volumeToMount.GenerateMsg("MountVolume.NodeExpandVolume failed", "requested read-only file system")
@@ -1868,7 +1868,7 @@ func (og *operationGenerator) nodeExpandVolume(
18681868
simpleMsg, detailedMsg := volumeToMount.GenerateMsg("MountVolume.NodeExpandVolume succeeded", "")
18691869
og.recorder.Eventf(volumeToMount.Pod, v1.EventTypeNormal, kevents.FileSystemResizeSuccess, simpleMsg)
18701870
og.recorder.Eventf(pvc, v1.EventTypeNormal, kevents.FileSystemResizeSuccess, simpleMsg)
1871-
klog.Infof(detailedMsg)
1871+
klog.InfoS(detailedMsg, "pod", klog.KObj(volumeToMount.Pod))
18721872
// File system resize succeeded, now update the PVC's Capacity to match the PV's
18731873
err = util.MarkFSResizeFinished(pvc, pvSpecCap, og.kubeClient)
18741874
if err != nil {

0 commit comments

Comments
 (0)