Repository: kubeflow/kfp-tekton (language: python)

Issue:
Log API didn't cover the edge case with custom tasks that don't produce logs
/kind bug

**What steps did you take and what happened:**
With the introduction of Tekton custom task, some custom task doesn't need to create new pods to run workloads. This means there's no logs for the custom task since it only get back the controller status. The current log API didn't cover this edge case and panic because log API was introduced before Tekton diverge its pipelinerun spec with custom task. 

We need to check whether the Tekton task is a Tekton custom task without pods/logs before retrieving/streaming the log file. If the custom task doesn't have any pod/log, return empty string or warning message as the logs to maintain backward compatibility. 

Panic we are seeing
```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1d68c24]
goroutine 1 [running]:
github.com/tektoncd/cli/pkg/helper/log.(*Reader).readAvailablePipelineLogs(0xc0000c2960, 0xc000224000, 0x2d, 0x0, 0x0, 0x0)
	/workspace/src/github.com/tektoncd/cli/pkg/helper/log/pipeline_reader.go:90 +0xc4
github.com/tektoncd/cli/pkg/helper/log.(*Reader).readPipelineLog(0xc0000c2960, 0x24, 0x21cfec8, 0x7ffeefbffc6e, 0xc000101340)
	/workspace/src/github.com/tektoncd/cli/pkg/helper/log/pipeline_reader.go:41 +0x13d
github.com/tektoncd/cli/pkg/helper/log.(*Reader).Read(0xc0000c2960, 0x8, 0xc0001c52c0, 0xc0000c2960, 0x0)
	/workspace/src/github.com/tektoncd/cli/pkg/helper/log/reader.go:77 +0xb8
github.com/tektoncd/cli/pkg/cmd/pipelinerun.Run(0xc0001c52c0, 0xc0002f0040, 0x0)
	/workspace/src/github.com/tektoncd/cli/pkg/cmd/pipelinerun/logs.go:105 +0x81
github.com/tektoncd/cli/pkg/cmd/pipelinerun.logCommand.func1(0xc000311340, 0xc000326e40, 0x1, 0x3, 0x0, 0x0)
	/workspace/src/github.com/tektoncd/cli/pkg/cmd/pipelinerun/logs.go:78 +0x1ba
github.com/spf13/cobra.(*Command).execute(0xc000311340, 0xc0002f1b80, 0x3, 0x4, 0xc000311340, 0xc0002f1b80)
	/workspace/pkg/mod/github.com/chmouel/cobra@v0.0.0-20200107083527-379e7a80af0c/command.go:834 +0x460
github.com/spf13/cobra.(*Command).ExecuteC(0xc0002e62c0, 0xc0002f0040, 0xc0002e62c0, 0xc000098058)
	/workspace/pkg/mod/github.com/chmouel/cobra@v0.0.0-20200107083527-379e7a80af0c/command.go:922 +0x2fb
github.com/spf13/cobra.(*Command).Execute(...)
	/workspace/pkg/mod/github.com/chmouel/cobra@v0.0.0-20200107083527-379e7a80af0c/command.go:872
main.main()
	/workspace/src/github.com/tektoncd/cli/cmd/tkn/main.go:29 +0x4b
```

**What did you expect to happen:**


**Additional information:**
[Miscellaneous information that will assist in solving the issue.]


**Environment:**

* Python Version (use `python --version`):
* SDK Version: 
* Tekton Version (use `tkn version`):
* Kubernetes Version (use `kubectl version`):
* OS (e.g. from `/etc/os-release`):



Discussion / hints:

Fix patch:
diff --git a/backend/src/apiserver/resource/resource_manager.go b/backend/src/apiserver/resource/resource_manager.go
index 5db1a4a01e..b6ce7b9ffb 100644
--- a/backend/src/apiserver/resource/resource_manager.go
+++ b/backend/src/apiserver/resource/resource_manager.go
@@ -650,12 +650,16 @@ func (r *ResourceManager) ReadLog(runId string, nodeId string, follow bool, dst
 	return err
 }
 
-func (r *ResourceManager) readRunLogFromPod(run *model.RunDetail, nodeId string, follow bool, dst io.Writer) error {
-	logOptions := corev1.PodLogOptions{
-		Container:  "main",
+func (r *ResourceManager) getPodLogOptions(follow bool) corev1.PodLogOptions {
+	return corev1.PodLogOptions{
+		Container:  "step-main",
 		Timestamps: false,
 		Follow:     follow,
 	}
+}
+
+func (r *ResourceManager) readRunLogFromPod(run *model.RunDetail, nodeId string, follow bool, dst io.Writer) error {
+	logOptions := r.getPodLogOptions(follow)
 
 	req := r.k8sCoreClient.PodClient(run.Namespace).GetLogs(nodeId, &logOptions)
 	podLogs, err := req.Stream(context.Background())


Test patch:
diff --git a/backend/src/apiserver/resource/resource_manager_test.go b/backend/src/apiserver/resource/resource_manager_test.go
index a72921069c..cea29f9972 100644
--- a/backend/src/apiserver/resource/resource_manager_test.go
+++ b/backend/src/apiserver/resource/resource_manager_test.go
@@ -30,6 +30,7 @@ import (
 	"github.com/stretchr/testify/require"
 	"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
 	"google.golang.org/grpc/codes"
+	corev1 "k8s.io/api/core/v1"
 	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 )
 
@@ -542,3 +543,16 @@ func TestCreateDefaultExperiment_MultiUser(t *testing.T) {
 	}
 	assert.Equal(t, expectedExperiment, experiment)
 }
+
+func TestGetPodLogOptions(t *testing.T) {
+	initEnvVars()
+	store := NewFakeClientManagerOrFatal(util.NewFakeTimeForEpoch())
+	manager := NewResourceManager(store)
+	logOptions := manager.getPodLogOptions(true)
+	expectedLogOptions := corev1.PodLogOptions{
+		Container:  "step-main",
+		Timestamps: false,
+		Follow:     true,
+	}
+	assert.Equal(t, expectedLogOptions, logOptions)
+}