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

Fix bug about Complete logs not shown for failed TaskRun #691

Merged
merged 1 commit into from Feb 10, 2020

Conversation

16yuki0702
Copy link
Member

@16yuki0702 16yuki0702 commented Feb 7, 2020

Changes

Related issue is #587

This bug seems to be happen from When pod status is failed hasTaskRunFailed method returns error immediately,
so pod's logs can't be shown up.

This fix stop returning error immediately, if pod status is failed just logging error on standard error.

Test yaml files is

apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
  name: tt
spec:
  steps:
    - name: echo
      image: ubuntu
      command:
        - echol
      args:
        - "hello world"
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
  name: diff-tt
spec:
  taskRef:
    name: tt
---

from this fix, logs can be shown like below.

$ tkn tr ls
NAME       STARTED          DURATION     STATUS               
diff-tt2   45 minutes ago   10 seconds   Succeeded   
diff-tt    53 minutes ago   9 seconds    Failed 
$ tkn tr logs diff-tt
task tt has failed: "step-echo" exited with code 1 (image: "docker-pullable://ubuntu@sha256:8d31dad0c58f552e890d68bbfb735588b6b820a46e459672d96e585871acc110"); for logs run: kubectl -n default logs diff-tt-pod-h2gwv -c step-echo
[echo] {"level":"info","ts":1581057041.4130957,"logger":"fallback-logger","caller":"logging/config.go:69","msg":"Fetch GitHub commit ID from kodata failed: \"KO_DATA_PATH\" does not exist or is empty"}
[echo] 2020/02/07 06:30:42 Error executing command: exec: "echol": executable file not found in $PATH

container step-echo has failed  : [{"name":"","digest":"","key":"StartedAt","value":"2020-02-07T06:30:42Z","resourceRef":{}}]

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes tests (if functionality changed/added)
  • Includes docs (if user facing)
  • Regenerate the manpages and docs with make docs and make man if needed.
  • Run the code checkers with make check
  • Commit messages follow commit message best practices

See the contribution guide
for more details.

Release Notes

release-note

related issue is tektoncd#587

When pod status is failed hasTaskRunFailed method returns error immediately,
so pod's logs can't be shown up.

This fix stop returning error immediately, if pod status is failed just logging error on standard error.
@tekton-robot tekton-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 7, 2020
@tekton-robot
Copy link
Contributor

Hi @16yuki0702. Thanks for your PR.

I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot tekton-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Feb 7, 2020
@piyush-garg
Copy link
Contributor

/ok-to-test

@tekton-robot tekton-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 7, 2020
Copy link
Member

@danielhelfand danielhelfand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, when I use the example task/taskrun you used for testing, (i.e., tt, diff-tt), tkn v0.7.1 does already have this behavior without this change.

@16yuki0702
Copy link
Member Author

16yuki0702 commented Feb 7, 2020

Really??
Umm... I tested this on revision 22351666497231290ddaa5225bf73dc045db964a
and got this result.

$ tkn tr logs diff-tt
Error: task tt has failed: "step-echo" exited with code 1 (image: "docker-pullable://ubuntu@sha256:8d31dad0c58f552e890d68bbfb735588b6b820a46e459672d96e585871acc110"); for logs run: kubectl -n default logs diff-tt-pod-h2gwv -c step-echo

it seems pod's log didn't show up...
it is not related with cli version 🤔 ??
I'll try update pipeline version and test again 🤔

@16yuki0702
Copy link
Member Author

I updated pipeline latest and test it again with tkn v0.7.1, but got same result, I can't see any pod logs.

$ tkn tr logs diff-tt
Error: task tt has failed: "step-echo" exited with code 1 (image: "docker-pullable://ubuntu@sha256:8d31dad0c58f552e890d68bbfb735588b6b820a46e459672d96e585871acc110"); for logs run: kubectl -n default logs diff-tt-pod-r6shz -c step-echo

Umm... why the results are different 🤔??
I got any mistake or misunderstanding 🤔??

@danielhelfand
Copy link
Member

I updated pipeline latest and test it again with tkn v0.7.1, but got same result, I can't see any pod logs.

$ tkn tr logs diff-tt
Error: task tt has failed: "step-echo" exited with code 1 (image: "docker-pullable://ubuntu@sha256:8d31dad0c58f552e890d68bbfb735588b6b820a46e459672d96e585871acc110"); for logs run: kubectl -n default logs diff-tt-pod-r6shz -c step-echo

Umm... why the results are different 🤔??
I got any mistake or misunderstanding 🤔??

Interestingly, it appears there is a difference between tkn tr logs name -f and tkn tr logs name. With -f, I see the logs. Without it, I do not.

@danielhelfand
Copy link
Member

danielhelfand commented Feb 7, 2020

Yes, it looks like the difference occurs between going through readAvailableLogs and readLiveLogs so my mistake. This is a good find.

@16yuki0702
Copy link
Member Author

16yuki0702 commented Feb 7, 2020

Ahh...!! I totally understood! thank you very much!!

Actually readAvailableLogs should not check pod status like readLiveLogs 🤔??

@chmouel
Copy link
Member

chmouel commented Feb 7, 2020

What version of kubernetes/openshift do you use ? I have seen some differences between servers version (or at least openshift 4.2 and 4.3)

@16yuki0702
Copy link
Member Author

What version of kubernetes/openshift do you use ?

I use kubernetes v.1.15.5 (Docker Desktop on Mac).

I have seen some differences between servers version (or at least openshift 4.2 and 4.3)

Oops... what kind of difference 🤔??

Copy link
Member

@danielhelfand danielhelfand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

I do wonder if there's more to #587 than this, but I think there's no doubt that this helps to address it.

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 10, 2020
@chmouel
Copy link
Member

chmouel commented Feb 10, 2020

@16yuki0702 sorry i miss-understood the issue with tektoncd/pipeline#2028

@chmouel
Copy link
Member

chmouel commented Feb 10, 2020

/lgtm
/approve

Thanks 👍🏼🔥

@tekton-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chmouel

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 10, 2020
@tekton-robot tekton-robot merged commit 03012d7 into tektoncd:master Feb 10, 2020
@16yuki0702 16yuki0702 deleted the fix_bug_587 branch February 11, 2020 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants