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

fix: ensure NillableDuration is round-trippable #1545

Merged
merged 3 commits into from
Aug 12, 2024

Conversation

jmdeal
Copy link
Member

@jmdeal jmdeal commented Aug 8, 2024

Fixes #N/A

Description
Ensure our NillableDuration type is round-trippable for conversion webhooks.

How was this change tested?

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 Aug 8, 2024
@jmdeal jmdeal changed the title checkpoint fix: ensure NillableDuration is round-trippable Aug 8, 2024
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 8, 2024
pkg/apis/v1/duration.go Outdated Show resolved Hide resolved
@jmdeal jmdeal force-pushed the fix/round-trip-duration branch 2 times, most recently from 0c9cc81 to d704fb2 Compare August 8, 2024 20:22
@jmdeal jmdeal changed the title fix: ensure NillableDuration is round-trippable [DRAFT] fix: ensure NillableDuration is round-trippable Aug 9, 2024
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 9, 2024
@coveralls
Copy link

Pull Request Test Coverage Report for Build 10323210198

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 6 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.02%) to 77.875%

Files with Coverage Reduction New Missed Lines %
pkg/test/expectations/expectations.go 2 94.64%
pkg/controllers/disruption/drift.go 2 89.66%
pkg/controllers/node/termination/controller.go 2 66.67%
Totals Coverage Status
Change from base Build 10322150232: -0.02%
Covered Lines: 8891
Relevant Lines: 11417

💛 - Coveralls

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 9, 2024
@jmdeal jmdeal force-pushed the fix/round-trip-duration branch 2 times, most recently from 14e0a2b to 15e5a6c Compare August 9, 2024 20:19
@jmdeal jmdeal changed the title [DRAFT] fix: ensure NillableDuration is round-trippable fix: ensure NillableDuration is round-trippable Aug 9, 2024
pkg/apis/v1/nodepool_conversion_test.go Outdated Show resolved Hide resolved
pkg/apis/v1/nodepool_conversion_test.go Outdated Show resolved Hide resolved
pkg/apis/v1/nodepool_conversion_test.go Outdated Show resolved Hide resolved
pkg/apis/v1/nodepool_conversion_test.go Outdated Show resolved Hide resolved
duration := NillableDuration{}
Expect(json.Unmarshal([]byte(str), &duration)).Should(Succeed())
*field() = duration
Expect(v1nodepool.ConvertTo(ctx, v1beta1nodepool)).To(Succeed())
Copy link
Member

Choose a reason for hiding this comment

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

Just validating: This test failed prior to this change?

Copy link
Member

Choose a reason for hiding this comment

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

Also, any reason to not json marshal the entire object rather than just the specific field that we care about during the test? Seems like a stronger bar to hold if we do that

Copy link
Member Author

@jmdeal jmdeal Aug 11, 2024

Choose a reason for hiding this comment

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

Yep, this failed before. I was only marshaling this as json to ensure we populated the "raw" value correctly before doing the conversions, I've updated every instance of us creating a NillableDuration with a constructor that covers this instead.

Copy link
Contributor

@njtran njtran left a comment

Choose a reason for hiding this comment

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

one comment but LGTM

pkg/apis/v1/nodepool_conversion_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@njtran njtran left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jmdeal, njtran

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 12, 2024
@k8s-ci-robot k8s-ci-robot merged commit feb6857 into kubernetes-sigs:main Aug 12, 2024
10 of 11 checks passed
engedaam pushed a commit to engedaam/karpenter-core that referenced this pull request Aug 12, 2024
Co-authored-by: Nick Tran <10810510+njtran@users.noreply.github.com>
engedaam pushed a commit to engedaam/karpenter-core that referenced this pull request Aug 12, 2024
Co-authored-by: Nick Tran <10810510+njtran@users.noreply.github.com>
engedaam pushed a commit to engedaam/karpenter-core that referenced this pull request Aug 12, 2024
Co-authored-by: Nick Tran <10810510+njtran@users.noreply.github.com>
engedaam pushed a commit to engedaam/karpenter-core that referenced this pull request Aug 12, 2024
Co-authored-by: Nick Tran <10810510+njtran@users.noreply.github.com>
rschalo pushed a commit to rschalo/karpenter that referenced this pull request Aug 12, 2024
Co-authored-by: Nick Tran <10810510+njtran@users.noreply.github.com>
engedaam pushed a commit to engedaam/karpenter-core that referenced this pull request Aug 12, 2024
Co-authored-by: Nick Tran <10810510+njtran@users.noreply.github.com>
engedaam pushed a commit to engedaam/karpenter-core that referenced this pull request Aug 12, 2024
Co-authored-by: Nick Tran <10810510+njtran@users.noreply.github.com>
engedaam pushed a commit to engedaam/karpenter-core that referenced this pull request Aug 12, 2024
Co-authored-by: Nick Tran <10810510+njtran@users.noreply.github.com>
engedaam pushed a commit to engedaam/karpenter-core that referenced this pull request Aug 12, 2024
Co-authored-by: Nick Tran <10810510+njtran@users.noreply.github.com>
rschalo pushed a commit to rschalo/karpenter that referenced this pull request Aug 12, 2024
Co-authored-by: Nick Tran <10810510+njtran@users.noreply.github.com>
engedaam pushed a commit to engedaam/karpenter-core that referenced this pull request Aug 12, 2024
Co-authored-by: Nick Tran <10810510+njtran@users.noreply.github.com>
@jmdeal jmdeal deleted the fix/round-trip-duration branch August 14, 2024 22:55
BEvgeniyS pushed a commit to BEvgeniyS/karpenter that referenced this pull request Sep 16, 2024
Co-authored-by: Nick Tran <10810510+njtran@users.noreply.github.com>
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. 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. 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.

6 participants