Skip to content

Make easier to disable exporting of environment with sudo #39

@willfurnass

Description

@willfurnass

BatchSpawner fails on one of our Grid Engine clusters due to sudo being unable to export the environment (enabled by it's -E argument). We only allow certain environment variables to be exported - from our sudoers:

Defaults:jupyter env_keep+="SGE_ROOT SGE_CELL SGE_EXECD_PORT SGE_QMASTER_PORT SGE_CLUSTER_NAME LANG JPY_API_TOKEN"
jupyter        host1, host2 = (ALL) NOPASSWD: /usr/local/sge/live/bin/lx-amd64/qsub
jupyter        host1, host2 = (ALL) NOPASSWD: /usr/local/sge/live/bin/lx-amd64/qstat
jupyter        host1, host2 = (ALL) NOPASSWD: /usr/local/sge/live/bin/lx-amd64/qdel

To work around this issue I've added the following to our jupyterhub_config.py:

# Need to tailor use of sudo to ShARC as exporting of entire environment         
# using sudo's -E argument is not permitted here                                 
sudo_prefix = 'sudo -u {username} '                                              
c.GridengineSpawner.batch_submit_cmd = sudo_prefix + 'qsub'                      
c.GridengineSpawner.batch_query_cmd = sudo_prefix + 'qstat -xml'                 
c.GridengineSpawner.batch_cancel_cmd = sudo_prefix + 'qdel {job_id}' 

but do others think it would be nicer to have a neater way of setting this e.g. a can_sudo_export_env boolean trait?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions