-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Propagate NodeSelector and Tolerations to Affinity Assistant #2743
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
Merged
tekton-robot
merged 1 commit into
tektoncd:master
from
jlpettersson:propagate_nodeselector_and_tolerations_to_affinity-assistant
Jun 3, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,13 +209,15 @@ The `subPath` specified in a `Pipeline` will be appended to any `subPath` specif | |
|
||
Sharing a `Workspace` between `Tasks` requires you to define the order in which those `Tasks` | ||
write to or read from that `Workspace`. Use the `runAfter` field in your `Pipeline` definition | ||
to define when a `Task` should be executed. For more information, see the [`runAfter` documentation](pipelines.md#runAfter). | ||
to define when a `Task` should be executed. For more information, see the [`runAfter` documentation](pipelines.md#using-the-runafter-parameter). | ||
|
||
When a `PersistentVolumeClaim` is used as volume source for a `Workspace` in a `PipelineRun`, | ||
an Affinity Assistant will be created. The Affinity Assistant acts as a placeholder for `TaskRun` pods | ||
sharing the same `Workspace`. All `TaskRun` pods within the `PipelineRun` that share the `Workspace` | ||
will be scheduled to the same Node as the Affinity Assistant pod. This means that Affinity Assistant is incompatible | ||
with e.g. NodeSelectors or other affinity rules configured for the `TaskRun` pods. The Affinity Assistant | ||
with e.g. other affinity rules configured for the `TaskRun` pods. If the `PipepineRun` has a custom | ||
[PodTemplate](pipelineruns.md#specifying-a-pod-template) configured, the `NodeSelector` and `Tolerations` fields | ||
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. thanks! |
||
will also be set on the Affinity Assistant pod. The Affinity Assistant | ||
is deleted when the `PipelineRun` is completed. The Affinity Assistant can be disabled by setting the | ||
[disable-affinity-assistant](install.md#customizing-basic-execution-parameters) feature gate. | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,58 @@ func TestCreateAndDeleteOfAffinityAssistant(t *testing.T) { | |
} | ||
} | ||
|
||
func TestThatCustomTolerationsAndNodeSelectorArePropagatedToAffinityAssistant(t *testing.T) { | ||
prWithCustomPodTemplate := &v1beta1.PipelineRun{ | ||
TypeMeta: metav1.TypeMeta{Kind: "PipelineRun"}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "pipelinerun-with-custom-podtemplate", | ||
}, | ||
Spec: v1beta1.PipelineRunSpec{ | ||
PodTemplate: &v1beta1.PodTemplate{ | ||
Tolerations: []corev1.Toleration{{ | ||
Key: "key", | ||
Operator: "Equal", | ||
Value: "value", | ||
Effect: "NoSchedule", | ||
}}, | ||
NodeSelector: map[string]string{ | ||
"disktype": "ssd", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
stsWithTolerationsAndNodeSelector := affinityAssistantStatefulSet("test-assistant", prWithCustomPodTemplate, "mypvc") | ||
|
||
if len(stsWithTolerationsAndNodeSelector.Spec.Template.Spec.Tolerations) != 1 { | ||
t.Errorf("expected Tolerations in the StatefulSet") | ||
} | ||
|
||
if len(stsWithTolerationsAndNodeSelector.Spec.Template.Spec.NodeSelector) != 1 { | ||
t.Errorf("expected a NodeSelector in the StatefulSet") | ||
} | ||
} | ||
|
||
func TestThatTheAffinityAssistantIsWithoutNodeSelectorAndTolerations(t *testing.T) { | ||
prWithoutCustomPodTemplate := &v1beta1.PipelineRun{ | ||
TypeMeta: metav1.TypeMeta{Kind: "PipelineRun"}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "pipelinerun-without-custom-podtemplate", | ||
}, | ||
Spec: v1beta1.PipelineRunSpec{}, | ||
} | ||
|
||
stsWithoutTolerationsAndNodeSelector := affinityAssistantStatefulSet("test-assistant", prWithoutCustomPodTemplate, "mypvc") | ||
|
||
if len(stsWithoutTolerationsAndNodeSelector.Spec.Template.Spec.Tolerations) != 0 { | ||
t.Errorf("unexpected Tolerations in the StatefulSet") | ||
} | ||
|
||
if len(stsWithoutTolerationsAndNodeSelector.Spec.Template.Spec.NodeSelector) != 0 { | ||
t.Errorf("unexpected NodeSelector in the StatefulSet") | ||
} | ||
} | ||
|
||
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. 🎉 thanks for redoing these twice 🙏 |
||
func TestDisableAffinityAssistant(t *testing.T) { | ||
for _, tc := range []struct { | ||
description string | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.