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

Variable expansion not working with mutations #1224

Closed
ygersie opened this issue Jun 1, 2016 · 4 comments
Closed

Variable expansion not working with mutations #1224

ygersie opened this issue Jun 1, 2016 · 4 comments

Comments

@ygersie
Copy link
Contributor

ygersie commented Jun 1, 2016

Nomad v0.3.2
Consul v0.6.4
Description: Ubuntu 14.04.4 LTS

I have a simple test job specification running a python web server. The service gets registered in Consul including a script health check. This works flawless except for variable expansion during "updates".
When I change the group count and perform nomad run web.nomad I get a service health check in Consul looking like this:

{
    "a4dfbee8062f8fc7be3fe2200c2c23810671b5e5": {
        "Node": "nomad",
        "CheckID": "a4dfbee8062f8fc7be3fe2200c2c23810671b5e5",
        "Name": "check_http_800${NOMAD_ALLOC_INDEX}",
        "ServiceName": "webservice",
        "Notes": "",
        "ModifyIndex": 0,
        "Status": "critical",
        "ServiceID": "nomad-registered-service-cd0c8730-75fa-3f3d-7aff-8f0a039cc3d1-web001-b5457a5a7acdb01c65b3afa23ffa66d0891b691b",
        "Output": "FAIL\n",
        "CreateIndex": 0
    }
}

The expansion of ${NOMAD_ALLOC_INDEX} (and probably other variables) doesn't happen for either the service name in consul and the actual command + args of that service (again, only during updates, the initial job run is doing it correctly).

Job file:

job "web" {
    region = "global"
    datacenters = ["dc1"]
    type = "service"
    priority = 50

    constraint {
        attribute = "${attr.kernel.name}"
        value = "linux"
    }

    update {
        # Stagger updates every 30 seconds
        stagger = "30s"

        # Update a single task at a time
        max_parallel = 1
    }

    group "webservers" {
        count = 1

        restart {
            attempts = 10
            interval = "1m"
            delay = "5s"
            mode = "fail"
        }

        task "web001" {
            driver = "exec"

            config {
                command = "/usr/bin/python"
                args = ["-m", "SimpleHTTPServer", "800${NOMAD_ALLOC_INDEX}"]
            }

            service {
                name = "webservice"
                tags = ["http", "python", "master"]
                check {
                    type = "script"
                    name = "check_http_800${NOMAD_ALLOC_INDEX}"
                    command = "/usr/local/bin/health.sh"
                    args = ["800${NOMAD_ALLOC_INDEX}"]
                    interval = "5s"
                    timeout = "1s"
                }
            }

            resources {
                cpu = 500
                memory = 64
                network {
                    mbits = 10
                }
            }
        }
    }
}
@dadgar
Copy link
Contributor

dadgar commented Jun 2, 2016

Nice find! Will get this fixed! Thanks

@diptanu
Copy link
Contributor

diptanu commented Jun 12, 2016

@sean- Can you please verify whether your PR fixes this?

@diptanu
Copy link
Contributor

diptanu commented Jun 12, 2016

I can see the codepath of updating the task is interpolating the service tags as well, so closing it. Fixed by #1201

@diptanu diptanu closed this as completed Jun 12, 2016
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants