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

fix: Fix supplied global workflow parameters, fixes #7573

Merged

Conversation

dinever
Copy link
Member

@dinever dinever commented Jan 18, 2022

Signed-off-by: Peixuan Ding [email protected]

Hi, this PR fixes an issue where supplied workflow parameters are not correctly set in the global parameters. See #7563 for more details.

For example, in the following workflow template, the parameter name is supplied by UI or CLI. However, it will not be set in the global parameters because both valueFrom and value exist at the runtime. The workflow controller only looks for configMapKeyRef when valueFrom is set.

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: workflow-template-whalesay-template
spec:
  arguments:
    parameters:
      - name: name
        valueFrom:
          supplied: {}
  entrypoint: whalesay-template
  templates:
  - name: whalesay-template
    container:
      image: docker/whalesay
      command: [cowsay]
      args: ["{{workflow.parameters.name}}"

Fixes #7563, also relates to #7476

Thanks!

}
woc.globalParams["workflow.parameters."+param.Name] = cmValue
} else {
woc.globalParams["workflow.parameters."+param.Name] = param.Value.String()
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the if/else structure from

if param.ValueFrom != nil {
	if param.ValueFrom.ConfigMapKeyRef != nil {
		// ...
	}
} else {
	woc.globalParams["workflow.parameters."+param.Name] = param.Value.String()
}

to

if param.ValueFrom != nil && param.ValueFrom.ConfigMapKeyRef != nil {
	// ...
} else {
	woc.globalParams["workflow.parameters."+param.Name] = param.Value.String()
}

Similar to ProcessArgs:

if inParam.ValueFrom != nil && inParam.ValueFrom.ConfigMapKeyRef != nil {
if configMapInformer != nil {
cmValue, err := GetConfigMapValue(configMapInformer, namespace, inParam.ValueFrom.ConfigMapKeyRef.Name, inParam.ValueFrom.ConfigMapKeyRef.Key)
if err != nil {
return nil, errors.Errorf(errors.CodeBadRequest, "unable to retrieve inputs.parameters.%s from ConfigMap: %s", inParam.Name, err)
}
inParam.Value = wfv1.AnyStringPtr(cmValue)
}
} else {
if inParam.Value == nil {
return nil, errors.Errorf(errors.CodeBadRequest, "inputs.parameters.%s was not supplied", inParam.Name)
}
}

Copy link
Member

@terrytangyuan terrytangyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@terrytangyuan terrytangyuan merged commit ebdde33 into argoproj:master Jan 18, 2022
@dinever dinever deleted the fix-supplied-workflow-parameters branch January 18, 2022 15:28
yriveiro pushed a commit to yriveiro/argo-workflows that referenced this pull request Jan 27, 2022
@alexec alexec mentioned this pull request Jan 27, 2022
4 tasks
@sarabala1979 sarabala1979 mentioned this pull request Mar 1, 2022
@agilgur5 agilgur5 added the area/templating Templating with `{{...}}` label Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/templating Templating with `{{...}}`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

workflow parameter valueFrom: supplied: {} fails to resolve
3 participants