Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
f8aabc8b
Commit
f8aabc8b
authored
4 years ago
by
Nick Ethier
Committed by
Seth Hoenig
4 years ago
Browse files
Options
Download
Email Patches
Plain Diff
command: use correct port mapping syntax in examples
parent
1c14f698
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
command/assets/example-short.nomad
+3
-1
command/assets/example-short.nomad
command/assets/example.nomad
+3
-1
command/assets/example.nomad
command/job_init.bindata_assetfs.go
+4
-4
command/job_init.bindata_assetfs.go
drivers/docker/driver.go
+3
-0
drivers/docker/driver.go
plugins/drivers/utils_test.go
+71
-0
plugins/drivers/utils_test.go
with
84 additions
and
6 deletions
+84
-6
command/assets/example-short.nomad
+
3
-
1
View file @
f8aabc8b
...
...
@@ -3,7 +3,9 @@ job "example" {
group
"cache"
{
network
{
port
"db"
{}
port
"db"
{
to
=
6379
}
}
task
"redis"
{
...
...
This diff is collapsed.
Click to expand it.
command/assets/example.nomad
+
3
-
1
View file @
f8aabc8b
...
...
@@ -151,7 +151,9 @@ job "example" {
# https://www.nomadproject.io/docs/job-specification/network
#
network
{
port
"db"
{}
port
"db"
{
to
=
6379
}
}
# The "service" stanza instructs Nomad to register this task as a service
...
...
This diff is collapsed.
Click to expand it.
command/job_init.bindata_assetfs.go
+
4
-
4
View file @
f8aabc8b
This diff is collapsed.
Click to expand it.
drivers/docker/driver.go
+
3
-
0
View file @
f8aabc8b
...
...
@@ -1095,6 +1095,9 @@ func (d *Driver) createContainerConfig(task *drivers.TaskConfig, driverConfig *T
default
:
if
len
(
driverConfig
.
PortMap
)
>
0
{
if
task
.
Resources
.
Ports
!=
nil
{
return
c
,
fmt
.
Errorf
(
"'port_map' cannot map group network ports, use 'ports' instead"
)
}
return
c
,
fmt
.
Errorf
(
"Trying to map ports but no network interface is available"
)
}
}
...
...
This diff is collapsed.
Click to expand it.
plugins/drivers/utils_test.go
+
71
-
0
View file @
f8aabc8b
...
...
@@ -3,6 +3,8 @@ package drivers
import
(
"testing"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/stretchr/testify/require"
)
...
...
@@ -32,3 +34,72 @@ func TestResourceUsageRoundTrip(t *testing.T) {
require
.
EqualValues
(
t
,
parsed
,
input
)
}
func
TestTaskConfigRoundTrip
(
t
*
testing
.
T
)
{
input
:=
&
TaskConfig
{
ID
:
uuid
.
Generate
(),
Name
:
"task"
,
JobName
:
"job"
,
TaskGroupName
:
"group"
,
Resources
:
&
Resources
{
NomadResources
:
&
structs
.
AllocatedTaskResources
{
Cpu
:
structs
.
AllocatedCpuResources
{
CpuShares
:
int64
(
100
),
},
Memory
:
structs
.
AllocatedMemoryResources
{
MemoryMB
:
int64
(
300
),
},
},
LinuxResources
:
&
LinuxResources
{
MemoryLimitBytes
:
300
*
1024
*
1024
,
CPUShares
:
100
,
PercentTicks
:
float64
(
100
)
/
float64
(
3200
),
},
Ports
:
&
structs
.
AllocatedPorts
{
{
Label
:
"port"
,
Value
:
23456
,
To
:
8080
,
HostIP
:
"10.0.0.1"
,
},
},
},
Devices
:
[]
*
DeviceConfig
{
{
TaskPath
:
"task"
,
HostPath
:
"host"
,
Permissions
:
"perms"
,
},
},
Mounts
:
[]
*
MountConfig
{
{
TaskPath
:
"task"
,
HostPath
:
"host"
,
Readonly
:
true
,
},
},
Env
:
map
[
string
]
string
{
"gir"
:
"zim"
},
DeviceEnv
:
map
[
string
]
string
{
"foo"
:
"bar"
},
User
:
"user"
,
AllocDir
:
"allocDir"
,
StdoutPath
:
"stdout"
,
StderrPath
:
"stderr"
,
AllocID
:
uuid
.
Generate
(),
NetworkIsolation
:
&
NetworkIsolationSpec
{
Mode
:
NetIsolationModeGroup
,
Path
:
"path"
,
Labels
:
map
[
string
]
string
{
"net"
:
"abc"
},
},
DNS
:
&
DNSConfig
{
Servers
:
[]
string
{
"8.8.8.8"
},
Searches
:
[]
string
{
".consul"
},
Options
:
[]
string
{
"ndots:2"
},
},
}
parsed
:=
taskConfigFromProto
(
taskConfigToProto
(
input
))
require
.
EqualValues
(
t
,
input
,
parsed
)
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment