Permission Denied: Starting cull_idle_servers.py in hub container

I’m using extracted deployment files from the helm chart and my own Dockerfiles(Since can’t use the external ones inside out premise).
If I remove the cull_idle from jupyterhub_config.py, my hub works fine. But when I’m including it, I’m getting this error.

Spawning /usr/local/bin/cull_idle_servers.py --url=http://127.0.0.1:8081/hub/api --timeout=3600 --cull-every=600 --concurrency=10
Permission denied trying to run ‘/usr/local/bin/cull_idle_servers.py’. Does have access to this file?
Failed to start service cull-idle

I’ve made my custom Dockerfile due to in-premise restrictions:

FROM <centos_base_image>

ARG JUPYTERHUB_VERSION=0.9.*

RUN yum install -y git
gcc
vim
less
libssl-dev
libcurl-devel
libcurl4-openssl-dev
openssl-devel
build-essential
redhat-rpm-config
sqlite3
curl
dnsutils
$(bash -c ‘if [[ $JUPYTERHUB_VERSION == “git”* ]]; then
# workaround for Bug #1794589 “libssl1.0-dev conflicts libssl-dev” : Bugs : nodejs package : Ubuntu
echo nodejs=8.10.0~dfsg-2ubuntu0.2 nodejs-dev=8.10.0~dfsg-2ubuntu0.2 npm;
fi’)

ARG NB_USER=jovyan
ARG NB_UID=1000
ARG HOME=/home/jovyan

ENV LANG C.UTF-8
RUN yum install -y --obsolete --disablerepo=* --enablerepo=epel
python36
python36-pip
python36-devel
python36-setuptools

RUN yum upgrade --obsolete --disablerepo=* --enablerepo=epel python36-setuptools

RUN adduser
–comment “Default user”
–uid ${NB_UID}
–home ${HOME}
${NB_USER}

ADD requirements.txt /tmp/requirements.txt
RUN PYCURL_SSL_LIBRARY=openssl pip3 --proxy <internal_proxy> install --no-cache-dir
-r /tmp/requirements.txt
$(bash -c ‘if [[ $JUPYTERHUB_VERSION == “git”* ]]; then
echo ${JUPYTERHUB_VERSION};
else
echo jupyterhub==${JUPYTERHUB_VERSION};
fi’)

ENV PYCURL_SSL_LIBRARY=nss
RUN pip3 install pycurl -i <internal_registry>

ADD jupyterhub_config.py /srv/jupyterhub_config.py
ADD z2jh.py /home/jovyan/.local/lib/python3.6/site-packages/z2jh.py

ADD cull_idle_servers.py /usr/local/bin/cull_idle_servers.py

WORKDIR /srv/jupyterhub
RUN chown ${NB_USER}:${NB_USER} /srv/jupyterhub

EXPOSE 8081

USER ${NB_USER}
CMD [“jupyterhub”, “–config”, “/srv/jupyterhub_config.py”]

What Can be the issue? I’ve not changed anything much in the jupyterhub_config.py file.

Is that file executable?

Hi, It is just a py file. But It is supposed to be executable right? But the issue I can’t access it.

It need to have the unix execute permissions, can you check they’re correct? If they not you can run chmod a+x /usr/local/bin/cull_idle_servers.py

No, its not permission issue as I tried changing the permission. It is unable to reach that file. When I go inside the pod and try to run the same command , it says: File not Found. But Inside that directory file is present.

This error was resolved when I mentioned the absolute path of cull_idle_servers.py.
And cull_idle is pinging after every 30 minutes (1800 secs) as timeout is passed as 3600 seconds. And it kills the pod after 1 hour 27 mins.

Thanks