Skip to content

feat(nodepool): support timezone for disruption budgets #2032

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

flavono123
Copy link
Contributor

@flavono123 flavono123 commented Feb 26, 2025

Fixes #1446, partially

Description

add the field disruption.budgets[].timeZone for NodePoolSpec.
if not set, use UTC as default.
validate if not schedule is set, timeZone also cannot be.

referenced one in CronJobSpec and already tried PR #1447

How was this change tested?

make verify && go test ./pkg/apis/v1/

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 26, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @flavono123. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 26, 2025
@flavono123
Copy link
Contributor Author

flavono123 commented Feb 26, 2025

are we have to emit a new event for a wrong timezone?:

If the time zone name becomes invalid during the lifetime of a CronJob or due to a change in host configuration, the controller will stop creating new new Jobs and will create a system event with the reason UnknownTimeZone

https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/cron-job-v1/#CronJobSpec

@coveralls
Copy link

coveralls commented Feb 26, 2025

Pull Request Test Coverage Report for Build 15434332727

Details

  • 12 of 16 (75.0%) changed or added relevant lines in 2 files are covered.
  • 15 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.09%) to 81.958%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/apis/v1/zz_generated.deepcopy.go 1 5 20.0%
Files with Coverage Reduction New Missed Lines %
pkg/controllers/disruption/consolidation.go 4 85.55%
pkg/controllers/provisioning/scheduling/topologydomaingroup.go 4 86.21%
pkg/controllers/provisioning/scheduling/preferences.go 7 88.76%
Totals Coverage Status
Change from base Build 15430250801: -0.09%
Covered Lines: 10262
Relevant Lines: 12521

💛 - Coveralls

@flavono123
Copy link
Contributor Author

@njtran could you mind to review this?

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: flavono123
Once this PR has been reviewed and has the lgtm label, please assign jmdeal for approval. For more information see the 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

@jonathan-innis
Copy link
Member

@flavono123 Would you mind coming to one of our Working Group meetings and we can discuss this one more? I think there are some tricky things with handling timezones that we have generally avoided but open to talk more about your use-case.

@flavono123
Copy link
Contributor Author

flavono123 commented Apr 1, 2025

@jonathan-innis thanks for inviting me. i'd like to, but two things are hurdles for me:

  • I'm afraid to understand the conversation in real time, honestly, I'm not good at English, both speaking and listening, so it would be good if there is support for translation.
  • Time is dawning for me, another time zone problem.

so let me explain my use-case in "text", in advance:

    - duration: 21h
      nodes: "0"
      schedule: 0 21 * * sun-thu

I use budgets like the one above to allow disruptions from 3am to 6am, Monday to Friday in KST(actually, leveraging does not allow from 6am to 3am tomorrow to avoid working time). I think it is more confusing when the duration is over the date and with weekdays for my case.

In short, this is just a literal time zone issue to make it easier to figure out the time span of budgets.

@engedaam
Copy link
Contributor

/assign @elmiko

@elmiko
Copy link
Contributor

elmiko commented May 13, 2025

putting this in my queue for the week, my intention is to review the various places where a time value is used and enumerate them in a doc. then we can review the doc to see if we should update all the time uses to include a user-specified timezone.

@elmiko
Copy link
Contributor

elmiko commented May 15, 2025

i poked around the karpenter code this week and i think we can confirm the the nodepool.spec.disruption.budgets.schedule is the only place where we currently accept a date-like format, or cron format.

if we wanted to support timezones for disruption budgets, i think we would want to add a nodepool.spec.disruption.budgets.timeZone field, similar to how core kubernetes allows a timezone field in cronjob specs.

@jonathan-innis
Copy link
Member

@elmiko It looks like the PR now supports your suggestion about using a separate timeZone field in the budgets section -- is this PR ready for another round of review?

Copy link
Contributor

@elmiko elmiko left a comment

Choose a reason for hiding this comment

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

this is looking good to me

@@ -237,6 +235,29 @@ var _ = Describe("Budgets", func() {
Expect(err).To(Succeed())
Expect(active).To(BeFalse())
})
It("should reutn that a schedule is active with a timezone", func() {

Choose a reason for hiding this comment

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

nit: reutn -> return :)

@flavono123 flavono123 force-pushed the feature/support-tz-for-disruption-budgets-schedule branch from 63523ea to c8baa62 Compare June 4, 2025 05:26
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. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. 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.

feat: StartDateTime and EndDateTime, Timezones for NodePool Disruption Budgets
7 participants