mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 01:45:44 +03:00
client: Merge driver/shared/structs and client/structs
This commit is contained in:
@@ -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() == dstructs.DriverStatsNotImplemented.Error() {
|
||||
if err.Error() == cstructs.DriverStatsNotImplemented.Error() {
|
||||
h.logger.Debug("driver does not support stats")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -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: dstructs.DriverStatsNotImplemented,
|
||||
err: cstructs.DriverStatsNotImplemented,
|
||||
}
|
||||
|
||||
poststartReq := &interfaces.TaskPoststartRequest{DriverStats: ds}
|
||||
|
||||
@@ -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() == dstructs.DriverStatsNotImplemented.Error() {
|
||||
if err.Error() == cstructs.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
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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(dstructs.CheckBufSize))
|
||||
stderr, _ := circbuf.NewBuffer(int64(dstructs.CheckBufSize))
|
||||
stdout, _ := circbuf.NewBuffer(int64(cstructs.CheckBufSize))
|
||||
stderr, _ := circbuf.NewBuffer(int64(cstructs.CheckBufSize))
|
||||
startOpts := docker.StartExecOptions{
|
||||
Detach: false,
|
||||
Tty: false,
|
||||
|
||||
@@ -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(dstructs.CheckBufSize))
|
||||
buf, _ := circbuf.NewBuffer(int64(cstructs.CheckBufSize))
|
||||
cmd.Stdout = buf
|
||||
cmd.Stderr = buf
|
||||
|
||||
|
||||
@@ -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(dstructs.CheckBufSize))
|
||||
buf, _ := circbuf.NewBuffer(int64(cstructs.CheckBufSize))
|
||||
|
||||
process := &libcontainer.Process{
|
||||
Args: combined,
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
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")
|
||||
Reference in New Issue
Block a user