Skip to content

Commit

Permalink
Review cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
towe75 committed Feb 2, 2021
1 parent 55d4420 commit 4219d92
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
6 changes: 3 additions & 3 deletions api/exec_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
7 changes: 4 additions & 3 deletions api/exec_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/hashicorp/nomad/plugins/drivers"
)

// ExecStartRequest prepares to stream a exec session
type ExecStartRequest struct {

// streams
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4219d92

Please sign in to comment.