-
Notifications
You must be signed in to change notification settings - Fork 710
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
Perform a scheduling simulation in dry-run mode. #1585
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,10 @@ import ( | |
"sigs.k8s.io/descheduler/pkg/utils" | ||
) | ||
|
||
const workersCount = 100 | ||
const ( | ||
workersCount = 100 | ||
FitNodeToPodAnnotationKey = "descheduler.alpha.kubernetes.io/fit-node-name" | ||
) | ||
|
||
// ReadyNodes returns ready nodes irrespective of whether they are | ||
// schedulable or not. | ||
|
@@ -161,6 +164,7 @@ func podFitsNodes(nodeIndexer podutil.GetPodsAssignedToNodeFunc, pod *v1.Pod, no | |
if err == nil { | ||
klog.V(4).InfoS("Pod fits on node", "pod", klog.KObj(pod), "node", klog.KObj(node)) | ||
atomic.AddInt32(&filteredLen, 1) | ||
addFitNodeNameToPod(pod, node) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we going to label all pods, whether they are dry-run or non-dry-run, with this label? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be ideal if this behavior only occurred during dry-run and if it could pass the nodename without setting it as an annotation. However, I haven't figured out how to implement this yet. If this approach is accepted, we can give it a try. |
||
cancel() | ||
} else { | ||
klog.V(4).InfoS("Pod does not fit on node", "pod", klog.KObj(pod), "node", klog.KObj(node), "err", err.Error()) | ||
|
@@ -173,6 +177,14 @@ func podFitsNodes(nodeIndexer podutil.GetPodsAssignedToNodeFunc, pod *v1.Pod, no | |
return filteredLen > 0 | ||
} | ||
|
||
func addFitNodeNameToPod(pod *v1.Pod, node *v1.Node) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding a fit node to the pod's annotation is not the most appropriate best practice. It seems more reasonable to add a return value to |
||
if pod.Annotations != nil { | ||
pod.Annotations[FitNodeToPodAnnotationKey] = node.Name | ||
} else { | ||
pod.Annotations = map[string]string{FitNodeToPodAnnotationKey: node.Name} | ||
} | ||
} | ||
|
||
// PodFitsAnyOtherNode checks if the given pod will fit any of the given nodes, besides the node | ||
// the pod is already running on. The predicates used to determine if the pod will fit can be found in the NodeFit function. | ||
func PodFitsAnyOtherNode(nodeIndexer podutil.GetPodsAssignedToNodeFunc, pod *v1.Pod, nodes []*v1.Node) bool { | ||
|
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 don't quite understand why we need to create a pod in dry run mode. The purpose of dry run mode is to simulate the behavior of Descheduler to preview which pods may be evicted. 🤔
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.
see comments:#1584 (comment)
The purpose is to reserve the resources.
If any part is not described clearly, please feel free to comment.
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. thanks