Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate github.com/docker/docker/pkg/signal #69

Closed
wants to merge 100 commits into from

Conversation

thaJeztah
Copy link
Member

relates to containerd/containerd#5402

Migrating this package from commit:
moby/moby@c81abef

Strategy taken:

# install filter-repo (https://github.com/newren/git-filter-repo/blob/main/INSTALL.md)
brew install git-filter-repo

cd ~/projects

# create a temporary clone of docker
git clone https://github.com/docker/docker.git moby_signal
cd moby_signal

# remove all code, except for pkg/signal, and rename to /signal
git filter-repo  --path pkg/signal --path-rename pkg/signal:signal

# go to the target github.com/moby/sys repository
cd ~/projects/moby-sys

# create a branch to work with
git checkout -b integrate_moby_signal

# add the temporary repository as an upstream and make sure it's up-to-date
git remote add moby_signal ~/projects/moby_signal
git fetch moby_signal

# merge the upstream code
git merge --allow-unrelated-histories --signoff -S moby_signal/master

After this:

  • signal: update import-paths
  • signal: add go.mod
  • Makefile: enable tests for signals
  • signal: remove logrus dependency
  • signal: remove gotest.tools dependency
  • signal: remove github.com/pkg/errors dependency

creack and others added 30 commits March 10, 2014 17:36
Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume@charmes.net> (github: creack)
Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume@charmes.net> (github: creack)
Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume@charmes.net> (github: creack)
Docker-DCO-1.1-Signed-off-by: Kato Kazuyoshi <kato.kazuyoshi@gmail.com> (github: kzys)
Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume@charmes.net> (github: creack)
Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
Fix various MAINTAINERS format inconsistencies
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
as a maintainer.

Best of luck on your e-commerce business Guillaume, and thanks for all
the great contributions!

Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
…me_on_his_new_business_and_no_longer_available_as_a_maintainer
Signed-off-by: Solomon Hykes <solomon@docker.com>
Cleanup: refactor shutdown and signal handling facility
Signed-off-by: Michael Crosby <michael@docker.com>
thaJeztah and others added 11 commits November 27, 2019 15:41
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
full diff: gotestyourself/gotest.tools@v2.3.0...v3.0.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…64el

error log :
signal_test.go:20: assertion failed: error is not nil: Invalid signal: SIGEMT
signal_test.go:22: assertion failed:
When "ParseSignal" function parse sigStr from SignalMap, it find the signal object with key ("SIG"+sigStr). But  EMT signal named "SIGEMT" in SignalMap structrue, so the real key is "SIGSIGEMT" , and cannot find the target signal.
modify "SIGEMT" to "EMT" in SignalMap structrue.

Signed-off-by: liuxiaodong <liuxiaodong@loongson.cn>
TestCatchAll, TestStopCatch: remove unneeded goroutine
Do not handle SIGURG on Linux, as in go1.14+, the go runtime issues
SIGURG as an interrupt to support preemptable system calls on Linux.

This issue was caught in TestCatchAll, which could fail when updating to Go 1.14 or above;

    === Failed
    === FAIL: pkg/signal TestCatchAll (0.01s)
        signal_linux_test.go:32: assertion failed: urgent I/O condition (string) != continued (string)
        signal_linux_test.go:32: assertion failed: continued (string) != hangup (string)
        signal_linux_test.go:32: assertion failed: hangup (string) != child exited (string)
        signal_linux_test.go:32: assertion failed: child exited (string) != illegal instruction (string)
        signal_linux_test.go:32: assertion failed: illegal instruction (string) != floating point exception (string)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Other Unix platforms (e.g. Darwin) are also affected by the Go
runtime sending SIGURG.

This patch changes how we match the signal by just looking for the
"URG" name, which should handle any platform that has this signal
defined in the SignalMap.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Migrating this package from commit:
moby/moby@c81abef

