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

Check config value in numeric or duration range #5228

Closed
wants to merge 1 commit into from

Conversation

bowenliang123
Copy link
Contributor

@bowenliang123 bowenliang123 commented Aug 31, 2023

Why are the changes needed?

  • Add and apply some helper methods to check config value in numeric or duration range, which may also helps unifying error message for invalid value
    • checkPositive
    • checkNonnegative
    • checkRange by NumericRange
    • checkPattern for string type
    • checkDuration by min/max range for duration type

How was this patch tested?

  • Add some test cases that check the changes thoroughly including negative and positive cases if possible

  • Add screenshots for manual tests if appropriate

  • Run test locally before make a pull request

Was this patch authored or co-authored using generative AI tooling?

No.

@codecov-commenter
Copy link

codecov-commenter commented Sep 1, 2023

Codecov Report

Attention: 17 lines in your changes are missing coverage. Please review.

Comparison is base (8f529aa) 61.41% compared to head (6995020) 61.42%.
Report is 1 commits behind head on master.

Files Patch % Lines
...scala/org/apache/kyuubi/config/ConfigBuilder.scala 62.16% 2 Missing and 12 partials ⚠️
.../main/scala/org/apache/kyuubi/util/MathUtils.scala 87.50% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #5228   +/-   ##
=========================================
  Coverage     61.41%   61.42%           
  Complexity       23       23           
=========================================
  Files           607      608    +1     
  Lines         35948    36000   +52     
  Branches       4939     4951   +12     
=========================================
+ Hits          22078    22112   +34     
- Misses        11484    11500   +16     
- Partials       2386     2388    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bowenliang123 bowenliang123 marked this pull request as ready for review September 1, 2023 01:10
.createWithDefault(Duration.ofMinutes(1).toMillis)

val CREDENTIALS_CHECK_INTERVAL: ConfigEntry[Long] =
buildConf("kyuubi.credentials.check.interval")
.doc("The interval to check the expiration of cached <user, CredentialsRef> pairs.")
.version("1.6.0")
.timeConf
.checkValue(_ > Duration.ofSeconds(3).toMillis, "Minimum 3 seconds")
.checkDurationRange(min = Some(Duration.ofSeconds(3)))
Copy link
Contributor

Choose a reason for hiding this comment

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

_ > should have different semantics from checkDurationRange.

Copy link
Contributor Author

@bowenliang123 bowenliang123 Sep 1, 2023

Choose a reason for hiding this comment

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

It's very likely an original typing mistake from #1021. The 'Minimum' term in the error message hints allowing >= inclusively rather than > exclusively as well. And there's no technical issue to exclude the start value in this config. Also taking Scala's numeric Range class as an example, the start value is always inclusive.

cc @lightning-L

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh....
I am okay with the change. Thanks

@bowenliang123
Copy link
Contributor Author

Do you have some time to have a look at this guarding checks for config values? If we docide not to accept it , let me close this PR. @pan3793

@pan3793 pan3793 changed the title [Improvement] Check config value in numeric or duration range Check config value in numeric or duration range Nov 24, 2023
Comment on lines +228 to +229
min: Option[Duration] = None,
max: Option[Duration] = None,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think we should change the type from : Option[Duration] = None into : Duration = null for simplified usage ? @pan3793

Copy link
Member

Choose a reason for hiding this comment

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

I prefer None, but force-inclusive is not flexible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So how about using the current implementation first?

@bowenliang123 bowenliang123 marked this pull request as draft December 1, 2023 15:44
@bowenliang123 bowenliang123 marked this pull request as ready for review December 1, 2023 16:35
@bowenliang123
Copy link
Contributor Author

Closing this PR with no enough consensus on the purposes, the design, the changes and the approaches.

@bowenliang123 bowenliang123 deleted the config-checkvalue branch September 10, 2024 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants