Open anticootheone opened 2 years ago
There is the problem of binding to /proc/self/fd/0
file. gomplate
just trying to read from this file and don't solve this error.
The quick solution is here:
ssh
you can use flag -T:
ssh -T username@hostname gotemplate --arg --arg --arg
The simplest way to reproduce this bug:
true | gotemplate --arg --arg --arg 2>&1 | cat
Hello,
I'm working on the replacement of the other tool to
gotemplate
as a primary tool to work with golang syntax templates in my project.In my case,
gotemplate
usage is wrapped into the python code, where it's called using subprocess.run(). This script is being used in various workflows, including the case, where it called remotely via ssh command execuction channel.In my recent tests I faced with an issue while working with my script by calling it remotely via ssh: script was failing with rc=1 on the stage when it renders the templates, without templates being rendered on
gotemplate
exit.After a bit of debugging, I believe I might have found something strange in
gotemplate
execution behaviour over ssh exec channel.There are two cases presented down below with some execution attempts. In both cases
gotemplate
exited with exit code = 1, but in the second case, when I added-n
option to ssh command, it failed, but the templates were rendered (I was thinking there is an issue with fd0/1/2, so I tried-n
).1. First case (quite close to the way how my script called remotely). No templates rendered, exit code = 1:
The command is:
ssh -vvvv testhost 'bash -ic "gotemplate --import=/gotemplate_debugging/values.yaml --color --no-razor --internal-log-level=trace --template-log-level=trace /gotemplate_debugging/vars.yaml"'
Snippet of
gotemplate
strace output:< I pressed CTRL+C to kill the ssh session>
Snippet of the ssh debug output:
2. Second case. Exit code = 1, but templates are rendered, behavior changed when I added
-n
option to the ssh command:The command is:
ssh -n -vvvv testhost 'bash -ic "gotemplate --import=/gotemplate_debugging/values.yaml --color --no-razor --internal-log-level=trace --template-log-level=trace /gotemplate_debugging/vars.yaml"'
Snippet of
gotemplate
strace output:Snippet of the ssh debug output:
In the tests
gotemplate
was executed over these files: vars.yaml:ttt.json:
values.yaml:
asd: ddd
Workaround to the issue (not the great one...): call the script via ssh with
-n
option and not to handle exit codes ofgotemplate
in the python code.There are no issues with executing
gotemplate
over ssh with--version
orlist --functions --all
arguments.P.S. Sorry for this mess with debugging info, I'm not good at golang code debugging... =\