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

Allow to use EPOCH timestamp in the image annotation #665

Merged
merged 1 commit into from
Sep 21, 2022

Conversation

mpryc
Copy link
Collaborator

@mpryc mpryc commented Sep 21, 2022

For the images that were build without commit time or hash data we allow to annotate them for the Commit Time exporter to work properly. This change allows to annotate with EPOCH time format.

Signed-off-by: Michal Pryc mpryc@redhat.com

@redhat-cop/mdt

exporters/pelorus/timeutil.py Outdated Show resolved Hide resolved
exporters/pelorus/timeutil.py Outdated Show resolved Hide resolved
@KevinMGranger
Copy link
Collaborator

KevinMGranger commented Sep 21, 2022

I'm still confused by the epoch function, but I might be misremembering what we wanted.

I think we said:

  • assume it's an epoch
  • assume a long epoch string means it's in milliseconds

If we're allowing 13-digit epochs, that means it's in milliseconds, or it refers to the year 33658 at the earliest. Which will cause an exception from fromtimestamp:

proof of concept
In [6]: len("1" + "0" * 12)
Out[6]: 13

In [7]: to_epoch_from_string("1" + "0" * 12)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In [7], line 1
----> 1 to_epoch_from_string("1" + "0" * 12)

File ~/workcode/pelorus/exporters/pelorus/timeutil.py:82, in to_epoch_from_string(timestring, allowed_length)
     78     raise ValueError(
     79         f"Tried to get epoch from not allowed string length: {timestring} / {allowed_length}"
     80     )
     81 else:
---> 82     return datetime.fromtimestamp(int(epoch_date_time))

ValueError: year 33658 is out of range

I also really don't get why customizing the number of digits is necessary. Where to do use any other values than the defaults?

Finally, there's one gotcha: it needs to be fromtimestamp(timestamp, timezone.utc), otherwise we get a naive datetime again. Those are really annoying. We should have a unit test to catch that. Disregard, I misunderstood the docs!

@mpryc mpryc force-pushed the allow_epoch_in_image branch from 79b1123 to 20610ef Compare September 21, 2022 15:22
@KevinMGranger
Copy link
Collaborator

/hold timezone issue and milliseconds discussion

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 21, 2022
@mpryc mpryc force-pushed the allow_epoch_in_image branch from 20610ef to b92e07a Compare September 21, 2022 15:42
@KevinMGranger
Copy link
Collaborator

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 21, 2022
@weshayutin
Copy link
Contributor

/LGTM

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 21, 2022
@weshayutin
Copy link
Contributor

Screenshot from 2022-09-21 10-13-13
Screenshot from 2022-09-21 10-13-28

@weshayutin
Copy link
Contributor

/LGTM

For the images that were build without commit time or hash data
we allow to annotate them for the Commit Time exporter to work
properly. This change allows to annotate with EPOCH time format.

Signed-off-by: Michal Pryc <mpryc@redhat.com>
@mpryc mpryc force-pushed the allow_epoch_in_image branch from b92e07a to 2af8407 Compare September 21, 2022 18:08
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Sep 21, 2022
@mpryc mpryc requested a review from KevinMGranger September 21, 2022 18:12
exporters/committime/collector_image.py Show resolved Hide resolved
exporters/pelorus/timeutil.py Show resolved Hide resolved
exporters/tests/test_datetime.py Show resolved Hide resolved
@KevinMGranger
Copy link
Collaborator

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 21, 2022
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 21, 2022
@openshift-ci
Copy link

openshift-ci bot commented Sep 21, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: KevinMGranger, weshayutin

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:
  • OWNERS [KevinMGranger,weshayutin]

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

@mpryc
Copy link
Collaborator Author

mpryc commented Sep 21, 2022

/retest

@mpryc
Copy link
Collaborator Author

mpryc commented Sep 21, 2022

/test 4.11-e2e-openshift

@mpryc mpryc merged commit 71f8b85 into dora-metrics:master Sep 21, 2022
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. dco-signoff: yes lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants