diff --git a/api/exec_create.go b/api/exec_create.go index a1fbeaa4..1e5e3847 100644 --- a/api/exec_create.go +++ b/api/exec_create.go @@ -47,9 +47,9 @@ type ExecConfig struct { Privileged bool `json:"Privileged,omitempty"` } -// +// ExecSessionResponse contains the ID of a newly created exec session type ExecSessionResponse struct { - Id string + ID string } // ExecCreate creates an exec session to run a command inside a running container @@ -81,5 +81,5 @@ func (c *API) ExecCreate(ctx context.Context, name string, config ExecConfig) (s if err != nil { return "", err } - return execResponse.Id, err + return execResponse.ID, err } diff --git a/api/exec_start.go b/api/exec_start.go index ea45720f..0e195d43 100644 --- a/api/exec_start.go +++ b/api/exec_start.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/nomad/plugins/drivers" ) +// ExecStartRequest prepares to stream a exec session type ExecStartRequest struct { // streams @@ -87,7 +88,7 @@ func (c *API) attachHandleResize(ctx context.Context, resizeChannel <-chan drive c.logger.Warn("Resize handler is done") return case size := <-resizeChannel: - c.logger.Debug("Resize terminal", "sessionId", sessionId, "height", size.Height, "width", size.Width) + c.logger.Trace("Resize terminal", "sessionId", sessionId, "height", size.Height, "width", size.Width) rerr := c.ExecResize(ctx, sessionId, size.Height, size.Width) if rerr != nil { c.logger.Warn("failed to resize TTY", "err", rerr) @@ -98,7 +99,8 @@ func (c *API) attachHandleResize(ctx context.Context, resizeChannel <-chan drive // ExecStartAndAttach starts and attaches to a given exec session. func (c *API) ExecStart(ctx context.Context, sessionID string, options ExecStartRequest) error { - client := *c.httpClient + client := new(http.Client) + *client = *c.httpClient client.Timeout = 0 var socket net.Conn @@ -170,7 +172,6 @@ func (c *API) ExecStart(ctx context.Context, sessionID string, options ExecStart return err } } else { - // logrus.Debugf("Handling non-terminal attach to exec") for { // Read multiplexed channels and write to appropriate stream fd, l, err := DemuxHeader(socket, buffer) diff --git a/driver.go b/driver.go index 1911c403..fa1c5fd6 100644 --- a/driver.go +++ b/driver.go @@ -721,8 +721,16 @@ func (d *Driver) ExecTask(taskID string, cmd []string, timeout time.Duration) (* d.logger.Error("Unable to create ExecTask session", "err", err) return nil, err } - stdout, _ := circbuf.NewBuffer(int64(drivers.CheckBufSize)) - stderr, _ := circbuf.NewBuffer(int64(drivers.CheckBufSize)) + stdout, err := circbuf.NewBuffer(int64(drivers.CheckBufSize)) + if err != nil { + d.logger.Error("ExecTask session failed, unable to allocate stdout buffer", "sessionId", sessionId, "err", err) + return nil, err + } + stderr, err := circbuf.NewBuffer(int64(drivers.CheckBufSize)) + if err != nil { + d.logger.Error("ExecTask session failed, unable to allocate stderr buffer", "sessionId", sessionId, "err", err) + return nil, err + } startRequest := api.ExecStartRequest{ Tty: false, AttachInput: false,