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

Error when using PodSpecPatch to parameterize ActiveDeadlineSeconds #2545

Closed
4 tasks done
jananzhu opened this issue Mar 30, 2020 · 4 comments
Closed
4 tasks done

Error when using PodSpecPatch to parameterize ActiveDeadlineSeconds #2545

jananzhu opened this issue Mar 30, 2020 · 4 comments
Assignees

Comments

@jananzhu
Copy link

Checklist:

  • I've included the version.
  • I've included reproduction steps.
  • I've included the workflow YAML.
  • I've included the logs.

What happened:
I would like to parameterize activeDeadlineSeconds for my workflows so that a timeout can be set at time of workflow submission, similar to the request in #703 . The PodSpecPatch functionality added in #1687 seems like it would suit this use case. However Argo returns an error message when I try to submit a workflow with a PodSpecPatch that modifies the activeDeadlineSeconds: Error in Unmarshalling after merge the patch
What you expected to happen:
A pod should be created from my workflow with activeDeadlineSeconds set to the value of the parameter.

How to reproduce it (as minimally and precisely as possible):

Submit the following workflow:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: pod-spec-patch
spec:
  entrypoint: whalesay
  arguments:
    parameters:
      - name: timeout
        value: 86400
  templates:
  - name: whalesay
    inputs:
      parameters:
      - name: timeout
    podSpecPatch: '{"activeDeadlineSeconds":"{{inputs.parameters.timeout}}"}'
    container:
      image: docker/whalesay:latest
      command: [cowsay]
      args: ["hello world"]

Anything else we need to know?:

Environment:

  • Argo version:
2.6.2
  • Kubernetes version :
clientVersion:
  buildDate: "2019-10-15T19:16:51Z"
  compiler: gc
  gitCommit: 20c265fef0741dd71a66480e35bd69f18351daea
  gitTreeState: clean
  gitVersion: v1.15.5
  goVersion: go1.12.10
  major: "1"
  minor: "15"
  platform: darwin/amd64
serverVersion:
  buildDate: "2019-10-15T19:09:08Z"
  compiler: gc
  gitCommit: c97fe5036ef3df2967d086711e6c0c405941e14b
  gitTreeState: clean
  gitVersion: v1.16.2
  goVersion: go1.12.10
  major: "1"
  minor: "16"
  platform: linux/amd64

Other debugging information (if applicable):

Logs

Name:                pod-spec-patchgz7n6
Namespace:           tenant-redesign
ServiceAccount:      default
Status:              Error
Message:             Error in Unmarshalling after merge the patch
Created:             Mon Mar 30 15:47:14 -0400 (17 minutes ago)
Started:             Mon Mar 30 15:47:14 -0400 (17 minutes ago)
Finished:            Mon Mar 30 15:47:15 -0400 (17 minutes ago)
Duration:            1 second
Parameters:
  timeout:           86400

STEP                               PODNAME              DURATION  MESSAGE
 ⚠ pod-spec-patchgz7n6 (whalesay)  pod-spec-patchgz7n6  0s        Error in Unmarshalling after merge the patch

Message from the maintainers:

If you are impacted by this bug please add a 👍 reaction to this issue! We often sort issues this way to know what to prioritize.

@sarabala1979 sarabala1979 self-assigned this Mar 31, 2020
@jananzhu
Copy link
Author

jananzhu commented Apr 1, 2020

I did some digging and the error is thrown here:
https://github.com/argoproj/argo/blob/8b92d33eb2f2de3b593459140576ea8eaff8fb4b/workflow/controller/workflowpod.go#L294

The underlying json error is json: cannot unmarshal string into Go struct field PodSpec.activeDeadlineSeconds of type int64. Seems like the cause might be due to parameter values being String types and so the numeric value for ActiveDeadlineSeconds is marshalled as a string but cannot be unmarshalled back into an int.

If this is the case though, I'm not sure why the call to util.ValidateJsonStr on the PodSpecPatch string isn't finding the same error.

@sarabala1979
Copy link
Member

Thanks for your detailed debug information. We will take a look and work that.

@sarabala1979
Copy link
Member

sarabala1979 commented Apr 1, 2020

it is wrongly defined in podspec. Number element should not have ""s.
Try below config an let me know

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: pod-spec-patch
spec:
  entrypoint: whalesay
  arguments:
    parameters:
      - name: timeout
        value: 86400
  templates:
  - name: whalesay
    inputs:
      parameters:
      - name: timeout
    podSpecPatch: '{"activeDeadlineSeconds":{{inputs.parameters.timeout}}}'
    container:
      image: docker/whalesay:latest
      command: [cowsay]
      args: ["hello world"]

@jananzhu
Copy link
Author

jananzhu commented Apr 1, 2020

That resolved the issue, thanks!

@jananzhu jananzhu closed this as completed Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants