Skip to content

Commit

Permalink
fix: panic in prepareMetricScope (#6720)
Browse files Browse the repository at this point in the history
Signed-off-by: Saravanan Balasubramanian <sarabala1979@gmail.com>
  • Loading branch information
sarabala1979 committed Sep 13, 2021
1 parent 808d897 commit 82e4082
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions workflow/controller/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,11 @@ func (woc *wfOperationCtx) prepareMetricScope(node *wfv1.NodeStatus) (map[string
if node.Inputs != nil {
for _, param := range node.Inputs.Parameters {
key := fmt.Sprintf("inputs.parameters.%s", param.Name)
localScope[key] = param.Value.String()
if param.Value == nil {
localScope[key] = ""
} else {
localScope[key] = param.Value.String()
}
}
}

Expand All @@ -515,7 +519,11 @@ func (woc *wfOperationCtx) prepareMetricScope(node *wfv1.NodeStatus) (map[string
}
for _, param := range node.Outputs.Parameters {
key := fmt.Sprintf("outputs.parameters.%s", param.Name)
localScope[key] = param.Value.String()
if param.Value == nil {
localScope[key] = ""
} else {
localScope[key] = param.Value.String()
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions workflow/controller/steps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ func TestResourceDurationMetric(t *testing.T) {
id: many-items-z26lj-3491220632
name: many-items-z26lj[0].sleep(4:four)
outputs:
parameters:
- name: pipeline_tid
artifacts:
- archiveLogs: true
name: main-logs
Expand Down

0 comments on commit 82e4082

Please sign in to comment.