ibm_zos_core icon indicating copy to clipboard operation
ibm_zos_core copied to clipboard

[Enabler] [Pipeline] Immediate fix for test suite not able to run in ansible-core 2.17.1 or later

Open fernandofloresg opened this issue 6 months ago • 0 comments

Is there an existing issue for this?

  • [X] There are no existing issues.

Enabler description

As described in #1659, we need an immediate fix to be able to run the pipeline with ansible-core 2.17 and certify v1.12.0 on it, the following is an extract from #1659, that explains briefly the issue and proposes a solution.

The call to build_module_command at this line cmd = self._connection._shell.build_module_command(environment_string, shebang, cmd, arg_path=args_file_path).strip() will yield a string that surrounded by single ' quotes. Here is that output after hacking in some debug stmts you can see:

'export _BPXK_AUTOCVT=ON ; export _CEE_RUNOPTS='"'"'FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)'"'"' ; export _TAG_REDIR_IN=txt ; export _TAG_REDIR_OUT=txt ; export LANG=C ; export ZOAU_HOME=/zoau/v1.3.1 ; export LIBPATH=/zoau/v1.3.1/lib:/allpython/3.10/usr/lpp/IBM/cyp/v3r10/pyz/lib:/lib:/usr/lib:. ; export PYTHONPATH=/zoau/v1.3.1/lib ; export PATH=/zoau/v1.3.1/bin:/allpython/3.10/usr/lpp/IBM/cyp/v3r10/pyz/bin:/bin:/usr/sbin:/var/bin ; export PYTHONSTDINENCODING=cp1047 ; /allpython/3.10/usr/lpp/IBM/cyp/v3r10/pyz/bin/python3'

where prior it would yield:

export _BPXK_AUTOCVT=ON ; export _CEE_RUNOPTS='FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)' ; export _TAG_REDIR_IN=txt ; export _TAG_REDIR_OUT=txt ; export LANG=C ; export ZOAU_HOME=/zoau/v1.3.1 ; export LIBPATH=/zoau/v1.3.1/lib:/allpython/3.10/usr/lpp/IBM/cyp/v3r10/pyz/lib:/lib:/usr/lib:. ; export PYTHONPATH=/zoau/v1.3.1/lib ; export PATH=/zoau/v1.3.1/bin:/allpython/3.10/usr/lpp/IBM/cyp/v3r10/pyz/bin:/bin:/usr/sbin:/var/bin ; export PYTHONSTDINENCODING=cp1047 ; /allpython/3.10/usr/lpp/IBM/cyp/v3r10/pyz/bin/python3

While quotes seem innocent enough but once they enter in a shlex.quote(...) call that single quote goes from ' to this '"'"' . Which corresponds to what I saw in the difference of the commands going from /allpython/3.10/usr/lpp/IBM/cyp/v3r10/pyz/bin/python3' && sleep 0 to a non-functional new command /allpython/3.10/usr/lpp/IBM/cyp/v3r10/pyz/bin/python3'"'"' && sleep 0'.

The shlex call cmd = executable + ' -c ' + shlex.quote(cmd) is over 3 years old and not the issue, its the change that delivers a string with single quotes that results in this breakage.

What should we do to resolve this? Based on our usage of the interpreter string, I think the community is in the right to have made those changes and its on us to come up with a plan which I will describe as immediate, short term and long term.

Immediate

  • Prior to our test framework running, we have a couple of choices where do perform this operation, but idea is that we will on the fly edit the code to correct the behavior so we can continue regression testing with 2.17.1+.
  • This can be done by removing the shlex.quote call
  • Trimming the cmd string before the cmd = executable + ' -c ' + shlex.quote(cmd) call.
  • Editing the changes that happened in def build_module_command(self, env_string, shebang, cmd, arg_path=None):
  • My personal opinion is to trim the cmd string for starting and ending quotes this way the behavior remains as it was intended.
  • How do this? in our pytext fixture or our call to using it in ztest.py insert a routine that will do some basic parsing and inserting of code to perform the above. This way its there for all our executions.

Ansible module

No response

fernandofloresg avatar Aug 27 '24 18:08 fernandofloresg