Commit fffd152e authored by David Zhu's avatar David Zhu

Fixed kubelet error message to be more descriptive. Added Attach success event…

Fixed kubelet error message to be more descriptive. Added Attach success event for help in debugging.
parent 68c857e2
...@@ -59,6 +59,7 @@ const ( ...@@ -59,6 +59,7 @@ const (
FailedUnmapDevice = "FailedUnmapDevice" FailedUnmapDevice = "FailedUnmapDevice"
WarnAlreadyMountedVolume = "AlreadyMountedVolume" WarnAlreadyMountedVolume = "AlreadyMountedVolume"
SuccessfulDetachVolume = "SuccessfulDetachVolume" SuccessfulDetachVolume = "SuccessfulDetachVolume"
SuccessfulAttachVolume = "SuccessfulAttachVolume"
SuccessfulMountVolume = "SuccessfulMountVolume" SuccessfulMountVolume = "SuccessfulMountVolume"
SuccessfulUnMountVolume = "SuccessfulUnMountVolume" SuccessfulUnMountVolume = "SuccessfulUnMountVolume"
HostPortConflict = "HostPortConflict" HostPortConflict = "HostPortConflict"
......
...@@ -357,21 +357,38 @@ func (vm *volumeManager) WaitForAttachAndMount(pod *v1.Pod) error { ...@@ -357,21 +357,38 @@ func (vm *volumeManager) WaitForAttachAndMount(pod *v1.Pod) error {
// Timeout expired // Timeout expired
unmountedVolumes := unmountedVolumes :=
vm.getUnmountedVolumes(uniquePodName, expectedVolumes) vm.getUnmountedVolumes(uniquePodName, expectedVolumes)
// Also get unattached volumes for error message
unattachedVolumes :=
vm.getUnattachedVolumes(expectedVolumes)
if len(unmountedVolumes) == 0 { if len(unmountedVolumes) == 0 {
return nil return nil
} }
return fmt.Errorf( 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.Namespace,
pod.Name, pod.Name,
unmountedVolumes) unmountedVolumes,
unattachedVolumes)
} }
glog.V(3).Infof("All volumes are attached and mounted for pod %q", format.Pod(pod)) glog.V(3).Infof("All volumes are attached and mounted for pod %q", format.Pod(pod))
return nil 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 // verifyVolumesMountedFunc returns a method that returns true when all expected
// volumes are mounted. // volumes are mounted.
func (vm *volumeManager) verifyVolumesMountedFunc(podName types.UniquePodName, expectedVolumes []string) wait.ConditionFunc { func (vm *volumeManager) verifyVolumesMountedFunc(podName types.UniquePodName, expectedVolumes []string) wait.ConditionFunc {
......
...@@ -305,6 +305,11 @@ func (og *operationGenerator) GenerateAttachVolumeFunc( ...@@ -305,6 +305,11 @@ func (og *operationGenerator) GenerateAttachVolumeFunc(
return detailedErr 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", "")) glog.Infof(volumeToAttach.GenerateMsgDetailed("AttachVolume.Attach succeeded", ""))
// Update actual state of world // Update actual state of world
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment