From f37dedc3bcf9173f7b42f402c0a30cd19efb85ca Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Wed, 23 Sep 2015 15:19:31 -0700 Subject: [PATCH] Changed to uppercase + numbers + underscores; updated docs --- jobspec/parse.go | 2 +- .../source/docs/jobspec/environment.html.md | 38 +++++++++---------- website/source/docs/jobspec/index.html.md | 10 ++--- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/jobspec/parse.go b/jobspec/parse.go index a826f50a3..5255bcf13 100644 --- a/jobspec/parse.go +++ b/jobspec/parse.go @@ -344,7 +344,7 @@ func parseTasks(result *[]*structs.Task, obj *hclobj.Object) error { return nil } -var reDynamicPorts *regexp.Regexp = regexp.MustCompile("^[a-z0-9_]+$") +var reDynamicPorts *regexp.Regexp = regexp.MustCompile("^[A-Z0-9_]+$") var errDynamicPorts = fmt.Errorf("DynamicPort label does not conform to naming requirements %s", reDynamicPorts.String()) func parseResources(result *structs.Resources, obj *hclobj.Object) error { diff --git a/website/source/docs/jobspec/environment.html.md b/website/source/docs/jobspec/environment.html.md index 440642561..25dce12a5 100644 --- a/website/source/docs/jobspec/environment.html.md +++ b/website/source/docs/jobspec/environment.html.md @@ -26,37 +26,33 @@ Nomad will pass CPU and memory to your job as `NOMAD_CPU_LIMIT` and fit inside the resource allocation that nomad provides. For example, you can use the memory limit to inform how large your in-process cache should be, or to decide when to flush buffers to disk. - -Both CPU and memory are presented as integers. The unit for CPU limit is `1024 = 1Ghz`. The unit for memory is megabytes. + +Both CPU and memory are presented as integers. The unit for CPU limit is +`1024 = 1Ghz`. The unit for memory `1 = 1 megabytes`. Writing your applications to adjust to these values at runtime provides greater scheduling flexibility since you can adjust the resource allocations in your -jobspec without needing to change your code. You can also schedule workloads that -use dynamic resource allocations so they can scale down/up as your cluster gets -more or less busy. +jobspec without needing to change your code. You can also schedule workloads +that accept dynamic resource allocations so they can scale down/up as your +cluster gets more or less busy. ### IPs and Named Ports Each task will receive port allocations on a single IP address. The IP is made available through `NOMAD_IP.` -If you requested reserved ports in your jobspec and your task is successfully scheduled, these ports are available for your use. Ports from `reserved_ports` in the job spec -are not exposed through the environment. If you requested dynamic ports in your -jobspec these are made known to your application via environment variables -`NOMAD_PORT_{LABEL}`. For example `dynamic_ports = ["http"]` becomes -`NOMAD_PORT_HTTP`. +If you requested reserved ports in your jobspec and your task is successfully +scheduled, these ports are available for your use. Ports from `reserved_ports` +in the job spec are not exposed through the environment. If you requested +dynamic ports in your jobspec these are made known to your application via +environment variables `NOMAD_PORT_{LABEL}`. For example +`dynamic_ports = ["HTTP"]` becomes `NOMAD_PORT_HTTP`. -Some drivers such as Docker and QEMU use port mapping. With port mapping the -application code can run on a fixed port and nomad will automatically map a -random allocated port in the driver. In this case, you should use numeric port -labels to indicate which ports are exposed in your container or VM. For example -with `dynamic_ports = ["5000"]` Docker will automatically map the allocated host -port to port 5000 in the container. - -Even with automatic port mapping, numeric ports are also exported via -environment variables such as `NOMAD_PORT_5000` so you can use these with -drivers that do not support port mapping. You may also be able to use named -ports if you want to bind to a dynamic port inside a container or VM. +Some drivers such as Docker and QEMU use port mapping. If a driver supports port +mapping and you specify a numeric label, the label will be automatically used as +the private port number. For example, `dynamic_ports = ["5000"]` will have a +random port mapped to port 5000 inside the container or VM. These ports are also +exported as environment variables for consistency, e.g. `NOMAD_PORT_5000`. Please see the relevant driver documentation for exact details. diff --git a/website/source/docs/jobspec/index.html.md b/website/source/docs/jobspec/index.html.md index f1cd58604..c1c3bcf34 100644 --- a/website/source/docs/jobspec/index.html.md +++ b/website/source/docs/jobspec/index.html.md @@ -185,11 +185,11 @@ The `resources` object supports the following keys: The `network` object supports teh following keys: -* `dynamic_ports` - List of port labels which may contain letters, numbers and underscores. - Each label will be associated with a dynamic port when the task starts. Port allocation - will be passed to the task as an environment variable like `NOMAD_PORT_{{ .Label }}` - (upper-cased). Some Drivers may infer additional semantics from the label. See - [Docker](/docs/drivers/docker.html) for an example. +* `dynamic_ports` - List of port labels which may contain uppercase letters, + numbers and underscores (`^[A-Z0-9_]+$`). Each label will be assigned a + dynamic port when the task starts. Ports are passed to the task environment as + `NOMAD_PORT_{LABEL}`. Drivers may infer additional semantics from the label. + See the relevant driver docs for details. * `mbits` - The number of MBits in bandwidth required.