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
50862f8e
Commit
50862f8e
authored
9 years ago
by
Alex Dadgar
Browse files
Options
Download
Email Patches
Plain Diff
Switch to using BlkioWeight
parent
095dc9ae
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
api/compose_test.go
+2
-2
api/compose_test.go
api/tasks_test.go
+1
-1
api/tasks_test.go
client/executor/exec_linux.go
+11
-8
client/executor/exec_linux.go
website/source/docs/jobspec/index.html.md
+1
-1
website/source/docs/jobspec/index.html.md
with
15 additions
and
12 deletions
+15
-12
api/compose_test.go
+
2
-
2
View file @
50862f8e
...
...
@@ -15,7 +15,7 @@ func TestCompose(t *testing.T) {
CPU
:
1250
,
MemoryMB
:
1024
,
DiskMB
:
2048
,
IOPS
:
1024
,
IOPS
:
500
,
Networks
:
[]
*
NetworkResource
{
&
NetworkResource
{
CIDR
:
"0.0.0.0/0"
,
...
...
@@ -81,7 +81,7 @@ func TestCompose(t *testing.T) {
CPU
:
1250
,
MemoryMB
:
1024
,
DiskMB
:
2048
,
IOPS
:
1024
,
IOPS
:
500
,
Networks
:
[]
*
NetworkResource
{
&
NetworkResource
{
CIDR
:
"0.0.0.0/0"
,
...
...
This diff is collapsed.
Click to expand it.
api/tasks_test.go
+
1
-
1
View file @
50862f8e
...
...
@@ -169,7 +169,7 @@ func TestTask_Require(t *testing.T) {
CPU
:
1250
,
MemoryMB
:
128
,
DiskMB
:
2048
,
IOPS
:
1024
,
IOPS
:
500
,
Networks
:
[]
*
NetworkResource
{
&
NetworkResource
{
CIDR
:
"0.0.0.0/0"
,
...
...
This diff is collapsed.
Click to expand it.
client/executor/exec_linux.go
+
11
-
8
View file @
50862f8e
...
...
@@ -87,7 +87,7 @@ func (e *LinuxExecutor) Limit(resources *structs.Resources) error {
}
if
e
.
cgroupEnabled
{
e
.
configureCgroups
(
resources
)
return
e
.
configureCgroups
(
resources
)
}
return
nil
...
...
@@ -168,9 +168,9 @@ func (e *LinuxExecutor) cleanTaskDir() error {
return
errs
.
ErrorOrNil
()
}
func
(
e
*
LinuxExecutor
)
configureCgroups
(
resources
*
structs
.
Resources
)
{
func
(
e
*
LinuxExecutor
)
configureCgroups
(
resources
*
structs
.
Resources
)
error
{
if
!
e
.
cgroupEnabled
{
return
return
nil
}
e
.
groups
=
&
cgroupConfig
.
Cgroup
{}
...
...
@@ -204,13 +204,16 @@ func (e *LinuxExecutor) configureCgroups(resources *structs.Resources) {
e
.
groups
.
CpuShares
=
int64
(
resources
.
CPU
)
}
if
resources
.
IOPS
>
0
{
throttleDevice
:=
&
cgroupConfig
.
ThrottleDevice
{
Rate
:
uint64
(
resources
.
IOPS
),
if
resources
.
IOPS
!=
0
{
// Validate it is in an acceptable range.
if
resources
.
IOPS
<
10
||
resources
.
IOPS
>
1000
{
return
fmt
.
Errorf
(
"resources.IOPS must be between 10 and 1000: %d"
,
resources
.
IOPS
)
}
e
.
groups
.
BlkioThrottleReadIOPSDevice
=
append
(
e
.
groups
.
BlkioThrottleReadIOPSDevice
,
throttleDevice
)
e
.
groups
.
Blkio
ThrottleWriteIOPSDevice
=
append
(
e
.
groups
.
BlkioThrottleWriteIOPSDevice
,
throttleDevice
)
e
.
groups
.
Blkio
Weight
=
uint16
(
resources
.
IOPS
)
}
return
nil
}
func
(
e
*
LinuxExecutor
)
runAs
(
userid
string
)
error
{
...
...
This diff is collapsed.
Click to expand it.
website/source/docs/jobspec/index.html.md
+
1
-
1
View file @
50862f8e
...
...
@@ -187,7 +187,7 @@ The `resources` object supports the following keys:
*
`disk`
- The disk required in MB.
*
`iops`
- The number of IOPS required.
*
`iops`
- The number of IOPS required
given as a weight between 10-1000
.
*
`memory`
- The memory required in MB.
...
...
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