Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc: How to read log of the steps #898

Closed
cmoulliard opened this issue May 23, 2019 · 4 comments · Fixed by #935
Closed

Doc: How to read log of the steps #898

cmoulliard opened this issue May 23, 2019 · 4 comments · Fixed by #935
Assignees
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/documentation Categorizes issue or PR as related to documentation.

Comments

@cmoulliard
Copy link

Doc feature - How to read log of the steps

When a taskRun or pipelineRun is executed with several steps, then a container is created for the step defined and the log content could be accessed to check what happened.
the doc should explain how to find the containers - steps and how to read the log

Example

kc get taskruns/build-docker-image-from-git-source-task-run -o yaml -n tutorial
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"tekton.dev/v1alpha1","kind":"TaskRun","metadata":{"annotations":{},"name":"build-docker-image-from-git-source-task-run","namespace":"tutorial"},"spec":{"inputs":{"params":[{"name":"pathToDockerFile","value":"Dockerfile"},{"name":"pathToContext","value":"/workspace/docker-source/examples/microservices/leeroy-web"}],"resources":[{"name":"docker-source","resourceRef":{"name":"skaffold-git"}}]},"outputs":{"resources":[{"name":"builtImage","resourceRef":{"name":"skaffold-image-leeroy-web"}}]},"taskRef":{"name":"build-docker-image-from-git-source"}}}
  creationTimestamp: "2019-05-23T06:03:56Z"
  generation: 1
  labels:
    tekton.dev/task: build-docker-image-from-git-source
  name: build-docker-image-from-git-source-task-run
  namespace: tutorial
  resourceVersion: "91117"
  selfLink: /apis/tekton.dev/v1alpha1/namespaces/tutorial/taskruns/build-docker-image-from-git-source-task-run
  uid: 8cbe8cb2-7d20-11e9-927b-fa163eaa1b05
spec:
  inputs:
    params:
    - name: pathToDockerFile
      value: Dockerfile
    - name: pathToContext
      value: /workspace/docker-source/examples/microservices/leeroy-web
    resources:
    - name: docker-source
      resourceRef:
        name: skaffold-git
  outputs:
    resources:
    - name: builtImage
      resourceRef:
        name: skaffold-image-leeroy-web
  taskRef:
    kind: Task
    name: build-docker-image-from-git-source
  trigger:
    type: ""
status:
  completionTime: "2019-05-23T06:04:23Z"
  conditions:
  - lastTransitionTime: "2019-05-23T06:04:23Z"
    message: '"build-step-build-and-push" exited with code 1 (image: "docker-pullable://gcr.io/kaniko-project/executor@sha256:d9fe474f80b73808dc12b54f45f5fc90f7856d9fc699d4a5e79d968a1aef1a72");
      for logs run: kubectl -n tutorial logs build-docker-image-from-git-source-task-run-pod-e31c31
      -c build-step-build-and-push'
...

Next, check the log of the pod

kubectl -n tutorial logs build-docker-image-from-git-source-task-run-pod-e31c31
Error from server (BadRequest): a container name must be specified for pod build-docker-image-from-git-source-task-run-pod-e31c31, choose one of: [build-step-git-source-skaffold-git-r7hj8 build-step-build-and-push nop] or one of the init containers: [build-step-credential-initializer-stpr4 build-step-place-tools]

Get container's log

kubectl -n tutorial logs build-docker-image-from-git-source-task-run-pod-e31c31 -c build-step-build-and-push               
INFO[0000] Downloading base image golang:1.10.1-alpine3.7 
2019/05/23 06:04:01 No matching credentials were found, falling back on anonymous
INFO[0000] Executing 0 build triggers                   
INFO[0000] Unpacking rootfs as cmd RUN go build -o /web . requires it. 
INFO[0006] Taking snapshot of full filesystem...        
INFO[0007] Skipping paths under /kaniko, as it is a whitelisted directory 
INFO[0007] Skipping paths under /builder/tools, as it is a whitelisted directory 
...
@vdemeester
Copy link
Member

There is several possibilities to do that, but please keep in mind this is still early.

  • a taskrun creating a pod, you need to read the pod log as you described. You can use ˋ—all-containers` flag on kubectl to see the logs from all the containers
  • tektoncd/cli aims to answer those questions/features, by providing a cli focused on pipeline (and thus not on kubectl constructs)
  • tektoncd/dashboard has the same aim but from a web interface instead of a command line

@skaegi
Copy link
Contributor

skaegi commented May 27, 2019

@vdemeester I sometimes wonder if we should just bite the bullet and do api aggregation to have a common logs endpoint on TaskRuns. e.g. so we could support kubectl logs on TaskRun names.

I was looking at kubernetes/kubernetes#72637 -- and a generic logs sub-resource we can use via CRD does not seem to be imminent.

@vdemeester
Copy link
Member

@skaegi yes we may have to go that route at some point 😅

@bobcatfish
Copy link
Collaborator

We should definitely document one or more of the current solutions!

@bobcatfish bobcatfish added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/documentation Categorizes issue or PR as related to documentation. labels May 30, 2019
@bobcatfish bobcatfish self-assigned this May 30, 2019
@bobcatfish bobcatfish added this to the Pipelines 0.5 🐱 milestone May 30, 2019
bobcatfish added a commit to bobcatfish/pipeline that referenced this issue May 30, 2019
As @cmoulliard pointed out, it's not obvious how to get to the logs for
a PipelineRun or a TaskRun. If you know how the underlying kubernetes
resources work you can figure it out but it can be hard to know where to
start. Plus, folks may not realize that we are working on better ways of
accessing logs.

And once we work on #107 we can build up these docs with more detail
about how to upload logs too.

Fixes tektoncd#898
tekton-robot pushed a commit that referenced this issue May 30, 2019
As @cmoulliard pointed out, it's not obvious how to get to the logs for
a PipelineRun or a TaskRun. If you know how the underlying kubernetes
resources work you can figure it out but it can be hard to know where to
start. Plus, folks may not realize that we are working on better ways of
accessing logs.

And once we work on #107 we can build up these docs with more detail
about how to upload logs too.

Fixes #898
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/documentation Categorizes issue or PR as related to documentation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants