Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions internal/oci/runtime_oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"path/filepath"
"strconv"
"strings"
"sync"
"syscall"
"time"

Expand Down Expand Up @@ -1294,13 +1295,32 @@

defer controlFile.Close()

var (
lastSize remotecommand.TerminalSize
controlFileLock sync.Mutex
controlFileValid = true
)

utils.HandleResizing(resizeChan, func(size remotecommand.TerminalSize) {
log.Debugf(ctx, "Got a resize event: %+v", size)
controlFileLock.Lock()
defer controlFileLock.Unlock()

if !controlFileValid || size == lastSize {
return
}

Check warning on line 1311 in internal/oci/runtime_oci.go

View check run for this annotation

Codecov / codecov/patch

internal/oci/runtime_oci.go#L1306-L1311

Added lines #L1306 - L1311 were not covered by tests

_, err := fmt.Fprintf(controlFile, "%d %d %d\n", 1, size.Height, size.Width)
if err != nil {
log.Debugf(ctx, "Failed to write to control file to resize terminal: %v", err)

controlFileValid = false

return

Check warning on line 1319 in internal/oci/runtime_oci.go

View check run for this annotation

Codecov / codecov/patch

internal/oci/runtime_oci.go#L1316-L1319

Added lines #L1316 - L1319 were not covered by tests
}

lastSize = size
log.Debugf(ctx, "Resized to %dx%d", size.Width, size.Height)

Check warning on line 1323 in internal/oci/runtime_oci.go

View check run for this annotation

Codecov / codecov/patch

internal/oci/runtime_oci.go#L1322-L1323

Added lines #L1322 - L1323 were not covered by tests
})

attachSocketPath := filepath.Join(r.config.ContainerAttachSocketDir, c.ID(), "attach")
Expand Down
Loading