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

Levant and Nomad 0.8 issues #139

Closed
maksym-iv opened this issue Apr 18, 2018 · 1 comment
Closed

Levant and Nomad 0.8 issues #139

maksym-iv opened this issue Apr 18, 2018 · 1 comment

Comments

@maksym-iv
Copy link
Contributor

Description

After additional tests I've discovered that Levant job file validation fails with Nomad 0.8 job file version.
With 0.8 Nomad lib and 0.0.4 version deploy seems working.
In 0.8 added:

  • reschedule stanza
  • check_restart can be defined at service level
  • cpu_hard_limit docker driver opt

Relevant Nomad job specification file

job "[[ .PREFIX ]]-[[ .PROJECT ]]-[[ .DEPLOY_ENV ]]" {
  region = "us"
  datacenters = ["us-west-1"]

  #     https://www.nomadproject.io/docs/jobspec/schedulers.html
  type = "service"

  group "main" {
    count = 1
    constraint {
      operator  = "distinct_property"
      attribute = "${node.unique.id}"
      value     = "2"
    }

    update {
      max_parallel = 1
      min_healthy_time = "15s"
      healthy_deadline = "1m"
      auto_revert = true
      canary = 1
      stagger = "30s"
    }
    meta {
      scale_factor = 100
      prefix = "[[ .PREFIX ]]"
      project = "[[ .PROJECT ]]"
      deploy_env = "[[ .DEPLOY_ENV ]]"
      server_env = "[[ .SERVER_ENV ]]"
      commit_hash = "[[ .COMMIT_HASH ]]"
    }

    restart {
      attempts = 17
      interval = "5m"
      delay = "15s"
      mode = "delay"
    }

    reschedule {
      delay          = "15s"
      delay_function = "exponential"
      max_delay      = "30m"
      unlimited      = true
    }

    ephemeral_disk {
      sticky = false
      migrate = false
      size = 128
    }

    task "[[ .PROJECT ]]-[[ .DEPLOY_ENV ]]" {
      driver = "docker"

      config {
        image = "registry.address.com/[[ .IMAGE ]]"
        force_pull = true
        cpu_hard_limit = true
        port_map {
          http = 80
        }
        // dns_servers
        labels {
          service = "[[ .PROJECT ]]"
          build_id = "[[ .BUILD_ID ]]"
        }
      }

      env {
      }
      logs {
        max_files     = 10
        max_file_size = 10
      }

      resources {
        cpu    = [[ .CPU ]]    # In MHz. Not a limit. Just for placement
        memory = [[ .MEMORY ]] # in MB
        network {
          mbits = 1   # Not a limit. Just for placement
          port "http" {
            # static = 6579   # for static mapping
          }
        }
      }

      service {
        name = "[[ .PREFIX ]]-[[ .PROJECT ]]-[[ .DEPLOY_ENV ]]"
        tags = [
          "urlprefix_pub-[[ .DOMAIN ]]/",
          "traefik.enable=true",
          "traefik.frontend.rule=Host:[[ .DOMAIN ]]",
        ]
        address_mode = "host"
        port = "http"
        check {
          name     = "[[ .PREFIX ]]-[[ .PROJECT ]]-[[ .DEPLOY_ENV ]]-http"
          type     = "http"   # possible script, http, tcp
          protocol = "http"
          path    = "/healthcheck.php"
          port    = "http"
          interval = "5s"
          timeout  = "3s"    # timeout_http
        }
        check {
          name     = "[[ .PREFIX ]]-[[ .PROJECT ]]-[[ .DEPLOY_ENV ]]-process"
          type     = "script"   # possible script, http, tcp
          command = "cat"
          args = [
            "/proc/1/stat"
          ]
          interval = "5s"
          timeout  = "1s"    # timeout_process
        }
        check_restart {
          limit = 2
          grace  = "5s"   # timeout_http
          ignore_warnings = false
        }
      }
    }
  }
}

Output of levant version:

# levant version
Levant v0.0.4

Output of consul version:

# consul version
Consul v1.0.7

Output of nomad version:

# nomad version
Nomad v0.8.0 (751b42aaa60f1bc679e5062e16db7d15f8ff9654)

Debug log outputs from Levant:

# levant deploy -var-file=service.yaml -canary-auto-promote=60 service.levant.nomad
2018/04/18 10:18:02 UTC [INFO] helper/variable: using variable with key COMMIT_HASH and value d195ced from file
2018/04/18 10:18:02 UTC [INFO] helper/variable: using variable with key DEPLOY_ENV and value stg from file
2018/04/18 10:18:02 UTC [INFO] helper/variable: using variable with key IMAGE and value px-pws-tf:commit_d195ced from file
2018/04/18 10:18:02 UTC [INFO] helper/variable: using variable with key SERVER_ENV and value dev from file
2018/04/18 10:18:02 UTC [INFO] helper/variable: using variable with key CPU and value 1000 from file
2018/04/18 10:18:02 UTC [INFO] helper/variable: using variable with key CPU_HARD and value false from file
2018/04/18 10:18:02 UTC [INFO] helper/variable: using variable with key DOMAIN and value stg.pws.px-dev.com from file
2018/04/18 10:18:02 UTC [INFO] helper/variable: using variable with key BUILD_ID and value 26 from file
2018/04/18 10:18:02 UTC [INFO] helper/variable: using variable with key REGION and value us from file
2018/04/18 10:18:02 UTC [INFO] helper/variable: using variable with key DC and value us-west-1 from file
2018/04/18 10:18:02 UTC [INFO] helper/variable: using variable with key PREFIX and value px from file
2018/04/18 10:18:02 UTC [INFO] helper/variable: using variable with key PROJECT and value pws from file
2018/04/18 10:18:02 UTC [INFO] helper/variable: using variable with key MEMORY and value 400 from file
[ERROR] levant/command: error parsing 'job': 1 error occurred:
group: 'main' -> invalid key: reschedule
@jrasell
Copy link
Member

jrasell commented Apr 18, 2018

@xmackex thanks a lot for this. #137 Will fix this, so I will now get this in before 0.1.0 release

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

No branches or pull requests

2 participants