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

Introduced a lazy activation preference to PropagationPolicy/ClusterPropagationPolicy #4577

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

chaosi-zju
Copy link
Member

@chaosi-zju chaosi-zju commented Jan 24, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

Introduced a lazy activation preference to PropagationPolicy/ClusterPropagationPolicy.

ActivationPreference indicates how the referencing resource template will be propagated, in case of policy changes.

If empty, the resource template will respond to policy changes immediately, in other words, any policy changes will drive the resource template to be propagated immediately as per the current propagation rules.

If the value is 'Lazy' means the policy changes will not take effect for now but defer to the resource template changes, in other words, the resource template will not be propagated as per the current propagation rules until there is an update on it.

This is an experimental feature that might help in a scenario where a policy manages huge amount of resource templates, changes to a policy typically affect numerous applications simultaneously. A minor misconfiguration could lead to widespread failures. With this feature, the change can be gradually rolled out through iterative modifications of resource templates.

More info refer to #4563

Which issue(s) this PR fixes:

Fixes part of #4563

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Introduced a lazy activation preference to PropagationPolicy/ClusterPropagationPolicy.

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Jan 24, 2024
@chaosi-zju
Copy link
Member Author

@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 24, 2024
@chaosi-zju chaosi-zju force-pushed the policy5 branch 5 times, most recently from 5f670d7 to 6ee6598 Compare January 24, 2024 12:04
@codecov-commenter
Copy link

codecov-commenter commented Jan 24, 2024

Codecov Report

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

Comparison is base (f054313) 51.89% compared to head (926e34a) 51.69%.
Report is 10 commits behind head on master.

Files Patch % Lines
pkg/detector/detector.go 0.00% 43 Missing ⚠️
pkg/util/eventfilter/eventfilter.go 9.75% 37 Missing ⚠️
pkg/detector/handler.go 0.00% 14 Missing ⚠️
pkg/detector/policy.go 0.00% 9 Missing ⚠️
pkg/util/policy.go 0.00% 5 Missing ⚠️
pkg/util/fedinformer/keys/keys.go 0.00% 2 Missing ⚠️
pkg/util/fedinformer/handlers.go 0.00% 1 Missing ⚠️
pkg/util/worker.go 50.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4577      +/-   ##
==========================================
- Coverage   51.89%   51.69%   -0.21%     
==========================================
  Files         246      247       +1     
  Lines       24328    24418      +90     
==========================================
- Hits        12626    12623       -3     
- Misses      11016    11107      +91     
- Partials      686      688       +2     
Flag Coverage Δ
unittests 51.69% <4.27%> (-0.21%) ⬇️

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

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

pkg/apis/policy/v1alpha1/propagation_types.go Outdated Show resolved Hide resolved
pkg/apis/policy/v1alpha1/propagation_types.go Outdated Show resolved Hide resolved
pkg/apis/policy/v1alpha1/propagation_types.go Outdated Show resolved Hide resolved
@chaosi-zju chaosi-zju force-pushed the policy5 branch 2 times, most recently from 523bdd5 to b6ac7e3 Compare January 24, 2024 15:49
@chaosi-zju chaosi-zju force-pushed the policy5 branch 4 times, most recently from 205c5e5 to 73b77ae Compare January 25, 2024 11:53
Signed-off-by: chaosi-zju <chaosi@zju.edu.cn>
@chaosi-zju chaosi-zju changed the title Introduced a delay activation strategy to PropagationPolicy/ClusterPropagationPolicy. Introduced a lazy activation preference to PropagationPolicy/ClusterPropagationPolicy Jan 25, 2024
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.

/lgtm
/approve

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 25, 2024
@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 Jan 25, 2024
@karmada-bot karmada-bot merged commit ae5b3fe into karmada-io:master Jan 25, 2024
13 checks passed
@chaunceyjiang
Copy link
Member

I found that deployment behaves differently from configMap. When I use the following PP, the deployment can propagate to member clusters, but the configMap cannot.

Note: Only apply this file.

apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: nginx-propagation
spec:
  activationPreference: Lazy
  resourceSelectors:
    - apiVersion: apps/v1
      kind: Deployment
      name: nginx
    - apiVersion: v1
      kind: ConfigMap
      name: game-demo
  placement:
    clusterAffinity:
      clusterNames:
        - member1
        - member2
    replicaScheduling:
      replicaDivisionPreference: Weighted
      replicaSchedulingType: Divided
      weightPreference:
        staticWeightList:
          - targetCluster:
              clusterNames:
                - member1
            weight: 1
          - targetCluster:
              clusterNames:
                - member2
            weight: 1
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: game-demo
data:
  # property-like keys; each key maps to a simple value
  player_initial_lives: "3"
  ui_properties_file_name: "user-interface.properties"

  # file-like keys
  game.properties: |
    enemy.types=aliens,monsters
    player.maximum-lives=5
  user-interface.properties: |
    color.good=purple
    color.bad=yellow
    allow.textmode=true
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx
        name: nginx

@chaosi-zju
Copy link
Member Author

I found that deployment behaves differently from configMap. When I use the following PP, the deployment can propagate to member clusters, but the configMap cannot.

I think this may because the detail resource applied in order, just like: configmap --> pp --> deploy

our principle is creation/updation/deletion of pp shouldn't actively triggle the propagation change of the resource. So:

If the resource create before pp, after pp created, the resource keep unchanged.

If the pp create before resource, after resource created, the resource propagated by the pp.

@chaosi-zju
Copy link
Member Author

I found that deployment behaves differently from configMap. When I use the following PP, the deployment can propagate to member clusters, but the configMap cannot.

If you use Lazy policy, you should understand PropagationPolicy is a preconfigured policy.

If the pp and resource are all not exist, you should apply pp first, then to apply resource.

@chaunceyjiang
Copy link
Member

you should apply pp first, then to apply resource.

So, I think this is the issue, it requires users to perceive the apply order forcibly. Obviously, in a real-world environment, it's hard for us to determine the create order of users.

@chaosi-zju
Copy link
Member Author

chaosi-zju commented Jan 26, 2024

you should apply pp first, then to apply resource.

So, I think this is the issue, it requires users to perceive the apply order forcibly. Obviously, in a real-world environment, it's hard for us to determine the create order of users.

yes, lazy policy should apply before resource.

when lazy policy created, it will not triggle resource in waiting list to refresh binding (it only triggle ClaimPolicyForObject to establish boundge relationship, but not triggle CreateOrUpdateResourceBinding) (it seems that you want it do this)

resource in waiting list can also has ResourceBiding and Work, the related pods running just fine, creation of lazy policy shouldn't change its propagation states.

@chaunceyjiang
Copy link
Member

yes, lazy policy should apply before resource.

It's really difficult for users.

@chaosi-zju
Copy link
Member Author

It's really difficult for users.

Is there a compromise?

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/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.

5 participants