Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
756325bc
Commit
756325bc
authored
6 years ago
by
Danielle Tomlinson
Browse files
Options
Download
Email Patches
Plain Diff
client: Merge driver/shared/structs and client/structs
parent
9d4329b5
No related merge requests found
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
client/allocrunner/taskrunner/stats_hook.go
+1
-2
client/allocrunner/taskrunner/stats_hook.go
client/allocrunner/taskrunner/stats_hook_test.go
+1
-2
client/allocrunner/taskrunner/stats_hook_test.go
client/allocrunnerdeprecated/taskrunner/task_runner.go
+1
-1
client/allocrunnerdeprecated/taskrunner/task_runner.go
client/structs/structs.go
+8
-0
client/structs/structs.go
drivers/docker/handle.go
+2
-3
drivers/docker/handle.go
drivers/shared/executor/executor.go
+1
-2
drivers/shared/executor/executor.go
drivers/shared/executor/executor_linux.go
+1
-2
drivers/shared/executor/executor_linux.go
drivers/shared/structs/structs.go
+0
-10
drivers/shared/structs/structs.go
with
15 additions
and
22 deletions
+15
-22
client/allocrunner/taskrunner/stats_hook.go
+
1
-
2
View file @
756325bc
...
...
@@ -9,7 +9,6 @@ import (
hclog
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/nomad/client/allocrunner/interfaces"
cstructs
"github.com/hashicorp/nomad/client/structs"
dstructs
"github.com/hashicorp/nomad/drivers/shared/structs"
)
// StatsUpdater is the interface required by the StatsHook to update stats.
...
...
@@ -95,7 +94,7 @@ func (h *statsHook) collectResourceUsageStats(handle interfaces.DriverStats, sto
ru
,
err
:=
handle
.
Stats
()
if
err
!=
nil
{
// Check if the driver doesn't implement stats
if
err
.
Error
()
==
d
structs
.
DriverStatsNotImplemented
.
Error
()
{
if
err
.
Error
()
==
c
structs
.
DriverStatsNotImplemented
.
Error
()
{
h
.
logger
.
Debug
(
"driver does not support stats"
)
return
}
...
...
This diff is collapsed.
Click to expand it.
client/allocrunner/taskrunner/stats_hook_test.go
+
1
-
2
View file @
756325bc
...
...
@@ -7,7 +7,6 @@ import (
"github.com/hashicorp/nomad/client/allocrunner/interfaces"
cstructs
"github.com/hashicorp/nomad/client/structs"
dstructs
"github.com/hashicorp/nomad/drivers/shared/structs"
"github.com/hashicorp/nomad/helper/testlog"
"github.com/stretchr/testify/require"
)
...
...
@@ -160,7 +159,7 @@ func TestTaskRunner_StatsHook_NotImplemented(t *testing.T) {
logger
:=
testlog
.
HCLogger
(
t
)
su
:=
newMockStatsUpdater
()
ds
:=
&
mockDriverStats
{
err
:
d
structs
.
DriverStatsNotImplemented
,
err
:
c
structs
.
DriverStatsNotImplemented
,
}
poststartReq
:=
&
interfaces
.
TaskPoststartRequest
{
DriverStats
:
ds
}
...
...
This diff is collapsed.
Click to expand it.
client/allocrunnerdeprecated/taskrunner/task_runner.go
+
1
-
1
View file @
756325bc
...
...
@@ -1601,7 +1601,7 @@ func (r *TaskRunner) collectResourceUsageStats(stopCollection <-chan struct{}) {
if
err
!=
nil
{
// Check if the driver doesn't implement stats
if
err
.
Error
()
==
d
structs
.
DriverStatsNotImplemented
.
Error
()
{
if
err
.
Error
()
==
c
structs
.
DriverStatsNotImplemented
.
Error
()
{
r
.
logger
.
Printf
(
"[DEBUG] client: driver for task %q in allocation %q doesn't support stats"
,
r
.
task
.
Name
,
r
.
alloc
.
ID
)
return
}
...
...
This diff is collapsed.
Click to expand it.
client/structs/structs.go
+
8
-
0
View file @
756325bc
...
...
@@ -4,6 +4,7 @@ package structs
import
(
"crypto/md5"
"errors"
"io"
"strconv"
"time"
...
...
@@ -437,3 +438,10 @@ func (h *HealthCheckResponse) AddDriverInfo(name string, driverInfo *structs.Dri
h
.
Drivers
[
name
]
=
driverInfo
}
// CheckBufSize is the size of the buffer that is used for job output
const
CheckBufSize
=
4
*
1024
// DriverStatsNotImplemented is the error to be returned if a driver doesn't
// implement stats.
var
DriverStatsNotImplemented
=
errors
.
New
(
"stats not implemented for driver"
)
This diff is collapsed.
Click to expand it.
drivers/docker/handle.go
+
2
-
3
View file @
756325bc
...
...
@@ -15,7 +15,6 @@ import (
plugin
"github.com/hashicorp/go-plugin"
cstructs
"github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/drivers/docker/docklog"
dstructs
"github.com/hashicorp/nomad/drivers/shared/structs"
"github.com/hashicorp/nomad/helper/stats"
"github.com/hashicorp/nomad/plugins/drivers"
"github.com/hashicorp/nomad/plugins/shared"
...
...
@@ -83,8 +82,8 @@ func (h *taskHandle) Exec(ctx context.Context, cmd string, args []string) (*driv
}
execResult
:=
&
drivers
.
ExecTaskResult
{
ExitResult
:
&
drivers
.
ExitResult
{}}
stdout
,
_
:=
circbuf
.
NewBuffer
(
int64
(
d
structs
.
CheckBufSize
))
stderr
,
_
:=
circbuf
.
NewBuffer
(
int64
(
d
structs
.
CheckBufSize
))
stdout
,
_
:=
circbuf
.
NewBuffer
(
int64
(
c
structs
.
CheckBufSize
))
stderr
,
_
:=
circbuf
.
NewBuffer
(
int64
(
c
structs
.
CheckBufSize
))
startOpts
:=
docker
.
StartExecOptions
{
Detach
:
false
,
Tty
:
false
,
...
...
This diff is collapsed.
Click to expand it.
drivers/shared/executor/executor.go
+
1
-
2
View file @
756325bc
...
...
@@ -24,7 +24,6 @@ import (
"github.com/hashicorp/consul-template/signals"
cstructs
"github.com/hashicorp/nomad/client/structs"
dstructs
"github.com/hashicorp/nomad/drivers/shared/structs"
)
const
(
...
...
@@ -321,7 +320,7 @@ func ExecScript(ctx context.Context, dir string, env []string, attrs *syscall.Sy
cmd
.
Env
=
env
// Capture output
buf
,
_
:=
circbuf
.
NewBuffer
(
int64
(
d
structs
.
CheckBufSize
))
buf
,
_
:=
circbuf
.
NewBuffer
(
int64
(
c
structs
.
CheckBufSize
))
cmd
.
Stdout
=
buf
cmd
.
Stderr
=
buf
...
...
This diff is collapsed.
Click to expand it.
drivers/shared/executor/executor_linux.go
+
1
-
2
View file @
756325bc
...
...
@@ -19,7 +19,6 @@ import (
multierror
"github.com/hashicorp/go-multierror"
"github.com/hashicorp/nomad/client/stats"
cstructs
"github.com/hashicorp/nomad/client/structs"
dstructs
"github.com/hashicorp/nomad/drivers/shared/structs"
"github.com/hashicorp/nomad/helper/discover"
shelpers
"github.com/hashicorp/nomad/helper/stats"
"github.com/hashicorp/nomad/helper/uuid"
...
...
@@ -403,7 +402,7 @@ func (l *LibcontainerExecutor) Signal(s os.Signal) error {
func
(
l
*
LibcontainerExecutor
)
Exec
(
deadline
time
.
Time
,
cmd
string
,
args
[]
string
)
([]
byte
,
int
,
error
)
{
combined
:=
append
([]
string
{
cmd
},
args
...
)
// Capture output
buf
,
_
:=
circbuf
.
NewBuffer
(
int64
(
d
structs
.
CheckBufSize
))
buf
,
_
:=
circbuf
.
NewBuffer
(
int64
(
c
structs
.
CheckBufSize
))
process
:=
&
libcontainer
.
Process
{
Args
:
combined
,
...
...
This diff is collapsed.
Click to expand it.
drivers/shared/structs/structs.go
deleted
100644 → 0
+
0
-
10
View file @
9d4329b5
package
structs
import
"errors"
// CheckBufSize is the size of the buffer that is used for job output
const
CheckBufSize
=
4
*
1024
// DriverStatsNotImplemented is the error to be returned if a driver doesn't
// implement stats.
var
DriverStatsNotImplemented
=
errors
.
New
(
"stats not implemented for driver"
)
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
Menu
Projects
Groups
Snippets
Help