mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Fixed kubelet error message to be more descriptive. Added Attach success event for help in debugging.
This commit is contained in:
parent
68c857e207
commit
fffd152e0d
@ -59,6 +59,7 @@ const (
|
||||
FailedUnmapDevice = "FailedUnmapDevice"
|
||||
WarnAlreadyMountedVolume = "AlreadyMountedVolume"
|
||||
SuccessfulDetachVolume = "SuccessfulDetachVolume"
|
||||
SuccessfulAttachVolume = "SuccessfulAttachVolume"
|
||||
SuccessfulMountVolume = "SuccessfulMountVolume"
|
||||
SuccessfulUnMountVolume = "SuccessfulUnMountVolume"
|
||||
HostPortConflict = "HostPortConflict"
|
||||
|
@ -357,21 +357,38 @@ func (vm *volumeManager) WaitForAttachAndMount(pod *v1.Pod) error {
|
||||
// Timeout expired
|
||||
unmountedVolumes :=
|
||||
vm.getUnmountedVolumes(uniquePodName, expectedVolumes)
|
||||
// Also get unattached volumes for error message
|
||||
unattachedVolumes :=
|
||||
vm.getUnattachedVolumes(expectedVolumes)
|
||||
|
||||
if len(unmountedVolumes) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf(
|
||||
"timeout expired waiting for volumes to attach/mount for pod %q/%q. list of unattached/unmounted volumes=%v",
|
||||
"timeout expired waiting for volumes to attach or mount for pod %q/%q. list of unmounted volumes=%v. list of unattached volumes=%v",
|
||||
pod.Namespace,
|
||||
pod.Name,
|
||||
unmountedVolumes)
|
||||
unmountedVolumes,
|
||||
unattachedVolumes)
|
||||
}
|
||||
|
||||
glog.V(3).Infof("All volumes are attached and mounted for pod %q", format.Pod(pod))
|
||||
return nil
|
||||
}
|
||||
|
||||
// getUnattachedVolumes returns a list of the volumes that are expected to be attached but
|
||||
// are not currently attached to the node
|
||||
func (vm *volumeManager) getUnattachedVolumes(expectedVolumes []string) []string {
|
||||
unattachedVolumes := []string{}
|
||||
for _, volume := range expectedVolumes {
|
||||
if !vm.actualStateOfWorld.VolumeExists(v1.UniqueVolumeName(volume)) {
|
||||
unattachedVolumes = append(unattachedVolumes, volume)
|
||||
}
|
||||
}
|
||||
return unattachedVolumes
|
||||
}
|
||||
|
||||
// verifyVolumesMountedFunc returns a method that returns true when all expected
|
||||
// volumes are mounted.
|
||||
func (vm *volumeManager) verifyVolumesMountedFunc(podName types.UniquePodName, expectedVolumes []string) wait.ConditionFunc {
|
||||
|
@ -305,6 +305,11 @@ func (og *operationGenerator) GenerateAttachVolumeFunc(
|
||||
return detailedErr
|
||||
}
|
||||
|
||||
// Successful attach event is useful for user debugging
|
||||
simpleMsg, _ := volumeToAttach.GenerateMsg("AttachVolume.Attach succeeded", "")
|
||||
for _, pod := range volumeToAttach.ScheduledPods {
|
||||
og.recorder.Eventf(pod, v1.EventTypeNormal, kevents.SuccessfulAttachVolume, simpleMsg)
|
||||
}
|
||||
glog.Infof(volumeToAttach.GenerateMsgDetailed("AttachVolume.Attach succeeded", ""))
|
||||
|
||||
// Update actual state of world
|
||||
|
Loading…
Reference in New Issue
Block a user