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(controller): Revert prepending ExecutorScriptSourcePath which brought a breaking change in args handling #4884

Merged
merged 1 commit into from
Feb 2, 2021

Conversation

MrFreezeex
Copy link
Contributor

@MrFreezeex MrFreezeex commented Jan 15, 2021

This reverts commit 64ae330.

This PR reverts #4492 which changes the way args are passed to a script template. Due to this change we are not able to override args with a docker image and an entrypoint with an exec "$@" in argo workflow 2.12.x.

This is convenient to execute the docker entrypoint of the base image and then execute the script in the workflow. We use it to do some privileged action and then drop those privileges before executing the script passed in the workflow. You can find more information in #4782 with an example to test the behavior that brokes in 2.12.x.

This revert will obviously break the behavior that the author of this commit has intended to introduce so I don't know if reverting is the best things to do...

Resolves #4782

@alexec
Copy link
Contributor

alexec commented Jan 15, 2021

Did you author these changes originally?

@alexec alexec changed the title Revert prepending ExecutorScriptSourcePath which brought a breaking change in args handling fix(controller): Revert prepending ExecutorScriptSourcePath which brought a breaking change in args handling Jan 15, 2021
@alexec alexec added this to the v2.12 milestone Jan 15, 2021
@MrFreezeex
Copy link
Contributor Author

Did you author these changes originally?

No I didn't. The original author is @ivancili in PR #4492. You can find an explanation of why this has been introduced in issue #4481. This broke our use of script template as described in this PR and in issue #4782.

@alexec
Copy link
Contributor

alexec commented Jan 15, 2021

@ivancili would you like to chip it? Would you like to propose a fix so everyone is happy?

@ghost
Copy link

ghost commented Jan 18, 2021

@alexec @MrFreezeex In my opinion, the correct behavior of a script template should include the ability to pass arbitrary args to the script (one way, or another). The example provided in this issue seems like an incorrect usage to me, though. I would just put the [sh] into command section of the template, or prepare the entrypoint of the base image fully. Nevertheless, I see your point, and I realize my PR introduced a breaking change and it should be fixed, I apologize for the inconvenience.

Here are my proposals on how to fix this:

  1. Add a flag to the script template which indicates whether args should be added before or after the script, notice the flag argsPosition in this example (name and data type of the flag can be further discussed):
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  name: test-args-script
spec:
  entrypoint: test
  templates:
  - name: test
    script:
      image: mrfreezeex/test-argow-script:v1
      args: [sh]
      argsPosition: prepend  # other option is append
      source: |
        echo "This message will be shown!"
  1. Add separate field called sourceArgs, which will then allow users to specify both container args and script args at the same time, without these kinds of problems. Container args will be added before script, and sourceArgs after the script. But in this case you have to be careful in how you write your container image entrypoint/args. Example:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  name: test-args-script
spec:
  entrypoint: test
  templates:
  - name: test
    script:
      image: mrfreezeex/test-argow-script:v1
      args: [sh]
      sourceArgs:
        - "Hello"
      source: |
        echo "This message will be shown!"
        echo $1 there                  # prints "Hello there"
  1. Revert my commit and just use Go templates to parametrize the script source (as it were before)

Let me know your thoughts.

@MrFreezeex
Copy link
Contributor Author

MrFreezeex commented Jan 18, 2021

Let me know your thoughts.

From my point of view, I think that the sourceArgs would be the best options of the three. Kubernetes users are used to having default commands/args handling and breaking this behavior in argo workflow would be a bit weird. This also would be a non breaking change as we would add a new field with a totally different behavior.

@MrFreezeex MrFreezeex changed the title fix(controller): Revert prepending ExecutorScriptSourcePath which brought a breaking change in args handling fix(controller): add sourceArgs to fix breaking change on script args Jan 24, 2021
@MrFreezeex MrFreezeex force-pushed the fix-args-entrypoint branch 3 times, most recently from aa89df3 to 81e1da0 Compare January 24, 2021 22:45
@MrFreezeex
Copy link
Contributor Author

I updated my PR to add sourceArgs instead of reverting the commit.

@MrFreezeex MrFreezeex force-pushed the fix-args-entrypoint branch 2 times, most recently from 2e854c5 to 5b31a3c Compare January 28, 2021 23:37
@jessesuen
Copy link
Member

Since #4492 introduced a regression/change in behavior, it should be reverted. If there is confusion about how script templates work, we should document the behavior better rather than implement additional knobs, especially since there are alternatives to achieve the desired use case. Can we simplify this PR to just a revert of #4492?

@MrFreezeex MrFreezeex force-pushed the fix-args-entrypoint branch 2 times, most recently from 3435c51 to 122748e Compare February 2, 2021 12:37
@MrFreezeex MrFreezeex changed the title fix(controller): add sourceArgs to fix breaking change on script args fix(controller): Revert prepending ExecutorScriptSourcePath which brought a breaking change in args handling Feb 2, 2021
@MrFreezeex
Copy link
Contributor Author

MrFreezeex commented Feb 2, 2021

Since #4492 introduced a regression/change in behavior, it should be reverted. If there is confusion about how script templates work, we should document the behavior better rather than implement additional knobs, especially since there are alternatives to achieve the desired use case. Can we simplify this PR to just a revert of #4492?

I just did that but for some reasons now a test is failing:

    --- FAIL: TestFunctionalSuite/TestDeletingRunningPod (44.63s)
Error:         functional_test.go:61: timeout after 30s waiting for condition to be done

I don't think that's something related to this code change but I retried It once already... Do you know if this test can be a bit flaky sometimes ?

…ught a breaking change in args handling

This reverts commit 64ae330.

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>
@alexec
Copy link
Contributor

alexec commented Feb 2, 2021

TestDeletingRunningPod is broken

@alexec alexec merged commit 44a4f7e into argoproj:master Feb 2, 2021
@alexec alexec modified the milestones: v2.12, v3.0 Feb 2, 2021
@alexec
Copy link
Contributor

alexec commented Feb 2, 2021

@ivancili we've reverted your commit because it was a breaking change that resulted in a regression. Would you like to consider suggesting a new way to do this that is non-breaking?

@MrFreezeex MrFreezeex deleted the fix-args-entrypoint branch February 2, 2021 16:27
@simster7 simster7 mentioned this pull request Feb 8, 2021
38 tasks
@henrywangx
Copy link
Contributor

henrywangx commented Dec 23, 2021

Hi guys @alexec @ivancili @MrFreezeex , looks like this revert broken our script
图片
Submitted a MR #7467 to fix this issue

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

Successfully merging this pull request may close these issues.

prepending ExecutorScriptSourcePath breaks using script with args without command
4 participants