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

Response to priority change of PropagationPolicy #3965

Merged
merged 1 commit into from
Aug 23, 2023

Conversation

RainbowMango
Copy link
Member

@RainbowMango RainbowMango commented Aug 21, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR provides a temporary solution for corner case:

After the priority(.spec.priority) of PropagationPolicy changed from high priority (e.g. 5) to 
low priority(e.g. 3), we should try to check if there is a PropagationPolicy(e.g. with priority 4) 
that could preempt the targeted resources.

Which issue(s) this PR fixes:
Fixes #
Part of #3787

Special notes for your reviewer:
See #3684 (comment) for the background discussion.

In addition, this PR focuses on dealing with PropagationPolicy, if it is acceptable, the ClusterPropagationPolicy should do a similar thing.

Test steps:

  1. Apply two policies (foo with priority 5 and bar with priority 4) as follows
apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: foo
spec:
  priority: 5
  preemption: Always
  resourceSelectors:
    - apiVersion: apps/v1
      kind: Deployment
      name: nginx
  placement:
    clusterAffinity:
      clusterNames:
        - member1
---
apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: bar
spec:
  priority: 4
  preemption: Always
  resourceSelectors:
    - apiVersion: apps/v1
      kind: Deployment
      name: nginx
  placement:
    clusterAffinity:
      clusterNames:
        - member2
  1. Apply a Deployment as this sample.
kubectl apply -f samples/nginx/deployment.yaml
  1. The Deployment should be propagated by foo as it has higher priority
apiVersion: apps/v1
kind: Deployment
metadata:
  generation: 1
  labels:
    app: nginx
    propagationpolicy.karmada.io/name: foo
    propagationpolicy.karmada.io/namespace: default
  name: nginx
  1. Update the priority of foo from 5 to 3, then the Deployment should be preempted by bar.
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: nginx
    propagationpolicy.karmada.io/name: bar
    propagationpolicy.karmada.io/namespace: default

meanwhile, I can see the relevant logs:

I0821 13:28:39.213404       1 preemption.go:263] Enqueuing PropagationPolicy(default/bar) in case of PropagationPolicy(default/foo) priority changes
...
I0821 13:28:39.226380       1 preemption.go:127] Propagation policy(default/bar) has preempted another propagation policy(default/foo).

Does this PR introduce a user-facing change?:

NONE(Part of feature #3787)

@karmada-bot karmada-bot added kind/feature Categorizes issue or PR as related to a new feature. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 21, 2023
@RainbowMango RainbowMango added this to the v1.7 milestone Aug 21, 2023
@codecov-commenter
Copy link

Codecov Report

Merging #3965 (90898e2) into master (5f16640) will decrease coverage by 0.16%.
Report is 4 commits behind head on master.
The diff coverage is 0.00%.

❗ 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    #3965      +/-   ##
==========================================
- Coverage   54.66%   54.50%   -0.16%     
==========================================
  Files         232      232              
  Lines       22521    22585      +64     
==========================================
- Hits        12311    12310       -1     
- Misses       9537     9602      +65     
  Partials      673      673              
Flag Coverage Δ
unittests 54.50% <0.00%> (-0.16%) ⬇️

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

Files Changed Coverage Δ
pkg/detector/detector.go 0.00% <0.00%> (ø)
pkg/detector/preemption.go 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

pkg/detector/preemption.go Outdated Show resolved Hide resolved
pkg/detector/preemption.go Outdated Show resolved Hide resolved
and enqueue PropagationPolicy that could repreempte.

Signed-off-by: RainbowMango <qdurenhongcai@gmail.com>
@RainbowMango
Copy link
Member Author

@wuyingjun-lucky Do you have any comments? I see you are looking at it :)

//
// The idea of the long-term solution, perhaps PropagationPolicy could have
// a status, in that case we can record the observed priority(.status.observedPriority)
// which can be used to detect priority changes during reconcile logic.
Copy link
Member

Choose a reason for hiding this comment

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

it's a good idea.

@wuyingjun-lucky
Copy link
Member

LGTM and I want have a try on “multiple preemption”

@RainbowMango
Copy link
Member Author

LGTM and I want have a try on “multiple preemption”

No, you don't, haha, that's a chaotic state(but will stabilize eventually.)

@whitewindmills
Copy link
Member

/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 23, 2023
@RainbowMango RainbowMango added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 23, 2023
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

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 merged commit c3bc284 into karmada-io:master Aug 23, 2023
12 checks passed
@RainbowMango RainbowMango deleted the pr_preemtion_depriority branch August 24, 2023 01:46
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/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. 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.

None yet

6 participants