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

Support namespace to use regexp for resourceSelector of cpp and cop #3656

Closed
wants to merge 1 commit into from

Conversation

Poor12
Copy link
Member

@Poor12 Poor12 commented Jun 8, 2023

What type of PR is this?
/kind feature

What this PR does / why we need it:
For cpp and cop, we expect resourceSelectors can hit multiple namespaces with the similar format, otherwise we may need to edit cpp and cop when we add a new namespace.

Assume that there is a use case that all business departments are registered to Karmada uniformly and isolated through different namespaces. It is agreed to use the format of "test-xxx" uniformly. Now they have registered two departments and have a global cpp to propagate their applications. Once they add a new department, they do not want to edit the cpp because they may cause rescheduling of applications.

In that case, the following config may help.

spec:
    resourceSelectors:
    - apiVersion: apps/v1
      kind: Deployment
      Namespace: test-.*
      Name: test

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

ClusterPropagationPolicy/ClusterOverridePolicy: Support namespace to use regexp for resourceSelector.
karmada-webhook: validate that namespace of resourceSelector must be the same as that of pp/op.

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Jun 8, 2023
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign kevin-wangzefeng after the PR has been reviewed.
You can assign the PR to them by writing /assign @kevin-wangzefeng in a comment when ready.

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

@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 8, 2023
@Poor12 Poor12 changed the title Support regex format for namespace of cpp and cop Support namespace to use regexp for resourceSelector of cpp and cop Jun 8, 2023
@Poor12
Copy link
Member Author

Poor12 commented Jun 20, 2023

e2e failed by occasional failure(setup e2e environment failed).
/cc @RainbowMango to help rerun it.

@RainbowMango
Copy link
Member

This issue is tracked by

https://github.com/karmada-io/karmada/actions/runs/5211054867/jobs/9403105260?pr=3656

Waiting for kubeconfig file /home/runner/.kube/members.config and clusters member3 to be ready...
Waiting for running............................................................................................................................................................................................................................................................................................................
Error:  Timeout waiting for condition running

@Poor12 Poor12 force-pushed the support-regex branch 2 times, most recently from 04fe1d0 to a3417ac Compare June 20, 2023 09:50
@codecov-commenter
Copy link

codecov-commenter commented Jun 20, 2023

Codecov Report

Merging #3656 (3327c85) into master (c39856b) will increase coverage by 0.00%.
The diff coverage is 58.33%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@           Coverage Diff           @@
##           master    #3656   +/-   ##
=======================================
  Coverage   55.69%   55.69%           
=======================================
  Files         222      222           
  Lines       21195    21218   +23     
=======================================
+ Hits        11805    11818   +13     
- Misses       8763     8771    +8     
- Partials      627      629    +2     
Flag Coverage Δ
unittests 55.69% <58.33%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
pkg/util/validation/validation.go 81.81% <45.45%> (-2.28%) ⬇️
pkg/util/selector.go 95.91% <69.23%> (-4.09%) ⬇️

Copy link
Member

@chaunceyjiang chaunceyjiang left a comment

Choose a reason for hiding this comment

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

LGTM

@Poor12
Copy link
Member Author

Poor12 commented Jun 28, 2023

/cc @RainbowMango @GitHubxsy who may be interested in this feature.

@GitHubxsy
Copy link
Contributor

Very nice feature

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.

Please fix the failing CI. I'll take a look later.

Signed-off-by: Poor12 <shentiecheng@huawei.com>
@RainbowMango
Copy link
Member

RainbowMango commented Aug 1, 2023

Just realized, that this approach might conflict with the PropagationPolicy Preemption feature:

we narrow down the scope of preemption by introducing a restriction: for pp, the name in ResourceSelector must be specified; for cpp, the namespace/name for namespace-scoped resources and the name for cluster-scoped resources must be specific.

My concern is we can't figure out if the namespace is a regexp or a concrete namespace.

@Poor12
Copy link
Member Author

Poor12 commented Aug 2, 2023

I got it. One option is that we can ensure that these two features won't be enabled in the meanwhile. I am not sure whether there are many resources with the same name and different ns.

@RainbowMango RainbowMango removed this from the v1.7 milestone Aug 25, 2023
@RainbowMango
Copy link
Member

I'm trying to figure out which PR/Issue should be included in the coming v1.7 release which is planned at the end of this month.

From an API perspective, I think each field should have clear meanings, otherwise, we might face challenges for both users and implementations.
So, I guess we can postpone this until there is a clear use case and an improved solution.
/close

@karmada-bot
Copy link
Collaborator

@RainbowMango: Closed this PR.

In response to this:

I'm trying to figure out which PR/Issue should be included in the coming v1.7 release which is planned at the end of this month.

From an API perspective, I think each field should have clear meanings, otherwise, we might face challenges for both users and implementations.
So, I guess we can postpone this until there is a clear use case and an improved solution.
/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. 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.

None yet

6 participants