gaborgsomogyi commented on code in PR #530:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/530#discussion_r1103821473


##########
e2e-tests/utils.sh:
##########
@@ -175,20 +175,33 @@ function debug_and_show_logs {
 
     echo "Flink logs:"
     kubectl get pods -o jsonpath='{range 
.items[*]}{.metadata.name}{"\n"}{end}' | while read pod;do
-        containers=(`kubectl get pods $pod -o 
jsonpath='{.spec.containers[*].name}'`)
-        i=0
-        for container in "${containers[@]}"; do
-          echo "Current logs for $pod:$container: "
-          kubectl logs $pod $container;
-          restart_count=$(kubectl get pod $pod -o 
jsonpath='{.status.containerStatuses['$i'].restartCount}')
-          if [[ ${restart_count} -gt 0 ]];then
-            echo "Previous logs for $pod: "
-            kubectl logs $pod $container --previous
-          fi
-        done
+        print_pod_container_logs "$pod" "{.spec.initContainers[*].name}" 
"{.status.initContainerStatuses[*].restartCount}"
+        print_pod_container_logs "$pod" "{.spec.containers[*].name}" 
"{.status.containerStatuses[*].restartCount}"
     done
 }
 
+function print_pod_container_logs {
+  pod=$1
+  container_path=$2
+  restart_count_path=$3
+
+  containers=(`kubectl get pods $pod -o jsonpath=$container_path`)
+  restart_counts=(`kubectl get pod $pod -o jsonpath=$restart_count_path`)
+
+  if [[ -z "$containers" ]];then
+    return 0
+  fi
+
+  for idx in "${!containers[@]}"; do
+    echo "Current logs for $pod:${containers[idx]}: "

Review Comment:
   I know it was implemented this way so it's a "new feature" but can we add 
some begin/end marker for the logs?
   Maybe
   ```
   --------BEGIN CURRENT LOGS for 
flink-example-statemachine-dddb4d664-m6n5b:flink-main-container--------
   foo
   --------END CURRENT LOGS--------
   ```
   or something. My eye could parse it easier.
   



##########
e2e-tests/utils.sh:
##########
@@ -175,20 +175,33 @@ function debug_and_show_logs {
 
     echo "Flink logs:"
     kubectl get pods -o jsonpath='{range 
.items[*]}{.metadata.name}{"\n"}{end}' | while read pod;do
-        containers=(`kubectl get pods $pod -o 
jsonpath='{.spec.containers[*].name}'`)
-        i=0
-        for container in "${containers[@]}"; do
-          echo "Current logs for $pod:$container: "
-          kubectl logs $pod $container;
-          restart_count=$(kubectl get pod $pod -o 
jsonpath='{.status.containerStatuses['$i'].restartCount}')
-          if [[ ${restart_count} -gt 0 ]];then
-            echo "Previous logs for $pod: "
-            kubectl logs $pod $container --previous
-          fi
-        done
+        print_pod_container_logs "$pod" "{.spec.initContainers[*].name}" 
"{.status.initContainerStatuses[*].restartCount}"
+        print_pod_container_logs "$pod" "{.spec.containers[*].name}" 
"{.status.containerStatuses[*].restartCount}"

Review Comment:
   I would add `echo "Printing init container logs"` and `echo "Printing main 
container logs"` for better understanding.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to