hashicorp / nomad

Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations.
https://www.nomadproject.io/
Other
14.87k stars 1.95k forks source link

Docker driver cpu_hard_limit is not valid #19768

Closed suikast42 closed 9 months ago

suikast42 commented 9 months ago

I try to set the cpu_hard_limit in nomad agent client config as shown below

plugin "docker" {
  config {
    allow_privileged = false
    # Default is false. Use hard CPU limiting instead of soft limiting
    #  By default this is false which means soft limiting is used and containers
    # are able to burst above their CPU limit when there is idle capacity.
    # For overcumsuming cpu set this value in your job->group->task->config stanza
    cpu_hard_limit = true
    disable_log_collection  = false
#    volumes {
#      enabled = true
#      selinuxlabel = "z"
#    }
    infra_image = "{{nomad_infra_image}}"
    infra_image_pull_timeout ="30m"
    extra_labels = ["job_name", "job_id", "task_group_name", "task_name", "namespace", "node_name", "node_id"]
    logging {
      type = "journald"
       config {
          labels-regex =".*"
       }
    }
    gc{
      container = true
      dangling_containers{
        enabled = true
      # period = "3m"
      # creation_grace = "5m"
      }
    }

  }
}

But nomad says that the cpu_hard_limit setting is not present.

But I can set this property in nomad job like https://github.com/hashicorp/nomad/issues/19758

Jan 17 16:20:42 worker-01 nomad[39702]: ==> Starting Nomad agent...
Jan 17 16:20:42 worker-01 nomad[39702]: ==> Error starting agent: failed to create plugin loader: failed to initialize plugin loader: parsing plugin configurations failed: 1 error occurred:
Jan 17 16:20:42 worker-01 nomad[39702]:         * plugin "docker" (driver): failed to parse config:  Invalid label: No argument or block type is named "cpu_hard_limit".
Jan 17 16:20:42 worker-01 nomad[39702]:     2024-01-17T16:20:42.798Z [WARN]  agent.plugin_loader: skipping external plugins since plugin_dir doesn't exist: plugin_dir=/opt/services/core/nomad/data/plugins
Jan 17 16:20:42 worker-01 nomad[39702]:     2024-01-17T16:20:42.800Z [ERROR] agent: error starting agent:
Jan 17 16:20:42 worker-01 nomad[39702]:   error=
Jan 17 16:20:42 worker-01 nomad[39702]:   | failed to create plugin loader: failed to initialize plugin loader: parsing plugin configurations failed: 1 error occurred:
Jan 17 16:20:42 worker-01 nomad[39702]:   | \t* plugin "docker" (driver): failed to parse config:  Invalid label: No argument or block type is named "cpu_hard_limit".
Jan 17 16:20:42 worker-01 nomad[39702]:   |
Jan 17 16:20:42 worker-01 nomad[39702]:

Nomad Version

Nomad v1.7.3 BuildDate 2024-01-15T16:55:40Z Revision https://github.com/hashicorp/nomad/commit/60ee328f97d19d2d2d9761251b895b06d82eb1a1

Nomad Client logs (if appropriate)

tgross commented 9 months ago

@suikast42 the cpu_hard_limit configuration is a task.config field, not a plugin.config field.

suikast42 commented 9 months ago

I didn't realize that. Sorry. Can we make a featrure request for that ?

For my usecase that's makes more sense to have it as default = true.