mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-04 21:32:39 +08:00
Adding flag to decide when to add pod affinity.
- This avoids adding it every time the loop finds a nodeSelector that's not nil in a template
This commit is contained in:
@@ -364,7 +364,7 @@ func (c *Client) createWorkflow(namespace string, workflowTemplateID uint64, wor
|
|||||||
func ensureWorkflowRunsOnDedicatedNode(wf *wfv1.Workflow, config SystemConfig) (*wfv1.Workflow, error) {
|
func ensureWorkflowRunsOnDedicatedNode(wf *wfv1.Workflow, config SystemConfig) (*wfv1.Workflow, error) {
|
||||||
antiAffinityLabelKey := "onepanel.io/reserves-instance-type"
|
antiAffinityLabelKey := "onepanel.io/reserves-instance-type"
|
||||||
nodeSelectorVal := ""
|
nodeSelectorVal := ""
|
||||||
|
addPodAffinity := false
|
||||||
for i := range wf.Spec.Templates {
|
for i := range wf.Spec.Templates {
|
||||||
template := &wf.Spec.Templates[i]
|
template := &wf.Spec.Templates[i]
|
||||||
if template.NodeSelector == nil {
|
if template.NodeSelector == nil {
|
||||||
@@ -392,6 +392,9 @@ func ensureWorkflowRunsOnDedicatedNode(wf *wfv1.Workflow, config SystemConfig) (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
template.Metadata.Labels = map[string]string{antiAffinityLabelKey: nodeSelectorVal}
|
template.Metadata.Labels = map[string]string{antiAffinityLabelKey: nodeSelectorVal}
|
||||||
|
addPodAffinity = true
|
||||||
|
}
|
||||||
|
if addPodAffinity {
|
||||||
wf.Spec.Affinity = &corev1.Affinity{
|
wf.Spec.Affinity = &corev1.Affinity{
|
||||||
PodAntiAffinity: &corev1.PodAntiAffinity{
|
PodAntiAffinity: &corev1.PodAntiAffinity{
|
||||||
RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
|
RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
|
||||||
|
Reference in New Issue
Block a user