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: affinityName can be set to an empty string #3442

Merged
merged 1 commit into from
Apr 25, 2023

Conversation

chaunceyjiang
Copy link
Member

@chaunceyjiang chaunceyjiang commented Apr 21, 2023

What type of PR is this?
/kind bug

What this PR does / why we need it:

affinityName cannot be set to an empty string.

Which issue(s) this PR fixes:
Fixes #3441

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

API change: The length of `AffinityName` in `PropagationPolicy` now be restricted to [1, 32], and must be a qualified name.

@karmada-bot karmada-bot added the kind/bug Categorizes issue or PR as related to a bug. label Apr 21, 2023
@karmada-bot karmada-bot requested review from Garrybest and Poor12 April 21, 2023 03:21
@karmada-bot karmada-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Apr 21, 2023
@codecov-commenter
Copy link

codecov-commenter commented Apr 21, 2023

Codecov Report

Merging #3442 (6fb9329) into master (b118a73) will increase coverage by 0.16%.
The diff coverage is 0.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master    #3442      +/-   ##
==========================================
+ Coverage   51.78%   51.94%   +0.16%     
==========================================
  Files         210      210              
  Lines       18974    19080     +106     
==========================================
+ Hits         9826     9912      +86     
- Misses       8605     8618      +13     
- Partials      543      550       +7     
Flag Coverage Δ
unittests 51.94% <0.00%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/util/validation/validation.go 83.90% <0.00%> (-1.48%) ⬇️

... and 2 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Poor12
Copy link
Member

Poor12 commented Apr 21, 2023

/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 21, 2023
@karmada-bot karmada-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 23, 2023
@@ -59,6 +60,9 @@ func ValidateClusterAffinities(affinities []policyv1alpha1.ClusterAffinityTerm,

affinityNames := make(map[string]bool)
for index, term := range affinities {
for _, err := range validation.IsDNS1123Subdomain(term.AffinityName) {
allErrs = append(allErrs, field.Invalid(fldPath.Index(index), term.AffinityName, err))
Copy link
Member

Choose a reason for hiding this comment

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

I'm afraid RFC1123 Label Names is a little bit too strict, which only accepts lowercase alphanumeric characters.
@XiShanYongYe-Chang Please take a look.

To be honest, I really don't want to add such a restriction that we should do in the last release, for people already using this feature, it'd be a challenge to upgrade.

Copy link
Member

Choose a reason for hiding this comment

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

Compared to RFC1123 Label Names, how about the following?

https://github.com/kubernetes/kubernetes/blob/b1f901acf44f8adf69759db434690c2a8bdd616b/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L31-L34

const qnameCharFmt string = "[A-Za-z0-9]"
const qnameExtCharFmt string = "[-A-Za-z0-9_.]"
const qualifiedNameFmt string = "(" + qnameCharFmt + qnameExtCharFmt + "*)?" + qnameCharFmt
const qualifiedNameErrMsg string = "must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character"

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

Copy link
Member Author

Choose a reason for hiding this comment

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

/cc @RainbowMango @XiShanYongYe-Chang Please take a look.

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/assign
I will add it to my queue and will try to review it tomorrow.

Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

Thanks~
/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 24, 2023
Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/approve

I updated the release-note by the way.

@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RainbowMango

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

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 25, 2023
@karmada-bot karmada-bot merged commit 27862f7 into karmada-io:master Apr 25, 2023
@RainbowMango RainbowMango added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API and removed kind/bug Categorizes issue or PR as related to a bug. labels Apr 25, 2023
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. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

affinityName can be set to an empty string.
6 participants