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

difference behavior of {{= workflow.creationTimestamp }} and {{ workflow.creationTimestamp }} #6906

Closed
roy-ht opened this issue Oct 11, 2021 · 4 comments
Assignees
Labels

Comments

@roy-ht
Copy link

roy-ht commented Oct 11, 2021

Summary

What happened/what you expected to happen?

{{= workflow.creationTimesamp }} should be rfc3339 string, but outputs a map representation like:

map[A:Monday B:October H:06 I:06 L:.000 M:11 S:08 Y:2021 Z:UTC a:Mon b:Oct d:11 m:10 p:AM s:1633932668 y:21 z:+0000]

some investigations

In Template.Replace,

I guess simpleReplace searches flattened replaceMap and good, but expressionReplace has a "nested" replaceMap, as env,
so the key workflow.creationTimestamp becomes a map[string]interface{}.

I'd like to get a formatted string value or time.Time instance to send sprig.dateModify like:

{{= sprig.dateModify("-24h", sprig.toDate('2006-01-02T15:04:05Z07:00', workflow.creationTimestamp)) }}

Or more simply to send to dateModify,
I would appreciate if Argo WF has workflow.creationTimestamp.time or asTime(workflow.creationTimestamp).

What version of Argo Workflows are you running?

v3.1.8

Diagnostics

Either a workflow that reproduces the bug, or paste you whole workflow YAML, including status, something like:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: steps-
spec:
  entrypoint: hello

  templates:
  - name: hello
    steps:
    - - name: h1
        template: whalesay
        arguments:
          parameters:
          - name: message
            value: "1: {{ workflow.creationTimestamp }}"
    - - name: h2
        template: whalesay
        arguments:
          parameters:
          - name: message
            value: "2: {{= workflow.creationTimestamp }}"
    - - name: h3
        template: whalesay
        arguments:
          parameters:
          - name: message
            value: "3: {{= string(workflow.creationTimestamp) }}"

  - name: whalesay
    inputs:
      parameters:
      - name: message
    container:
      image: docker/whalesay
      command: [cowsay]
      args: ["{{inputs.parameters.message}}"]

What Kubernetes provider are you using?

Amazon EKS


Message from the maintainers:

Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.

@alexec
Copy link
Contributor

alexec commented Oct 11, 2021

This is because workflows.creationTimestamp is, in fact, a map. It has some fields,

workflow.creationTimestamp. Creation timestamp formatted with a strftime format character

https://strftime.org

I'm not sure this is useful to most users.

Options:

  1. Remove workflows.creationTimestamp.STRFTIMECHAR from expression template support (breaking change).
  2. Add workflows.creationTimestamp.RFC3339 or similar.

This is an easy change.

@alexec alexec added good first issue Good for newcomers and removed triage labels Oct 11, 2021
@roy-ht
Copy link
Author

roy-ht commented Oct 12, 2021

@alexec Thanks for quick reply!

First, Option 2 seems to be good for me, but I'm not sure which is the best option for the future of Argo WF.

I prefer option 1 and add some utility function to manipulate a date (like strftime, date_add, ....), but it has a cost to existing users and need some extra implementation.

@ziv-codefresh
Copy link
Contributor

@alexec i would be happy to contribute it. can you assign it to me please?

kriti-sc pushed a commit to kriti-sc/argo-workflows that referenced this issue Oct 24, 2021
…roj#7044)

Signed-off-by: kriti-sc <kathuriakriti1@gmail.com>
@sarabala1979 sarabala1979 mentioned this issue Oct 26, 2021
25 tasks
@sarabala1979 sarabala1979 mentioned this issue Nov 4, 2021
25 tasks
@posquit0
Copy link
Contributor

I need this feature also. :)

alexec pushed a commit that referenced this issue Nov 17, 2021
Signed-off-by: Alex Collins <alex_collins@intuit.com>
@sarabala1979 sarabala1979 mentioned this issue Dec 15, 2021
73 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants