Skip to content

Allow human readable duration strings in DecorationConfig duration fields. #12100

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

Merged
merged 1 commit into from
Apr 24, 2019

Conversation

cjwagner
Copy link
Member

@cjwagner cjwagner commented Apr 6, 2019

This PR adds a new Duration type that can parse either 'integer number of nanoseconds' or 'duration string' format and serializes to the 'duration string' format. This type is used to replace the existing DecorationConfig duration fields with backwards compatibility for existing values. Now those fields can be specified in config like "1h15m" instead of 4500000000000 (ns units).

/cc @stevekuznetsov @sebastienvas

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. area/prow Issues or PRs related to prow sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Apr 6, 2019
@cjwagner cjwagner force-pushed the durations-for-humans branch from 98c7c8f to 0837828 Compare April 6, 2019 00:06
@sebastienvas
Copy link
Contributor

thanks
/lgtm
/hold

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Apr 6, 2019
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: b69f654312f6b0b733348257dbdbfd51ce4090cd

@Katharine
Copy link
Member

I think the _readable suffix is pretty awkward, and likely to be confusing to users.

Couldn't we just make timeout and grace_period accept either? At this point you already have to post-process the config, so you could just make them strings (or something else that can take either), try parsing a duration, then try parsing a number.

Copy link
Contributor

@stevekuznetsov stevekuznetsov left a comment

Choose a reason for hiding this comment

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

Are we adding a deprecation warning?

Copy link
Contributor

@stevekuznetsov stevekuznetsov left a comment

Choose a reason for hiding this comment

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

+1 to Katharine's comment

@cjwagner cjwagner force-pushed the durations-for-humans branch from 0837828 to da9fd3b Compare April 17, 2019 23:36
@k8s-ci-robot k8s-ci-robot added area/prow/knative-build Issues or PRs related to prow's knative-build controller component area/prow/pod-utilities Issues or PRs related to prow's pod-utilities component and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Apr 17, 2019
@cjwagner
Copy link
Member Author

I got rid of the _readable fields and switched to using a new Duration type that can parse either 'integer number of nanoseconds' or 'duration string' format and serializes to the 'duration string' format.
The API server shouldn't care that we are changing the type of this field right? I think it is sufficient that our components parse both the existing and new formats properly.

@cjwagner cjwagner force-pushed the durations-for-humans branch from da9fd3b to dcf972e Compare April 17, 2019 23:49
@k8s-ci-robot k8s-ci-robot added the area/config Issues or PRs related to code in /config label Apr 17, 2019
@cjwagner cjwagner force-pushed the durations-for-humans branch from dcf972e to 7f9a860 Compare April 17, 2019 23:50
@stevekuznetsov
Copy link
Contributor

Yeah the type is irrelevant I think, don't think etcd cares about how to store the record. Only one way to find out ;)

@cjwagner cjwagner force-pushed the durations-for-humans branch from 7f9a860 to 2231ec8 Compare April 18, 2019 00:05
@cjwagner
Copy link
Member Author

Passes tests now. (My editor's go formatting disagrees with go fmt...) PTAL.

Copy link
Contributor

@stevekuznetsov stevekuznetsov left a comment

Choose a reason for hiding this comment

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

The changes LGTM but can you try installing the current CRD, creating some, then changing the CRD and seeing if any of our clients fall over on a test cluster since the failure mode there is pretty rough?

/hold

grace_period: 15000000000
timeout: 2400000000000
grace_period: 15s
timeout: 40m0s
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: do we need the 0s here? That's odd

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately that is how duration strings are printed: https://play.golang.org/p/xyrKD-34gfP

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 18, 2019
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 8693cfde7fd607c1379eb68f9bab621592b3cb62

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cjwagner, stevekuznetsov

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

@cjwagner
Copy link
Member Author

The changes LGTM but can you try installing the current CRD, creating some, then changing the CRD and seeing if any of our clients fall over on a test cluster since the failure mode there is pretty rough?

I thought that is what we discussed here #12100 (comment)?

I agree that the failure mode could be nasty if I made a mistake and if there is a better way to test this I'm eager to do so, but the ProwJob CRD did not change at all, so I'm not sure what you are suggesting I do to test this.

@stevekuznetsov
Copy link
Contributor

Eek sorry, poor English -- I meant to install the CRD, create some ProwJobs (creating some) and edit the ProwJobs ("changing the CRD") with the new clients to see it function. But if you want to just roll it out to prow.k8s.io and roll back in case things get weird that also SGTM

@cjwagner cjwagner changed the title Add human readable variants of DecorationConfig duration fields. Allow human readable duration strings in DecorationConfig duration fields. Apr 24, 2019
@cjwagner
Copy link
Member Author

Deploying from this PR or merging this PR then deploying master should be equivalent, but deploying to prod from a PR seems like bad practice so lets merge this and deploy from master.
If something is broken reverting is cheap.
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 24, 2019
@k8s-ci-robot k8s-ci-robot merged commit e0b472c into kubernetes:master Apr 24, 2019
@k8s-ci-robot
Copy link
Contributor

@cjwagner: Updated the job-config configmap in namespace default using the following files:

  • key generated-security-jobs.yaml using file config/jobs/kubernetes-security/generated-security-jobs.yaml

In response to this:

This PR adds a new Duration type that can parse either 'integer number of nanoseconds' or 'duration string' format and serializes to the 'duration string' format. This type is used to replace the existing DecorationConfig duration fields with backwards compatibility for existing values. Now those fields can be specified in config like "1h15m" instead of 4500000000000 (ns units).

/cc @stevekuznetsov @sebastienvas

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.

@cjwagner cjwagner deleted the durations-for-humans branch April 24, 2019 18:37
@cjwagner
Copy link
Member Author

This appears to be working as intended. Our currently deployed config contains duration values in both formats and everything is being serialized to the human readable strings: https://prow.k8s.io/config

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. area/config Issues or PRs related to code in /config area/prow/knative-build Issues or PRs related to prow's knative-build controller component area/prow/pod-utilities Issues or PRs related to prow's pod-utilities component area/prow Issues or PRs related to prow cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants