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

Disable a single resource multi dependency distribution #5743

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

XiShanYongYe-Chang
Copy link
Member

What type of PR is this?

/kind feature

What this PR does / why we need it:

From the majority of user feedback received so far, there are no scenarios where a single resource is depended on by multiple resources, or where a resource is both depended on by other resources and also distributed through PropagationPolicy/ClusterPropagationPolicy. Therefore, we have decided to restrict the above usage in the Karmada system, with the ultimate goal of ensuring that a resource can only be subject to distribution decisions by one PropagationPolicy/ClusterPropagationPolicy.

By imposing such a restriction, we can make the behavior of the Karmada system more explicit and also facilitate the iteration of the follow-on distribution feature.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

The current PR is far from the end. In order to complete the entire restriction activity, I plan to carry out the following tasks:

  1. Add events for the target resources to describe the restriction operations performed by the Karmada system.
  2. In the next version (v1.13), deprecate the DisableMultiDependencyDistribution switch and clean up the existing code, no longer considering the situation where a resource is depended on by multiple resources. For example, labels with the prefix resourcebinding.karmada.io/depended-by- will be deprecated.
  3. Optimize the restriction logic so that when a resource is depended on by another resource and an attachedBinding is generated, an annotation or label is added to the resource to record its depender, thus avoiding the need to query the corresponding resourceBinding object during restriction judgment. Additionally, this information may also be processed through karmadactl for further extensions.

Does this PR introduce a user-facing change?:

karmada-controller-manager: disable a single resource multi dependency distribution

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Oct 25, 2024
@XiShanYongYe-Chang
Copy link
Member Author

/cc @RainbowMango @chaosi-zju

@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 25, 2024
@codecov-commenter
Copy link

codecov-commenter commented Oct 25, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 2.24719% with 87 lines in your changes missing coverage. Please review.

Project coverage is 42.20%. Comparing base (e90ff63) to head (b5e0c44).

Files with missing lines Patch % Lines
...ependenciesdistributor/dependencies_distributor.go 4.16% 43 Missing and 3 partials ⚠️
pkg/detector/detector.go 0.00% 29 Missing ⚠️
cmd/controller-manager/app/controllermanager.go 0.00% 9 Missing ⚠️
cmd/controller-manager/app/options/options.go 0.00% 3 Missing ⚠️

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5743      +/-   ##
==========================================
- Coverage   42.25%   42.20%   -0.06%     
==========================================
  Files         655      655              
  Lines       55847    55928      +81     
==========================================
+ Hits        23600    23602       +2     
- Misses      30734    30811      +77     
- Partials     1513     1515       +2     
Flag Coverage Δ
unittests 42.20% <2.24%> (-0.06%) ⬇️

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.

return err
}

if d.DisableMultiDependencyDistribution {
Copy link
Member

Choose a reason for hiding this comment

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

Can you remind me what situation this logic is handling?

Copy link
Member Author

Choose a reason for hiding this comment

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

A parameter is added to determine whether the Karmada system allows the same resource to be dependent on different resources. By default, the value is true, indicating that multiple dependencies will be prohibited in future evolution, including that a resource is processed by the PropagationPolicy and distributed along with the resource.

Copy link
Member

Choose a reason for hiding this comment

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

I understand the purpose of your DisableMultiDependencyDistribution parameter. But I haven't grasped what the code you wrote in the detector is meant to handle.

Looking at the e2e scenario, this code seems to be breaking compatibility.

Copy link
Member Author

Choose a reason for hiding this comment

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

But I haven't grasped what the code you wrote in the detector is meant to handle.

The logic of this code is incorrect. I will correct it later.

Looking at the e2e scenario, this code seems to be breaking compatibility.

When DisableMultiDependencyDistribution is false, it adds some restrictions, and it really can be understood as break change.
When DisableMultiDependencyDistribution is true, it keeps the original behavior.

Copy link
Member

Choose a reason for hiding this comment

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

Please rebase and fix the failing tests.

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

Comment on lines +146 to +156

// DisableMultiDependencyDistribution indicates disable the ability to a resource from being depended on by multiple
// resources or being distributed by PropagationPolicy/ClusterPropagationPolicy while being depended on.
//
// Before v1.12, this capability is allowed by default. If you still wish to enable this capability, you can set
// this flag to false. However, you will need to bear some side effects that come with it.
// For example, you can refer to https://github.com/karmada-io/karmada/pull/5717. When the primary resource is deleted,
// it does not consider other resources that currently depend on the resource or any PropagationPolicy associated with it.
//
// It is recommended that you adapt your business accordingly to avoid continued use.
DisableMultiDependencyDistribution bool
Copy link
Member

@RainbowMango RainbowMango Nov 4, 2024

Choose a reason for hiding this comment

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

Would it be better to have a feature gate than a command flag? Something like: DisableDependencySharing.
For example:

  • release-1.12 starts from alpha, which is disabled by default, for backward compatibility concerns.
  • release-1.13 move to beta, which is enabled by default, and allows people to disable it as an escape hatch
  • release-1.14 move to stable, enabled by default, and don't allow to disable it.

@XiShanYongYe-Chang @chaunceyjiang What do you think?

@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from rainbowmango. For more information see the Kubernetes Code Review Process.

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

@XiShanYongYe-Chang
Copy link
Member Author

/retest

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.

5 participants