From a51eb1e70f3647fb5e3126a50a3458fcf486af16 Mon Sep 17 00:00:00 2001
From: haircommander <pehunt@redhat.com>
Date: Wed, 15 Aug 2018 11:32:23 -0400
Subject: Added reason to PodContainerError

Signed-off-by: haircommander <pehunt@redhat.com>

Closes: #1275
Approved by: mheon
---
 cmd/podman/shared/.pod.go.swp        | Bin 12288 -> 0 bytes
 cmd/podman/varlink/io.podman.varlink |   7 +++++-
 pkg/varlinkapi/pods.go               |  42 ++++++++++++++++++++---------------
 3 files changed, 30 insertions(+), 19 deletions(-)
 delete mode 100644 cmd/podman/shared/.pod.go.swp

diff --git a/cmd/podman/shared/.pod.go.swp b/cmd/podman/shared/.pod.go.swp
deleted file mode 100644
index a8565e752..000000000
Binary files a/cmd/podman/shared/.pod.go.swp and /dev/null differ
diff --git a/cmd/podman/varlink/io.podman.varlink b/cmd/podman/varlink/io.podman.varlink
index 0e6f0f054..abbaf1b07 100644
--- a/cmd/podman/varlink/io.podman.varlink
+++ b/cmd/podman/varlink/io.podman.varlink
@@ -346,6 +346,11 @@ type ListPodData (
     containersinfo: []ListPodContainerInfo
 )
 
+type PodContainerErrorData (
+    containerid: string,
+    reason: string
+)
+
 # Ping provides a response for developers to ensure their varlink setup is working.
 # #### Example
 # ~~~
@@ -758,7 +763,7 @@ error PodNotFound (name: string)
 
 # PodContainerError means a container associated with a pod failed to preform an operation. It contains
 # a container ID of the container that failed.
-error PodContainerError (podname: string, ctrnames: []string)
+error PodContainerError (podname: string, errors: []PodContainerErrorData)
 
 # ErrorOccurred is a generic error for an error that occurs during the execution.  The actual error message
 # is includes as part of the error's text.
diff --git a/pkg/varlinkapi/pods.go b/pkg/varlinkapi/pods.go
index 98a622d8a..be5e3614c 100644
--- a/pkg/varlinkapi/pods.go
+++ b/pkg/varlinkapi/pods.go
@@ -95,9 +95,10 @@ func (i *LibpodAPI) StartPod(call iopodman.VarlinkCall, name string) error {
 		return call.ReplyErrorOccurred(err.Error())
 	}
 	if ctrErrs != nil {
-		containerErrs := make([]string, len(ctrErrs))
-		for ctr := range ctrErrs {
-			containerErrs = append(containerErrs, ctr)
+		containerErrs := make([]iopodman.PodContainerErrorData, len(ctrErrs))
+		for ctr, reason := range ctrErrs {
+			ctrErr := iopodman.PodContainerErrorData{Containerid: ctr, Reason: reason.Error()}
+			containerErrs = append(containerErrs, ctrErr)
 		}
 		return call.ReplyPodContainerError(pod.ID(), containerErrs)
 	}
@@ -116,9 +117,10 @@ func (i *LibpodAPI) StopPod(call iopodman.VarlinkCall, name string) error {
 		return call.ReplyErrorOccurred(err.Error())
 	}
 	if ctrErrs != nil {
-		containerErrs := make([]string, len(ctrErrs))
-		for ctr := range ctrErrs {
-			containerErrs = append(containerErrs, ctr)
+		containerErrs := make([]iopodman.PodContainerErrorData, len(ctrErrs))
+		for ctr, reason := range ctrErrs {
+			ctrErr := iopodman.PodContainerErrorData{Containerid: ctr, Reason: reason.Error()}
+			containerErrs = append(containerErrs, ctrErr)
 		}
 		return call.ReplyPodContainerError(pod.ID(), containerErrs)
 	}
@@ -137,9 +139,10 @@ func (i *LibpodAPI) RestartPod(call iopodman.VarlinkCall, name string) error {
 		return call.ReplyErrorOccurred(err.Error())
 	}
 	if ctrErrs != nil {
-		containerErrs := make([]string, len(ctrErrs))
-		for ctr := range ctrErrs {
-			containerErrs = append(containerErrs, ctr)
+		containerErrs := make([]iopodman.PodContainerErrorData, len(ctrErrs))
+		for ctr, reason := range ctrErrs {
+			ctrErr := iopodman.PodContainerErrorData{Containerid: ctr, Reason: reason.Error()}
+			containerErrs = append(containerErrs, ctrErr)
 		}
 		return call.ReplyPodContainerError(pod.ID(), containerErrs)
 	}
@@ -164,9 +167,10 @@ func (i *LibpodAPI) KillPod(call iopodman.VarlinkCall, name string, signal int64
 		return call.ReplyErrorOccurred(err.Error())
 	}
 	if ctrErrs != nil {
-		containerErrs := make([]string, len(ctrErrs))
-		for ctr := range ctrErrs {
-			containerErrs = append(containerErrs, ctr)
+		containerErrs := make([]iopodman.PodContainerErrorData, len(ctrErrs))
+		for ctr, reason := range ctrErrs {
+			ctrErr := iopodman.PodContainerErrorData{Containerid: ctr, Reason: reason.Error()}
+			containerErrs = append(containerErrs, ctrErr)
 		}
 		return call.ReplyPodContainerError(pod.ID(), containerErrs)
 	}
@@ -185,9 +189,10 @@ func (i *LibpodAPI) PausePod(call iopodman.VarlinkCall, name string) error {
 		return call.ReplyErrorOccurred(err.Error())
 	}
 	if ctrErrs != nil {
-		containerErrs := make([]string, len(ctrErrs))
-		for ctr := range ctrErrs {
-			containerErrs = append(containerErrs, ctr)
+		containerErrs := make([]iopodman.PodContainerErrorData, len(ctrErrs))
+		for ctr, reason := range ctrErrs {
+			ctrErr := iopodman.PodContainerErrorData{Containerid: ctr, Reason: reason.Error()}
+			containerErrs = append(containerErrs, ctrErr)
 		}
 		return call.ReplyPodContainerError(pod.ID(), containerErrs)
 	}
@@ -206,9 +211,10 @@ func (i *LibpodAPI) UnpausePod(call iopodman.VarlinkCall, name string) error {
 		return call.ReplyErrorOccurred(err.Error())
 	}
 	if ctrErrs != nil {
-		containerErrs := make([]string, len(ctrErrs))
-		for ctr := range ctrErrs {
-			containerErrs = append(containerErrs, ctr)
+		containerErrs := make([]iopodman.PodContainerErrorData, len(ctrErrs))
+		for ctr, reason := range ctrErrs {
+			ctrErr := iopodman.PodContainerErrorData{Containerid: ctr, Reason: reason.Error()}
+			containerErrs = append(containerErrs, ctrErr)
 		}
 		return call.ReplyPodContainerError(pod.ID(), containerErrs)
 	}
-- 
cgit v1.2.3-54-g00ecf