-
Notifications
You must be signed in to change notification settings - Fork 725
add PodProtections for DefaultEvictorArgs #1665
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
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
a6656de
to
837a434
Compare
@@ -49,6 +49,9 @@ func SetDefaults_DefaultEvictorArgs(obj runtime.Object) { | |||
if args.PriorityThreshold == nil { | |||
args.PriorityThreshold = nil | |||
} | |||
if args.EvictionProtection == nil { | |||
args.EvictionProtection = nil | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this function ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh... This is also where I am confused. I just added it in the same way as before...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunate product of duplicating the no-op constructs.
fa6f9f0
to
93b0f88
Compare
README.md
Outdated
nodeFit: true | ||
minReplicas: 2 | ||
# List of disabled default pod protections. This allows users to selectively disable certain protection rules. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will recommend users to use the new config here
93b0f88
to
6813080
Compare
} | ||
|
||
if args.MinReplicas == 1 { | ||
klog.V(4).Info("DefaultEvictor minReplicas must be greater than 1 to check for min pods during eviction. This check will be ignored during eviction.") | ||
} | ||
|
||
// check if any deprecated fields are set to true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validate check here: We do not want users to mix old and new config. If any of the old config is true and there is a value in the new config list (including: DisabledDefaultPodProtections and ExtraPodProtections), it means that they are mixed and the validation fails.
6813080
to
cc5857d
Compare
cc5857d
to
baf046e
Compare
baf046e
to
11a8caf
Compare
frameworktypes "sigs.k8s.io/descheduler/pkg/framework/types" | ||
"sigs.k8s.io/descheduler/pkg/utils" | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think add new file constraints.go to be more clear
I hope we can reach an agreement and merge it into the master before the next release. 😄 |
|
||
// DisabledDefaultPodProtections is a list that specifies which default Pod protection mechanisms are disabled. | ||
// Users can selectively disable certain default protection rules via this field. | ||
DisabledDefaultPodProtections []DisabledDefaultPodProtection `json:"disabledDefaultPodProtections,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about to put the list of disabled and extra enabled policies under a single field? E.g.
# Pod anti-eviction/protection policies.
# The list of policies enabled by default:
# - protect pods with local storage, extend disabled with 'podsWithLocalStorage' to disable the protection
# - protect daemon set pods, extend disabled with `daemonSetPods` to disable the protection
# - ...
protectionPolicies:
# list of extra enabled policies
extraEnabled:
# list of disabled pod policies
disabled:
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a good suggestion
we can config like this:
- name: "DefaultEvictor"
args:
# Deprecated: Use `disabledDefaultPodProtections` with "systemCriticalPods" instead.
# evictSystemCriticalPods: true
# Deprecated: Use `disabledDefaultPodProtections` with "failedBarePods" instead.
# evictFailedBarePods: true
# Deprecated: Use `disabledDefaultPodProtections` with "withLocalStorage" instead.
# evictLocalStoragePods: true
nodeFit: true
minReplicas: 2
protectionPolicies:
extraEnabled:
- withPVC
- withoutPDB
# list of disabled pod policies
disabled:
- withLocalStorage
- systemCriticalPods
- failedBarePods
- daemonSetPods
|
||
// DisabledDefaultPodProtection defines the type for default Pod protection mechanisms. | ||
// Each value represents a specific protection rule that can be disabled. | ||
type DisabledDefaultPodProtection string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both DisabledDefaultPodProtection
and ExtraPodProtection
can be consolidated into a single type. E.g.
type PodProtectionPolicy string
const (
PodsWithLocalStorage PodProtectionPolicy = "podsWithLocalStorage"
DaemonSetPods PodProtectionPolicy = "daemonSetPods"
SystemCriticalPods PodProtectionPolicy = "systemCriticalPods"
FailedBarePods PodProtectionPolicy = "failedBarePods"
PodsWithPVC PodProtectionPolicy = "podsWithPVC"
PodsWithoutPDB PodProtectionPolicy = "podsWithoutPDB"
)
With some of the policies enabled by default. Other used for extra enabling or disabling. Also, would you please have defaults.go
set the default list of enabled policies too? E.g.
args.defaultPodProtectionPolicies = [PodsWithLocalStorage, DaemonSetPods, ...]
while extending the new private defaultPodProtectionPolicies
field with a comment saying the list of default policies is a subject to change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1664 (comment)
@ingvagabund
We have discussed why not to use the default value here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thinks this(set default value) will make the behavior incompatible with previous. I think using two types will not have any impact for user. It will also avoid coding errors of different strategies in the delegate (because we distinguish enable and disable as different types).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaultPodProtectionPolicies
is going to be a private variable only, not exposed to customers. Only for internal use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got this
e4d12bc
to
d3ce730
Compare
} | ||
|
||
// PodProtectionPolicy defines the protection policy for a pod. | ||
type PodProtectionPolicy string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to one type and use ExtraEnabled Disabled to decide
if uint(len(objs)) < defaultEvictorArgs.MinReplicas { | ||
return fmt.Errorf("owner has %d replicas which is less than minReplicas of %d", len(objs), defaultEvictorArgs.MinReplicas) | ||
} | ||
if !useNewConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are here to maintain compatibility with the old config logic.
d3ce730
to
478a67e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make the review and refactoring easier to follow would you please move the changes in constaints.go into a separate PR? Without introducing the pod protection policy. Just to refactor the code is it's easier to introduce the pod protection policies later.
// It supports both new-style (PodProtectionPolicies) and legacy-style flags. | ||
func getEffectiveProtectedPolicies(args *DefaultEvictorArgs) []PodProtectionPolicy { | ||
if args.defaultPodProtectionPolicies == nil { | ||
args.defaultPodProtectionPolicies = BuiltInPodProtectionPolicies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaultPodProtectionPolicies
is used only for internal purposes so the same list of default policies does not have to be duplicated. If you plan to define BuiltInPodProtectionPolicies
as well the new variable can be used instead of the internal defaultPodProtectionPolicies
field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed BuiltInPodProtectionPolicies
I think we just use defaultPodProtectionPolicies
is enough 🤔
478a67e
to
0b33128
Compare
0b33128
to
cfd5c26
Compare
12f11a2
to
bd0d074
Compare
| `ignorePodsWithoutPDB` |`bool`|`false`| set whether pods without PodDisruptionBudget should be evicted or ignored | | ||
|
||
### Example policy | ||
| Name | Type | Default Value | Description | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the delays. I will not be able to finish the review. I am leaving for a vacation until June 8. I will resume once I am back. |
Signed-off-by: googs1025 <[email protected]>
bd0d074
to
09c9970
Compare
fix: #1664