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

Added support of nine digit nanoseconds format. #1370

Closed
wants to merge 3 commits into from

Conversation

ndallmeyer
Copy link

@ndallmeyer ndallmeyer commented Aug 14, 2023

Added support for up to nine digit nanoseconds format. The nanoseconds are truncated to 7 decimal places. See #1350

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ndallmeyer
Once this PR has been reviewed and has the lgtm label, please assign tg123 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 14, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Aug 14, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @ndallmeyer!

It looks like this is your first PR to kubernetes-client/csharp 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-client/csharp has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 14, 2023
@tg123
Copy link
Member

tg123 commented Aug 14, 2023

could you please merge my testcase

@ndallmeyer
Copy link
Author

Thanks, based on your tests I've implemented tests that cover all edge cases.


private static string FormatDateTimeOffsetToSevenDigitsNanoseconds(string dateTime)
{
var isUTC = dateTime.EndsWith("Z");
Copy link
Member

Choose a reason for hiding this comment

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

too complex
why not just trim extra input?

Copy link
Author

Choose a reason for hiding this comment

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

As already pointed out by @anekdoti in #1350 the lastTransitionTimestamp should be deserializable as a Golang Time struct that follows RFC3339 where an arbitrary number of nansecond digits from 0 to 9 is valid. Therefore trimming alone would not help here.
This method allows an arbitrary number of nanosecond digits from 0 to 9.

@tg123
Copy link
Member

tg123 commented Aug 25, 2023

check my impl in #1351

@anekdoti
Copy link

Hello @tg123 ,

thank you for your PR #1351.

It solves the specific case that made me open issue #1350 where we observed an error with a timestamp with 9 nanosecond digits.

However, as also described in my issue, timestamps can have an arbitrary number (up to 9) of nanosecond digits by the Golang implementation. For this reason, your PR only solves certain special cases whereas the PR on hand by @ndallmeyer solves the general case as by Kubernetes API conventions.

To avoid further and foreseeable problems with deserializing timestamps, I would therefore strongly suggest to follow the general approach by @ndallmeyer .

@tg123
Copy link
Member

tg123 commented Aug 28, 2023

@anekdoti could you please add bad test cases?
also please make pipeline happy

@ndallmeyer
Copy link
Author

Hi @tg123 , recently added test cases as comment to your PR. Also fixed a bug, that made the pipeline unhappy.

@ndallmeyer
Copy link
Author

Thanks @tg123 for the brief solution for this issue in #1351. Therefore I will close this PR.

@ndallmeyer ndallmeyer closed this Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants