pipeline icon indicating copy to clipboard operation
pipeline copied to clipboard

PipelineRun 's PodTemplate support affinity

Open lookis opened this issue 2 years ago • 7 comments

Feature request

currently, PipelineRun support PodTemplate only three feature: tolerations, nodeSelector, and imagePullSecrets. and I would like to see affinity be supported.

Use case

In my case, I prefer all the task running on the high performance node which I will label it. but PipelineRun scheduler doesn't support affinity.nodeAffinity.

and I cannot guarantee the high performance node will avalible all the time, so nodeSelector makes assumption too strong.

lookis avatar Jul 30 '22 03:07 lookis

/assign

yuzp1996 avatar Aug 01 '22 08:08 yuzp1996

any update? @yuzp1996

lookis avatar Aug 08 '22 12:08 lookis

any update? @yuzp1996

Hi! I will start working on this issue today.

yuzp1996 avatar Aug 10 '22 03:08 yuzp1996

Hi @lookis, Podtemplate supports affinity now. This document podtemplates could help you.

But if your PipelineRun contains PVC then affinity will be overwritten by affinity-assistant. https://github.com/tektoncd/pipeline/blob/55f044161a68d1ce7d7a07df4fa7cf6be10eafd5/pkg/internal/affinityassistant/transformer.go#L29

I tried and find two solutions to avoid being overwritten by affinity-assistant.

  1. delete PVC in your pipelinerun
  2. disable affinity-assistant by setting feature-flag disable-affinity-assistant to be true image

yuzp1996 avatar Aug 10 '22 10:08 yuzp1996

@lookis For more information about Affinity Assistant, you can refer to this document https://tekton.dev/vault/pipelines-v0.16.3/workspaces/#specifying-workspace-order-in-a-pipeline-and-affinity-assistants.

yuzp1996 avatar Aug 10 '22 10:08 yuzp1996

@yuzp1996 I think it would be better to merge two configurations, that's what nodeAffinity.weight for.

It's no reason for pvc case not to prefer a better node, thought it may failed, that's why it's nodeAffinity rather than nodeSelector

lookis avatar Aug 10 '22 10:08 lookis

@lookis Yes, I agree with you that merging the two configurations is the better approach. I made changes in my dev environment and tested some simple cases and everything seems to be working fine. Maybe tomorrow I will create the PullRequest because I need to add some unit tests and test some more complex cases.

yuzp1996 avatar Aug 10 '22 14:08 yuzp1996

PR https://github.com/tektoncd/pipeline/pull/5306 has merged /close

yuzp1996 avatar Sep 09 '22 07:09 yuzp1996

@yuzp1996: You can't close an active issue/PR unless you authored it or you are a collaborator.

In response to this:

PR https://github.com/tektoncd/pipeline/pull/5306 has merged /close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

tekton-robot avatar Sep 09 '22 07:09 tekton-robot

Thx for the PR.

lookis avatar Sep 09 '22 07:09 lookis