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(steps): provide functions args in function conditions values #343

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rclsilver
Copy link
Contributor

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
    Bug fix

  • What is the current behavior? (You can also link to an open issue here)
    Currently, we don't have the function args values available in functions conditions (skip and check).

  • What is the new behavior (if this is a feature change)?
    Now, the function args are available in functions conditions (skip and check).

  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
    No breaking change.

  • Other information:

@ovh-cds
Copy link
Collaborator

ovh-cds commented Jul 23, 2022

CDS Report test#1310.0 ✘

  • tests and lint
    • golangci-lint ✔
    • unit-test and integration-tests ✘

@ovh-cds
Copy link
Collaborator

ovh-cds commented Jul 23, 2022

CDS Report test#1309.0 ✘

  • tests and lint
    • golangci-lint ✔
    • unit-test and integration-tests ✘

@ovh-cds
Copy link
Collaborator

ovh-cds commented Jul 23, 2022

CDS Report test#1310.1 ✘

  • tests and lint
    • golangci-lint ✔
    • unit-test and integration-tests ✘

@rbeuque74
Copy link
Member

LGTM.
Need to check why the build is failing

@rclsilver
Copy link
Contributor Author

LGTM. Need to check why the build is failing

I guess as I cloned the values, the changes made by the condition wasn't saved in the DB. I think we have to alter the original Values with the FunctionArgs.

What do you think?

@rclsilver
Copy link
Contributor Author

I added a test to verify my work

Signed-off-by: Thomas Bétrancourt <thomas@betrancourt.net>
@ovh-cds
Copy link
Collaborator

ovh-cds commented Jul 25, 2022

CDS Report test#1326.0 ✘

  • tests and lint
    • golangci-lint ✘
    • unit-test and integration-tests ✘

@ovh-cds
Copy link
Collaborator

ovh-cds commented Jul 25, 2022

CDS Report test#1327.0 ✘

  • tests and lint
    • golangci-lint ✘
    • unit-test and integration-tests ✔

@ovh-cds
Copy link
Collaborator

ovh-cds commented Jul 26, 2022

CDS Report test#1327.1 ✘

  • tests and lint
    • golangci-lint ✘
    • unit-test and integration-tests ✘

@ovh-cds
Copy link
Collaborator

ovh-cds commented Jul 26, 2022

CDS Report test#1327.2 ✘

  • tests and lint
    • golangci-lint ✘
    • unit-test and integration-tests ✔

@ovh-cds
Copy link
Collaborator

ovh-cds commented Jul 26, 2022

CDS Report test#1327.3 ✘

  • tests and lint
    • golangci-lint ✘
    • unit-test and integration-tests ✔

@ovh-cds
Copy link
Collaborator

ovh-cds commented Jul 26, 2022

CDS Report test#1327.4 ✘

  • tests and lint
    • golangci-lint ✘
    • unit-test and integration-tests ✔

@ovh-cds
Copy link
Collaborator

ovh-cds commented Jul 26, 2022

CDS Report test#1327.5 ✘

  • tests and lint
    • golangci-lint ✘
    • unit-test and integration-tests ✘

Co-authored-by: Romain Beuque <556072+rbeuque74@users.noreply.github.com>
@ovh-cds
Copy link
Collaborator

ovh-cds commented Jul 26, 2022

CDS Report test#1333.0 ✘

  • tests and lint
    • golangci-lint ✘
    • unit-test and integration-tests ✔

@ovh-cds
Copy link
Collaborator

ovh-cds commented Jul 26, 2022

CDS Report test#1332.0 ✘

  • tests and lint
    • golangci-lint ✘
    • unit-test and integration-tests ✔

@ovh-cds
Copy link
Collaborator

ovh-cds commented Jul 27, 2022

CDS Report test#1334.0 ✘

  • tests and lint
    • golangci-lint ✘
    • unit-test and integration-tests ✘

@ovh-cds
Copy link
Collaborator

ovh-cds commented Jul 27, 2022

CDS Report test#1335.0 ✘

  • tests and lint
    • golangci-lint ✘
    • unit-test and integration-tests ✘

Comment on lines +25 to +27
- value: '{{ .function_args.name1 }}'
operator: EQ
expected: foobar
Copy link
Member

Choose a reason for hiding this comment

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

I added this condition in the test : function nested2 has correctly been called with foobar, but it's failing in the test.
This comes from the fact that the pull request is only using the function args of the "main" step (the one declared in the template): if we start to have nested functions, templating start to fails, because only the function_args on the "main" step is populated in the values.

I also found why this test was failing if we used values.Clone, follow the second comment

ss(st.Name, StateServerError, err.Error())
return
}
values.SetFunctionsArgs(functionInput)
Copy link
Member

Choose a reason for hiding this comment

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

Here, we previously used values.Clone to prevent alter on the values object of the caller.
But, in this function, we have a second parameter, which is ss for StateSetter: https://github.com/ovh/utask/blob/master/engine/step/step.go#L521
Called from here: https://github.com/ovh/utask/blob/master/engine/engine.go#L431
definition of this function is here: https://github.com/ovh/utask/blob/master/engine/engine.go#L1064-L1071

Everytime a condition is matching, we need to alter the state of some steps, using ss (such as here https://github.com/ovh/utask/blob/master/engine/step/step.go#L551 )
And the call of the closure in resolutionStateSetter is using the parent values object to alter the current state.
So when the second condition is evaluated, and require that the first condition altered the state to match, we are using the cloned value, which has not been altered by the closure in resolutionStateSetter, which mean that the condition state will not match, making the test failing.

I guess not cloning the values is fine, but the drawback of function_args not working in conditions if they are nested seems a huge drawback that we should address before merging this one

Copy link
Member

@rbeuque74 rbeuque74 left a comment

Choose a reason for hiding this comment

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

See other comments

@wI2L wI2L added the 🚧 WIP 🚧 Work in progress label label Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚧 WIP 🚧 Work in progress label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants