Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,14 @@ testing_task:
setup_environment_script: '$SCRIPT_BASE/setup_environment.sh |& ${TIMESTAMP}'
unit_test_script: '$SCRIPT_BASE/unit_test.sh |& ${TIMESTAMP}'
integration_test_script: '$SCRIPT_BASE/integration_test.sh |& ${TIMESTAMP}'
ginkgo_node_logs_script: 'cat $CIRRUS_WORKING_DIR/test/e2e/ginkgo-node-*.log || echo "Ginkgo node logs not found"'
audit_log_script: 'cat /var/log/audit/audit.log || cat /var/log/kern.log'
journalctl_b_script: 'journalctl -b'

on_failure:
failed_master_script: '$CIRRUS_WORKING_DIR/$SCRIPT_BASE/notice_master_failure.sh'
# Job has already failed, don't fail again and miss collecting data
failed_ginkgo_node_logs_script: 'cat $CIRRUS_WORKING_DIR/test/e2e/ginkgo-node-*.log || echo "Ginkgo node logs not found"'
failed_audit_log_script: 'cat /var/log/audit/audit.log || cat /var/log/kern.log || echo "Uh oh, cat audit.log failed"'
failed_journalctl_b_script: 'journalctl -b || echo "Uh oh, journalctl -b failed"'

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ localunit: test/goecho/goecho varlink_generate
./contrib/cirrus/lib.sh.t

ginkgo:
ginkgo -v -tags "$(BUILDTAGS)" $(GINKGOTIMEOUT) -cover -flakeAttempts 3 -progress -trace -noColor -nodes 3 test/e2e/.
ginkgo -v -tags "$(BUILDTAGS)" $(GINKGOTIMEOUT) -cover -flakeAttempts 3 -progress -trace -noColor -nodes 3 -debug test/e2e/.

ginkgo-remote:
ginkgo -v -tags "$(BUILDTAGS) remoteclient" $(GINKGOTIMEOUT) -cover -flakeAttempts 3 -progress -trace -noColor test/e2e/.
ginkgo -v -tags "$(BUILDTAGS) remoteclient" $(GINKGOTIMEOUT) -cover -flakeAttempts 3 -progress -trace -noColor -nodes 3 -debug test/e2e/.

localintegration: varlink_generate test-binaries ginkgo ginkgo-remote

Expand Down
12 changes: 10 additions & 2 deletions libpod/container_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io/ioutil"
"os"
"strconv"
"sync"
"time"

"github.com/containers/libpod/libpod/driver"
Expand Down Expand Up @@ -119,13 +120,20 @@ func (c *Container) StartAndAttach(ctx context.Context, streams *AttachStreams,

attachChan := make(chan error)

// We need to ensure that we don't return until start() fired in attach.
// Use a WaitGroup to sync this.
wg := new(sync.WaitGroup)
wg.Add(1)

// Attach to the container before starting it
go func() {
if err := c.attach(streams, keys, resize, true); err != nil {
if err := c.attach(streams, keys, resize, true, wg); err != nil {
attachChan <- err
}
close(attachChan)
}()

wg.Wait()
c.newContainerEvent(events.Attach)
return attachChan, nil
}
Expand Down Expand Up @@ -398,7 +406,7 @@ func (c *Container) Attach(streams *AttachStreams, keys string, resize <-chan re
return errors.Wrapf(ErrCtrStateInvalid, "can only attach to created or running containers")
}
defer c.newContainerEvent(events.Attach)
return c.attach(streams, keys, resize, false)
return c.attach(streams, keys, resize, false, nil)
}

// Mount mounts a container's filesystem on the host
Expand Down
17 changes: 13 additions & 4 deletions libpod/container_attach_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net"
"os"
"path/filepath"
"sync"

"github.com/containers/libpod/pkg/kubeutils"
"github.com/containers/libpod/utils"
Expand All @@ -31,7 +32,7 @@ const (

// Attach to the given container
// Does not check if state is appropriate
func (c *Container) attach(streams *AttachStreams, keys string, resize <-chan remotecommand.TerminalSize, startContainer bool) error {
func (c *Container) attach(streams *AttachStreams, keys string, resize <-chan remotecommand.TerminalSize, startContainer bool, wg *sync.WaitGroup) error {
if !streams.AttachOutput && !streams.AttachError && !streams.AttachInput {
return errors.Wrapf(ErrInvalidArg, "must provide at least one stream to attach to")
}
Expand All @@ -48,12 +49,17 @@ func (c *Container) attach(streams *AttachStreams, keys string, resize <-chan re

logrus.Debugf("Attaching to container %s", c.ID())

return c.attachContainerSocket(resize, detachKeys, streams, startContainer)
return c.attachContainerSocket(resize, detachKeys, streams, startContainer, wg)
}

// attachContainerSocket connects to the container's attach socket and deals with the IO
// attachContainerSocket connects to the container's attach socket and deals with the IO.
// wg is only required if startContainer is true
// TODO add a channel to allow interrupting
func (c *Container) attachContainerSocket(resize <-chan remotecommand.TerminalSize, detachKeys []byte, streams *AttachStreams, startContainer bool) error {
func (c *Container) attachContainerSocket(resize <-chan remotecommand.TerminalSize, detachKeys []byte, streams *AttachStreams, startContainer bool, wg *sync.WaitGroup) error {
if startContainer && wg == nil {
return errors.Wrapf(ErrInternal, "wait group not passed when startContainer set")
}

kubeutils.HandleResizing(resize, func(size remotecommand.TerminalSize) {
controlPath := filepath.Join(c.bundlePath(), "ctl")
controlFile, err := os.OpenFile(controlPath, unix.O_WRONLY, 0)
Expand Down Expand Up @@ -84,10 +90,13 @@ func (c *Container) attachContainerSocket(resize <-chan remotecommand.TerminalSi
}
defer conn.Close()

// If starting was requested, start the container and notify when that's
// done.
if startContainer {
if err := c.start(); err != nil {
return err
}
wg.Done()
}

receiveStdoutError := make(chan error)
Expand Down
4 changes: 3 additions & 1 deletion libpod/container_attach_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
package libpod

import (
"sync"

"k8s.io/client-go/tools/remotecommand"
)

func (c *Container) attach(streams *AttachStreams, keys string, resize <-chan remotecommand.TerminalSize, startContainer bool) error {
func (c *Container) attach(streams *AttachStreams, keys string, resize <-chan remotecommand.TerminalSize, startContainer bool, wg *sync.WaitGroup) error {
return ErrNotImplemented
}
14 changes: 7 additions & 7 deletions test/e2e/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ func (p *PodmanTestIntegration) Setup() {
// LockTmpDir = path
// })

var _ = AfterSuite(func() {
sort.Sort(testResultsSortedLength{testResults})
fmt.Println("integration timing results")
for _, result := range testResults {
fmt.Printf("%s\t\t%f\n", result.name, result.length)
}
})
// var _ = AfterSuite(func() {
// sort.Sort(testResultsSortedLength{testResults})
// fmt.Println("integration timing results")
// for _, result := range testResults {
// fmt.Printf("%s\t\t%f\n", result.name, result.length)
// }
// })

// PodmanTestCreate creates a PodmanTestIntegration instance for the tests
func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration {
Expand Down