Skip to content
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

Add resource op owner reference mapping #922

Merged
merged 1 commit into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sdk/python/kfp_tekton/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,13 +775,16 @@ def _process_resourceOp(self, task_refs, pipeline):
merge_strategy = op.resource.get('merge_strategy')
success_condition = op.resource.get('successCondition')
failure_condition = op.resource.get('failureCondition')
set_owner_reference = op.resource.get('setOwnerReference')
task['params'] = [tp for tp in task.get('params', []) if tp.get('name') != "image"]
if not merge_strategy:
task['params'] = [tp for tp in task.get('params', []) if tp.get('name') != 'merge-strategy']
if not success_condition:
task['params'] = [tp for tp in task.get('params', []) if tp.get('name') != 'success-condition']
if not failure_condition:
task['params'] = [tp for tp in task.get('params', []) if tp.get('name') != "failure-condition"]
if not set_owner_reference:
task['params'] = [tp for tp in task.get('params', []) if tp.get('name') != "set-ownerreference"]
for tp in task.get('params', []):
if tp.get('name') == "action" and action:
tp['value'] = action
Expand All @@ -791,6 +794,8 @@ def _process_resourceOp(self, task_refs, pipeline):
tp['value'] = success_condition
if tp.get('name') == "failure-condition" and failure_condition:
tp['value'] = failure_condition
if tp.get('name') == "set-ownerreference" and set_owner_reference:
tp['value'] = set_owner_reference
if tp.get('name') == "output":
output_values = ''
for value in sorted(list(op.attribute_outputs.items()), key=lambda x: x[0]):
Expand Down
3 changes: 2 additions & 1 deletion sdk/python/tests/compiler/testdata/resourceop_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def resourceop_basic():
op = dsl.ResourceOp(
name='test-step',
k8s_resource=json.loads(_CONTAINER_MANIFEST),
action='create'
action='create',
set_owner_reference='true'
# success_condition='status.succeeded > 0',
# failure_condition='status.failed > 0'
)
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/tests/compiler/testdata/resourceop_basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
- name: name
valueFrom: '{.metadata.name}'
- name: set-ownerreference
value: "false"
value: "true"
taskSpec:
params:
- description: Action on the resource
Expand Down
2 changes: 0 additions & 2 deletions sdk/python/tests/compiler/testdata/volume_op.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ spec:
valueFrom: '{.metadata.name}'
- name: size
valueFrom: '{.status.capacity.storage}'
- name: set-ownerreference
value: "false"
- name: size
value: $(params.size)
taskSpec:
Expand Down