Strategy taken:

    # install filter-repo (https://github.com/newren/git-filter-repo/blob/main/INSTALL.md)
    brew install git-filter-repo

    cd ~/projects

    # create a temporary clone of docker
    git clone https://github.com/docker/docker.git moby_signal
    cd moby_signal

    # remove all code, except for pkg/signal, and rename to /signal
    git filter-repo  --path pkg/signal --path-rename pkg/signal:signal

    # go to the target github.com/moby/sys repository
    cd ~/projects/moby-sys

    # create a branch to work with
    git checkout -b integrate_moby_signal

    # add the temporary repository as an upstream and make sure it's up-to-date
    git remote add moby_signal ~/projects/moby_signal
    git fetch moby_signal

    # merge the upstream code
    git merge --allow-unrelated-histories --signoff -S moby_signal/master

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah marked this pull request as draft July 9, 2021 21:16
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    signal_linux_test.go:28:16: Error return value of `syscall.Kill` is not checked (errcheck)
                syscall.Kill(syscall.Getpid(), signal)
                            ^
    signal_linux_test.go:59:14: Error return value of `syscall.Kill` is not checked (errcheck)
        syscall.Kill(syscall.Getpid(), signal)
                    ^
    trap.go:59:16: Error return value of `DumpStacks` is not checked (errcheck)
                        DumpStacks("")
                                  ^
    trap.go:94:15: Error return value of `f.Sync` is not checked (errcheck)
            defer f.Sync()
                        ^
    testfiles/main.go:42:14: Error return value of `p.Signal` is not checked (errcheck)
                        p.Signal(sigmap[s])
                                ^
    testfiles/main.go:45:13: Error return value of `p.Signal` is not checked (errcheck)
                    p.Signal(sigmap[s])
                            ^
    testfiles/main.go:48:12: Error return value of `p.Signal` is not checked (errcheck)
                p.Signal(sigmap[s])
                        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
}
} else {
// 3 SIGTERM/INT signals received; force exit without cleanup
logger.Info("Forcing docker daemon shutdown without cleanup; 3 interrupts received")
Copy link
Member Author

Choose a reason for hiding this comment

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

This should probably be made more generic

Suggested change
logger.Info("Forcing docker daemon shutdown without cleanup; 3 interrupts received")
logger.Info("Forcing shutdown; 3 interrupts received")

Copy link
Member

Choose a reason for hiding this comment

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

SGTM 👍

}
case syscall.SIGQUIT:
_, _ = DumpStacks("")
logger.Info("Forcing docker daemon shutdown without cleanup on SIGQUIT")
Copy link
Member Author

Choose a reason for hiding this comment

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

Same for this:

Suggested change
logger.Info("Forcing docker daemon shutdown without cleanup on SIGQUIT")
logger.Info("Forcing shutdown on SIGQUIT")

Copy link
Member Author

Choose a reason for hiding this comment

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

Or perhaps this whole file should be kept in the moby repository (as it may be quite specific to moby)

@thaJeztah
Copy link
Member Author

Some old commits were missing a proper DCO, so I manually marked it to "pass"

Commit sha: 6057481, Author: Guillaume J. Charmes, Committer: Guillaume J. Charmes; The sign-off is missing.
Commit sha: 108a12b, Author: Guillaume J. Charmes, Committer: Guillaume J. Charmes; The sign-off is missing.
Commit sha: aa57f84, Author: Guillaume J. Charmes, Committer: Guillaume J. Charmes; The sign-off is missing.
Commit sha: 5fcf5fa, Author: Kato Kazuyoshi, Committer: Kato Kazuyoshi; The sign-off is missing.
Commit sha: 530bcc0, Author: Guillaume J. Charmes, Committer: Guillaume J. Charmes; The sign-off is missing.
Commit sha: a3e2247, Author: Tianon Gravi, Committer: Tianon Gravi; The sign-off is missing.
Commit sha: 2f0e890, Author: Solomon Hykes, Committer: Solomon Hykes; The sign-off is missing.
Commit sha: 57a9d66, Author: Phil Estes, Committer: Phil Estes; The sign-off is missing.
Commit sha: 860f076, Author: Amit Krishnan, Committer: Amit Krishnan; Expected "Amit Krishnan amit.krishnan@oracle.com", but got "Amit Krishnan krish.amit@gmail.com".

@thaJeztah thaJeztah marked this pull request as ready for review July 9, 2021 21:38
@thaJeztah
Copy link
Member Author

I guess this is one to decide (can be done later if we want)

Or perhaps this whole file should be kept in the moby repository (as it may be quite specific to moby)

@thaJeztah
Copy link
Member Author

I'm updating the moby package in moby/moby#42641 to get rid of the things we don't need

@thaJeztah
Copy link
Member Author

closing in favour of (WIP) #70

@thaJeztah thaJeztah closed this Jul 16, 2021
@thaJeztah thaJeztah deleted the integrate_moby_signal branch July 17, 2023 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.