Skip to content

Bug: worker mangles no_proxy environment variable #2220

Closed

Description

@databus23

Bug Report

We just upgraded from 3.9.2 to 3.13.0 and had saw all our pipelines failing.
In our setup we rely on http(s)_proxy and no_proxy as our corporate proxy refuses to serve internal resources.
Since the upgrade we can't access internal resources anymore which means the no_proxy environment variable is not set or wrong.
Inspecting running /opt/resource/check processes via /proc/$PID/environ we noticed that the no_proxy environment variable only contains the very last part the value we pass via the http_proxy environment variable to the worker:
env no_proxy=host1,host2,host3 concourse worker ... ends up as no_proxy=host3 in containers scheduled by the atc to that worker.

We also confirmed that this is already wrong in the database via select name,no_proxy from workers. So the worker seems to be picking this up wrong during startup.

I opened a PR that hopefully fixes this issue: vmware-archive/worker#1

The following can also be handy:

  • Concourse version: 3.13.0

  • Deployment type (BOSH/Docker/binary): binary

  • Did this used to work? Yes with 3.9.2

Activity

  1. cfasnacht commented on May 28, 2018

    @cfasnacht

    We also updated to 3.13 and have the same issue, it would be great if you could fix this, or release the fix as soon as possible.
    Thanks!

  2. databus23 commented on May 28, 2018

    @databus23
    ContributorAuthor

    @cfasnacht As this bug only effects how environment variables are parsed you can mitigate this by starting the worker with the command line flag --no-proxy=$no_proxy. This works because command line arguments have a higher precedence then environment variables.

  3. mgruener commented on Jun 19, 2018

    @mgruener

    Although this issue should be fixed with vmware-archive/worker#1, I still see this effect with concourse 3.14.1. I am using the concourse docker images.

  4. databus23 commented on Jun 19, 2018

    @databus23
    ContributorAuthor

    Looking at https://github.com/concourse/concourse/tree/v3.14.1/src/github.com/concourse it seems like that commit never made it into 3.14.x.
    @vito I think the changelog needs to be amended and the milestone for vmware-archive/worker#1 set to 3.15 (or 3.14.2?)

  5. mgruener commented on Jun 19, 2018

    @mgruener

    Hmmmm, too bad then that the fix made it to the Changelog for 3.14 :D I really was hoping this was fixed.

    For anyone struggling with the same issue: Try to make no_proxy space separated. This might be somewhat non-standard but it avoids this concourse bug and my initial tests suggest that this might actually work as intended (at least curl can handle a space separated no_proxy variable).

    Hopefully this gets fixed with 3.15.0 or 3.14.2 :)

  6. vito commented on Jun 19, 2018

    @vito
    Contributor

    Woops, you're right it was never bumped. Sorry about that. I really want to make it harder to accidentally forget to bump things after merging PRs. I'll un-milestone it and update the release notes later.

  7. akamalov commented on Jun 19, 2018

    @akamalov

    I can concur. Using 3.14.0. This is an issue for us. We can no longer backup our PCF environment, which is a major bummer..

  8. databus23 commented on Jun 19, 2018

    @databus23
    ContributorAuthor

    @mgruener @akamalov Did you try the workaround mentioned above: #2220 (comment)

  9. akamalov commented on Jun 19, 2018

    @akamalov

    @databus23 thanks for quick reply. I did try to start worker with --no-proxy=$no_proxy, where variable $no_proxy is being sourced off /etc/environment. However, inside the container (using hijack command), I see the following:

    ubuntu@h0002020: ~> fly -t lab hijack -j bbr-backup-bosh/export-om-installation
    1: build #1, step: bbr-pipeline-tasks-repo, type: get
    2: build #1, step: export-om-installation, type: task
    3: build #1, step: om-backup-artifact, type: put
    choose a container: 3
    bash-4.4# env
    BUILD_ID=472
    USER=root
    ATC_EXTERNAL_URL=http://XXXXXXXXXX:8080
    PWD=/tmp/build/put
    HOME=/root
    https_proxy=http://XXXXXXXXXXXXXXXXXXXX:8080/
    http_proxy=http://XXXXXXXXXXXXXXXXXXXX:8080/
    BUILD_PIPELINE_NAME=bbr-backup-bosh
    BUILD_TEAM_NAME=main
    no_proxy=$no_proxy
    TERM=xterm
    BUILD_JOB_NAME=export-om-installation
    BUILD_NAME=1
    SHLVL=1
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    _=/usr/bin/env
    bash-4.4# 
    

    For some reason, variable $no_proxy wasn't sourced properly, shown above. Here is my systemD service file:

    # /etc/systemd/system/concourse-worker.service
    [Unit]
    Description=Concourse CI worker process
    After=concourse-web.service
    
    [Service]
    User=root
    Restart=on-failure
    EnvironmentFile=/etc/concourse/worker_environment
    ExecStart=/opt/concourse/bin/concourse worker --no-proxy=$no_proxy
    
    [Install]
    WantedBy=multi-user.target
    

    And my /etc/environment file looks like this:

    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
    no_proxy="localhost,127.0.0.1,127.0.0.0/8,10.0.0.0/8,XXX.XXX.0.0/16,XXX.XXX.XXX.19,192.168.20.10,192.168.20.11"
    http_proxy="http://XXXXXXXXXXXXXXXXXXXXXXXXX:8080/"
    https_proxy="http://XXXXXXXXXXXXXXXXXXXXXXXXX:8080/"
    

    Thanks yet again.

  10. databus23 commented on Jun 19, 2018

    @databus23
    ContributorAuthor

    @akamalov We are using systemd as well: try --no-proxy=${no_proxy}. My above statement was meant as sort of a general remark to pass the environment variable explicitly as a command line argument. systemd specifically doesn't expand $var but only ${var} in ExecStart.

  11. akamalov commented on Jun 19, 2018

    @akamalov

    Yup, did as you asked as well:

    # /etc/systemd/system/concourse-worker.service
    [Unit]
    Description=Concourse CI worker process
    After=concourse-web.service
    
    [Service]
    User=root
    Restart=on-failure
    EnvironmentFile=/etc/concourse/worker_environment
    ExecStart=/opt/concourse/bin/concourse worker --no-proxy=${no_proxy}
    
    [Install]
    WantedBy=multi-user.target
    

    Using hijack command:

    kam819@h0002020: ~> fly -t lab hijack -j bbr-backup-bosh/export-om-installation
    fly -t lab hijack -j bbr-backup-bosh/export-om-installation
    1: build #1, step: bbr-pipeline-tasks-repo, type: get
    2: build #1, step: export-om-installation, type: task
    3: build #1, step: om-backup-artifact, type: put
    choose a container: 3
    bash-4.4# env
    BUILD_ID=475
    USER=root
    ATC_EXTERNAL_URL=http://XXXXXXXXXXX:8080
    PWD=/tmp/build/put
    HOME=/root
    https_proxy=http://XXXXXXXXXXX:8080/
    http_proxy=http://XXXXXXXXXXX:8080/
    BUILD_PIPELINE_NAME=bbr-backup-bosh
    BUILD_TEAM_NAME=main
    TERM=xterm
    BUILD_JOB_NAME=export-om-installation
    BUILD_NAME=1
    SHLVL=1
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    _=/usr/bin/env
    bash-4.4# 
    

    Variable no_proxy is gone...

  12. databus23 commented on Jun 19, 2018

    @databus23
    ContributorAuthor

    @akamalov strange. this definitely works for us for weeks now.

    EnvironmentFile=-/etc/environment
    ExecStart=/usr/local/bin/concourse worker \
    --tsa-public-key /etc/concourse/tsa-public-key \
    --tsa-worker-private-key /etc/concourse/tsa-worker-private-key \
    --tsa-host XXX:2222 \
    --no-proxy=${no_proxy} \
    --work-dir /workdir \
    --baggageclaim-driver=btrfs
    

    our /etc/environment looks similar to yours.

  13. DaxterM commented on Jun 19, 2018

    @DaxterM
    Contributor

    @akamalov I think @databus23 has EnvironmentFile=-/etc/environment and sets all the other concourse params as command line flags.

    I think you are trying to set the majority of your concourse params inside EnvironmentFile=/etc/concourse/worker_environment . Maybe this could giving trouble?

  14. akamalov commented on Jun 19, 2018

    @akamalov

    I removed proxy references from worker environment file and then I modified /etc/system/system/concourse-worker.service to have the following:

    [Unit]
    Description=Concourse CI worker process
    After=concourse-web.service
    
    [Service]
    User=root
    Restart=on-failure
    EnvironmentFile=/etc/environment
    EnvironmentFile=/etc/concourse/worker_environment
    ExecStart=/opt/concourse/bin/concourse worker --tag=BBR --no-proxy=${no_proxy} --http-proxy=${http_proxy} --https-proxy=${https_proxy}
    [Install]
    WantedBy=multi-user.target
    

    It took the variable thereafter.

    Thanks so much @DaxterM and @databus23

  15. mgruener commented on Jun 20, 2018

    @mgruener

    @databus23 The workaround does not really help me here as I am using the Concourse Helm chart to run Concourse on Kubernetes. And the chart has no way to specify additional command line parameters: https://github.com/kubernetes/charts/blob/master/stable/concourse/templates/worker-statefulset.yaml#L48

    (yes, I could fork and modify it but I am in the middle of moving away from a customized concourse helm chart that I would have to maintain myself).

  16. vito commented on Jul 24, 2018

    @vito
    Contributor

    Gonna close this as vmware-archive/worker#1 was merged. Sorry for the wait, y'all, this will be in the next release (4.0) which has dragged on a bit.

  17. modified the milestone: v4.0.0 on Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions