Skip to content

Commit d16f6d0

Browse files
authored
Merge pull request #798 from MetaCell/feature/CH-182
CH-182 add default toleration to all workflows
2 parents 06ad701 + 6b73522 commit d16f6d0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

libraries/cloudharness-common/cloudharness/workflows/operations.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from collections.abc import Iterable
33
from typing import List, Union
44

5+
import argo.workflows
6+
import argo.workflows.client
57
import yaml
68

79
from cloudharness import log
@@ -10,6 +12,7 @@
1012
from . import argo
1113
from .tasks import Task, SendResultTask, CustomTask
1214
from .utils import PodExecutionContext, affinity_spec, is_accounts_present, name_from_path, volume_mount_template
15+
from argo.workflows.client import V1Toleration
1316

1417
POLLING_WAIT_SECONDS = 1
1518
SERVICE_ACCOUNT = 'argo-workflows'
@@ -120,6 +123,7 @@ def spec(self):
120123
'entrypoint': self.entrypoint,
121124
'ttlStrategy': self.ttl_strategy,
122125
'templates': [self.modify_template(template) for template in self.templates],
126+
'tolerations': [V1Toleration(key='cloudharness/temporary-job', operator='Equal', value='true').to_dict()],
123127
'serviceAccountName': SERVICE_ACCOUNT,
124128
'imagePullSecrets': [{'name': config.CloudharnessConfig.get_registry_secret()}],
125129
'volumes': [{

libraries/cloudharness-common/tests/test_workflow.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ def test_single_task_shared():
122122
accounts_offset = 1 if is_accounts_present() else 0
123123
assert len(op.volumes) == 1
124124
assert len(wf['spec']['volumes']) == 2 + accounts_offset
125+
assert wf['spec']['tolerations'], "Tolerations should be added to the workflow"
126+
assert wf['spec']['tolerations'][0]['key'] == 'cloudharness/temporary-job'
127+
assert wf['spec']['tolerations'][0]['operator'] == 'Equal'
128+
assert wf['spec']['tolerations'][0]['value'] == 'true'
125129
assert wf['spec']['volumes'][1 + accounts_offset]['persistentVolumeClaim']['claimName'] == 'myclaim'
126130
if accounts_offset == 1:
127131
assert wf['spec']['volumes'][1]['secret']['secretName'] == 'accounts'

0 commit comments

Comments
 (0)