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

Getting error when building custom image with 'ansible' pack added. #31

Open
dhexnatheo opened this issue Oct 27, 2022 · 1 comment
Open

Comments

@dhexnatheo
Copy link

  • I'm trying to build custom pack image with 'ansible' pack added. But keep getting this error message:
Building wheels for collected packages: pykerberos
  Building wheel for pykerberos (setup.py): started
  Building wheel for pykerberos (setup.py): finished with status 'error'
  Running setup.py clean for pykerberos
Failed to build pykerberos
Installing collected packages: pycparser, urllib3, idna, charset-normalizer, cffi, certifi, requests, pyparsing, ntlm-auth, MarkupSafe, cryptography, xmltodict, resolvelib, requests-ntlm, PyYAML, pyspnego, packaging, jinja2, requests-credssp, pywinrm, pykerberos, ansible-core, netaddr, ansible
    Running setup.py install for pykerberos: started
    Running setup.py install for pykerberos: finished with status 'error'
 (stderr:   ERROR: Command errored out with exit status 1:
   command: /opt/stackstorm/virtualenvs/ansible/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-g2tgpfz4/pykerberos_8b76ed6ecc4c44fa8b5baef50282d2d6/setup.py'"'"'; __file__='"'"'/tmp/pip-install-g2tgpfz4/pykerberos_8b76ed6ecc4c44fa8b5baef50282d2d6/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-iyp_di66
       cwd: /tmp/pip-install-g2tgpfz4/pykerberos_8b76ed6ecc4c44fa8b5baef50282d2d6/
  Complete output (10 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'kerberos' extension
  creating build
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/src
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/opt/stackstorm/virtualenvs/ansible/include -I/usr/include/python3.8 -c src/kerberos.c -o build/temp.linux-x86_64-3.8/src/kerberos.o
  unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pykerberos
    ERROR: Command errored out with exit status 1:
     command: /opt/stackstorm/virtualenvs/ansible/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-g2tgpfz4/pykerberos_8b76ed6ecc4c44fa8b5baef50282d2d6/setup.py'"'"'; __file__='"'"'/tmp/pip-install-g2tgpfz4/pykerberos_8b76ed6ecc4c44fa8b5baef50282d2d6/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-uqi43b55/install-record.txt --single-version-externally-managed --compile --install-headers /opt/stackstorm/virtualenvs/ansible/include/site/python3.8/pykerberos
         cwd: /tmp/pip-install-g2tgpfz4/pykerberos_8b76ed6ecc4c44fa8b5baef50282d2d6/
    Complete output (10 lines):
    running install
    running build
    running build_ext
    building 'kerberos' extension
    creating build
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/src
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/opt/stackstorm/virtualenvs/ansible/include -I/usr/include/python3.8 -c src/kerberos.c -o build/temp.linux-x86_64-3.8/src/kerberos.o
    unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /opt/stackstorm/virtualenvs/ansible/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-g2tgpfz4/pykerberos_8b76ed6ecc4c44fa8b5baef50282d2d6/setup.py'"'"'; __file__='"'"'/tmp/pip-install-g2tgpfz4/pykerberos_8b76ed6ecc4c44fa8b5baef50282d2d6/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-uqi43b55/install-record.txt --single-version-externally-managed --compile --install-headers /opt/stackstorm/virtualenvs/ansible/include/site/python3.8/pykerberos Check the logs for full command output.
  • After some diggin' around, i've found this issue and begin to suspect that there was some missing dependencies here. I was right, libkrb5-dev gcc python3-dev python-dev were missing.
  • I did some simple, temporary workaround for this. What i did was add those missing dependencies directly into the builder Dockerfile using sed.
    sed -i "2i RUN apt update && apt install -y libkrb5-dev gcc python3-dev python-dev && rm -rf /var/lib/apt/lists/*" ./st2packs-image/Dockerfile
  • And then proceed to build the image as the docs says. Summary for everything i've did:
$ git clone [email protected]:stackstorm/st2packs-dockerfiles
$ cd st2packs-dockerfiles
$ sed -i "2i RUN apt update && apt install -y libkrb5-dev gcc python3-dev python-dev && rm -rf /var/lib/apt/lists/*" ./st2packs-image/Dockerfile
$ docker build --build-arg PACKS="ansible" -t ${DOCKER_REGISTRY}/st2packs:<version_number> st2packs-image
  • I hope this could help and if anyone has better idea/way feel free to add. I'd really appreciate it.
@arm4b
Copy link
Member

arm4b commented Oct 27, 2022

@FreddyAprilliant Thanks for sharing! 👍

I'd recommend considering the Dockerfile for building your packs as an infrastructure-as-code artifact, keep it in the repo so you can just do default docker build anytime without specifying the CLI parameters:

Dockerfile:

# list of packs to be installed
ARG PACKS="ansible"

FROM stackstorm/st2packs:builder AS builder
# custom dependencies
RUN apt update && apt install -y libkrb5-dev gcc python3-dev python-dev

RUN /opt/stackstorm/st2/bin/st2-pack-install ${PACKS}
FROM stackstorm/st2packs:runtime

that'll technically do the same. Choose the approach suitable for situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants