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

[bug] The command exit code always be '0' in windows container #9797

Closed
wsj0000 opened this issue Oct 12, 2022 · 2 comments · Fixed by #9807
Closed

[bug] The command exit code always be '0' in windows container #9797

wsj0000 opened this issue Oct 12, 2022 · 2 comments · Fixed by #9807
Assignees
Labels

Comments

@wsj0000
Copy link
Contributor

wsj0000 commented Oct 12, 2022

The command exit code always be '0' in windows container. Because the wait function on windows only check the err but not with the exit code of the stat (The error might be redirect).
https://github.com/argoproj/argo-workflows/blob/aa59b43748f78e599709add871af7ec14e1fd3c1/workflow/executor/os-specific/signal_windows.go#L29

I tried to fix this by the code below:

func Wait(process *os.Process) error {
	stat, err := process.Wait()
	if stat.ExitCode() != 0 {
		var errStr string
		if err != nil {
			errStr = err.Error()
		} else {
			errStr = "<nil>"
		}

		return errors.New(fmt.Sprintf("Exited failed. Error:%s", errStr))
	}
	return nil
}

This is just a temporary fix, so I just show my code here. Hope helpful.

The yaml below will reproduce the issue.

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  namespace: default
  name: mytemplate

spec:
  templates:
    - name: test
      template: test-main
          

    - name: test-main
      nodeSelector:
        kubernetes.io/os: windows
      container:
        - name: main
          image: mcr.microsoft.com/windows/nanoserver:ltsc2022 # I used the nanoserver-ltsc2022 but the issue should also exist on ltsc2019
          command: ["cmd", "/s", "/c"]
          args: ["call exit /b 1"]
@wsj0000 wsj0000 added the type/feature Feature request label Oct 12, 2022
@alexec alexec added type/bug area/executor and removed type/feature Feature request labels Oct 13, 2022
@alexec
Copy link
Contributor

alexec commented Oct 13, 2022

Please submit PR to fix!

@wsj0000
Copy link
Contributor Author

wsj0000 commented Oct 13, 2022

Please submit PR to fix!

#9807

PR submitted

@sarabala1979 sarabala1979 added this to To do in Run The Business (incl. bugs) via automation Oct 17, 2022
alexec pushed a commit that referenced this issue Oct 18, 2022
Run The Business (incl. bugs) automation moved this from To do to Done Oct 18, 2022
juchaosong pushed a commit to juchaosong/argo-workflows that referenced this issue Nov 3, 2022
@agilgur5 agilgur5 added the area/windows Windows Container support label Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

3 participants