Skip to content

Skip TestHealthKillContainer on Windows#39575

Merged
crosbymichael merged 1 commit intomoby:masterfrom
thaJeztah:fix_TestHealthKillContainer
Jul 19, 2019
Merged

Skip TestHealthKillContainer on Windows#39575
crosbymichael merged 1 commit intomoby:masterfrom
thaJeztah:fix_TestHealthKillContainer

Conversation

@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Jul 19, 2019

closes #39574 (but we should probably look if we can make it work on Windows)

This test is failing on Windows currently:

11:59:47 --- FAIL: TestHealthKillContainer (8.12s)
11:59:47     health_test.go:57: assertion failed: error is not nil: Error response from daemon: Invalid signal: SIGUSR1

That test was added recently in #39454, but
rewritten in a commit in the same PR:
f8aef6a

In that rewrite, there were some changes:

  • originally it was skipped on Windows, but the rewritten test doesn't have that skip:

    testRequires(c, DaemonIsLinux) // busybox doesn't work on Windows
  • the original test used SIGINT, but the new one uses SIGUSR1

Analysis:

  • The Error bubbles up from:
    // ParseSignal translates a string to a valid syscall signal.
    // It returns an error if the signal map doesn't include the given signal.
    func ParseSignal(rawSignal string) (syscall.Signal, error) {
    s, err := strconv.Atoi(rawSignal)
    if err == nil {
    if s == 0 {
    return -1, fmt.Errorf("Invalid signal: %s", rawSignal)
    }
    return syscall.Signal(s), nil
    }
    signal, ok := SignalMap[strings.TrimPrefix(strings.ToUpper(rawSignal), "SIG")]
    if !ok {
    return -1, fmt.Errorf("Invalid signal: %s", rawSignal)
    }
    return signal, nil
    }
  • Interestingly; ContainerKill should validate if a signal is valid for the given platform, but somehow we don't hit that part;

    moby/daemon/kill.go

    Lines 40 to 48 in f1b5612

    func (daemon *Daemon) ContainerKill(name string, sig uint64) error {
    container, err := daemon.GetContainer(name)
    if err != nil {
    return err
    }
    if sig != 0 && !signal.ValidSignalForPlatform(syscall.Signal(sig)) {
    return fmt.Errorf("The %s daemon does not support signal %d", runtime.GOOS, sig)
    }
  • Windows only looks to support 2 signals currently
    // SignalMap is a map of "supported" signals. As per the comment in GOLang's
    // ztypes_windows.go: "More invented values for signals". Windows doesn't
    // really support signals in any way, shape or form that Unix does.
    //
    // We have these so that docker kill can be used to gracefully (TERM) and
    // forcibly (KILL) terminate a container on Windows.
    var SignalMap = map[string]syscall.Signal{
    "KILL": syscall.SIGKILL,
    "TERM": syscall.SIGTERM,
    }
  • Upstream Golang looks to define SIGINT as well; https://github.com/golang/go/blob/77f9b2728eb08456899e6500328e00ec4829dddf/src/runtime/defs_windows.go#L44
  • This looks like the current list of Signals upstream in Go; https://github.com/golang/sys/blob/3b58ed4ad3395d483fc92d5d14123ce2c3581fec/windows/types_windows.go#L52-L67
const (
	// More invented values for signals
	SIGHUP  = Signal(0x1)
	SIGINT  = Signal(0x2)
	SIGQUIT = Signal(0x3)
	SIGILL  = Signal(0x4)
	SIGTRAP = Signal(0x5)
	SIGABRT = Signal(0x6)
	SIGBUS  = Signal(0x7)
	SIGFPE  = Signal(0x8)
	SIGKILL = Signal(0x9)
	SIGSEGV = Signal(0xb)
	SIGPIPE = Signal(0xd)
	SIGALRM = Signal(0xe)
	SIGTERM = Signal(0xf)
)

This test is failing on Windows currently:

```
11:59:47 --- FAIL: TestHealthKillContainer (8.12s)
11:59:47     health_test.go:57: assertion failed: error is not nil: Error response from daemon: Invalid signal: SIGUSR1
``

That test was added recently in moby#39454, but
rewritten in a commit in the same PR:
moby@f8aef6a

In that rewrite, there were some changes:

- originally it was skipped on Windows, but the rewritten test doesn't have that skip:

    ```go
    testRequires(c, DaemonIsLinux) // busybox doesn't work on Windows
    ```

- the original test used `SIGINT`, but the new one uses `SIGUSR1`

Analysis:

- The Error bubbles up from: https://github.com/moby/moby/blob/8e610b2b55bfd1bfa9436ab110d311f5e8a74dcb/pkg/signal/signal.go#L29-L44
- Interestingly; `ContainerKill` should validate if a signal is valid for the given platform, but somehow we don't hit that part; https://github.com/moby/moby/blob/f1b5612f2008827fdcf838abb4539064c682181e/daemon/kill.go#L40-L48
- Windows only looks to support 2 signals currently https://github.com/moby/moby/blob/8e610b2b55bfd1bfa9436ab110d311f5e8a74dcb/pkg/signal/signal_windows.go#L17-L26
- Upstream Golang looks to define `SIGINT` as well; https://github.com/golang/go/blob/77f9b2728eb08456899e6500328e00ec4829dddf/src/runtime/defs_windows.go#L44
- This looks like the current list of Signals upstream in Go; https://github.com/golang/sys/blob/3b58ed4ad3395d483fc92d5d14123ce2c3581fec/windows/types_windows.go#L52-L67

```go
const (
	// More invented values for signals
	SIGHUP  = Signal(0x1)
	SIGINT  = Signal(0x2)
	SIGQUIT = Signal(0x3)
	SIGILL  = Signal(0x4)
	SIGTRAP = Signal(0x5)
	SIGABRT = Signal(0x6)
	SIGBUS  = Signal(0x7)
	SIGFPE  = Signal(0x8)
	SIGKILL = Signal(0x9)
	SIGSEGV = Signal(0xb)
	SIGPIPE = Signal(0xd)
	SIGALRM = Signal(0xe)
	SIGTERM = Signal(0xf)
)
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
Copy link
Member Author

ping @cpuguy83 @crosbymichael PTAL

Copy link
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@andrewhsu
Copy link
Contributor

cc @ddebroy

@thaJeztah
Copy link
Member Author

RS1 machine looks to be in need of a cleanup;

14:15:19 INFO: Nuke-Everything...
14:15:19 INFO: Container count on control daemon to delete is 1
18:05:15 Build timed out (after 230 minutes). Marking the build as failed.

@crosbymichael
Copy link
Contributor

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Testing: TestHealthKillContainer is broken on Windows

5 participants