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

Check for the wrong start date #3092

Merged
merged 1 commit into from
Aug 29, 2023
Merged

Conversation

jisoolee
Copy link
Contributor

@jisoolee jisoolee commented Aug 28, 2023

Add wrongDateChecker to catch the wrong start date which is causing the wrong duration for PipelineRuns and TaskRuns

Changes

This will prevent to show the wrong duration for the users.
Related issue: https://github.ibm.com/one-pipeline/adoption-issues/issues/1374

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Docs included if any changes are user facing
  • Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (new features, significant UI changes, API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

NONE

@tekton-robot tekton-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 28, 2023
@tekton-robot
Copy link
Contributor

Hi @jisoolee. 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.

@AlanGreene
Copy link
Member

/kind bug

@tekton-robot tekton-robot added the kind/bug Categorizes issue or PR as related to a bug. label Aug 29, 2023
Copy link
Member

@AlanGreene AlanGreene left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @jisoolee. I've left a suggestion for a change to make sure handles some other possible bad input.

Comment on lines 31 to 33
const wrongDateChecker = new Date(startTime).getTime()

if (!startTime || !endTime || wrongDateChecker == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

If the startTime is either an empty string '' or undefined this will not give the expected result.

new Date('') and new Date(undefined) both result in an 'Invalid Date' object, and the call to getTime() will return NaN instead of 0.

Since this is a relatively simple expression we can just inline it in the if-statement after we've already checked that startTime is truthy so we know it won't hit these cases.

Suggested change
const wrongDateChecker = new Date(startTime).getTime()
if (!startTime || !endTime || wrongDateChecker == 0) {
if (!startTime || !endTime || new Date(startTime).getTime() == 0) {

Copy link
Contributor Author

@jisoolee jisoolee Aug 29, 2023

Choose a reason for hiding this comment

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

Thank you @AlanGreene for the suggestion and catching that. I did not think about those cases.

I applied the change.

Add wrongDateChecker to catch the wrong start date
which is causing the wrong duration for PipelineRuns
and TaskRuns
@AlanGreene
Copy link
Member

/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 Aug 29, 2023
Copy link
Member

@AlanGreene AlanGreene left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 29, 2023
@tekton-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AlanGreene

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 Aug 29, 2023
@tekton-robot tekton-robot merged commit b986b43 into tektoncd:main Aug 29, 2023
3 checks passed
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. kind/bug Categorizes issue or PR as related to a bug. 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.

3 participants