1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
Commit graph

15 commits

Author SHA1 Message Date
Sebastiaan van Stijn
521807837b
plugin: Executor.Signal() accept syscall.Signal
This helps reducing some type-juggling / conversions further up
the stack.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-05-05 00:53:55 +02:00
Sebastiaan van Stijn
25ee00c494
pkg/system: move EnsureRemoveAll() to pkg/containerfs
pkg/system historically has been a bit of a kitchen-sink of things that were
somewhat "system" related, but didn't have a good place for. EnsureRemoveAll()
is one of those utilities. EnsureRemoveAll() is used to both unmount and remove
a path, for which it depends on both github.com/moby/sys/mount, which in turn
depends on github.com/moby/sys/mountinfo.

pkg/system is imported in the CLI, but neither EnsureRemoveAll(), nor any of its
moby/sys dependencies are used on the client side, so let's move this function
somewhere else, to remove those dependencies from the CLI.

I looked for plausible locations that were related; it's used in:

- daemon
- daemon/graphdriver/XXX/
- plugin

I considered moving it into a (e.g.) "utils" package within graphdriver (but not
a huge fan of "utils" packages), and given that it felt (mostly) related to
cleaning up container filesystems, I decided to move it there.

Some things to follow-up on after this:

- Verify if this function is still needed (it feels a bit like a big hammer in
  a "YOLO, let's try some things just in case it fails")
- Perhaps it should be integrated in `containerfs.Remove()` (so that it's used
  automatically)
- Look if there's other implementations (and if they should be consolidated),
  although (e.g.) the one in containerd is a copy of ours:
  https://github.com/containerd/containerd/blob/v1.5.9/pkg/cri/server/helpers_linux.go#L200

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-03-03 00:22:26 +01:00
Eng Zer Jun
c55a4ac779
refactor: move from io/ioutil to io and os package
The io/ioutil package has been deprecated in Go 1.16. This commit
replaces the existing io/ioutil functions with their new definitions in
io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-08-27 14:56:57 +08:00
Arnaud Rebillout
e8648fa19f plugin/manager_linux_test: Skip privileged tests when non-root
This test fail when run by a non-root user

  === CONT  TestPluginAlreadyRunningOnStartup
  === RUN   TestPluginAlreadyRunningOnStartup/live-restore-disabled
  === PAUSE TestPluginAlreadyRunningOnStartup/live-restore-disabled
  === RUN   TestPluginAlreadyRunningOnStartup/live-restore-enabled
  === PAUSE TestPluginAlreadyRunningOnStartup/live-restore-enabled
  === CONT  TestPluginAlreadyRunningOnStartup/live-restore-disabled
  === CONT  TestPluginAlreadyRunningOnStartup/live-restore-enabled
  time="2020-12-15T02:23:03Z" level=error msg="failed to enable plugin" error="chown /tmp/TestPluginAlreadyRunningOnStartup898689032/live-restore-disabled/manager/b6106d4d8937398ec8ec5e7092897ca4dd2eab6aa8043640095ef92b860b1417/rootfs/dev: operation not permitted" id=b6106d4d8937398ec8ec5e7092897ca4dd2eab6aa8043640095ef92b860b1417
  === CONT  TestPluginAlreadyRunningOnStartup/live-restore-disabled
      manager_linux_test.go:250: plugin client should not be nil
  panic: test timed out after 10m0s

  goroutine 41 [running]:
  testing.(*M).startAlarm.func1()
	  /usr/lib/go-1.15/src/testing/testing.go:1618 +0xe5
  created by time.goFunc
	  /usr/lib/go-1.15/src/time/sleep.go:167 +0x45

  goroutine 1 [chan receive, 9 minutes]:
  testing.tRunner.func1(0xc000001500)
	  /usr/lib/go-1.15/src/testing/testing.go:1088 +0x24d
  testing.tRunner(0xc000001500, 0xc0001dfde0)
	  /usr/lib/go-1.15/src/testing/testing.go:1127 +0x125
  testing.runTests(0xc00000e2c0, 0xeade80, 0xa, 0xa, 0xbfee25f7d50c4ace, 0x8bb30f7348, 0xebb2c0, 0x40f710)
	  /usr/lib/go-1.15/src/testing/testing.go:1437 +0x2fe
  testing.(*M).Run(0xc000394100, 0x0)
	  /usr/lib/go-1.15/src/testing/testing.go:1345 +0x1eb
  main.main()
	  _testmain.go:61 +0x138

  goroutine 11 [chan receive, 9 minutes]:
  testing.tRunner.func1(0xc000412180)
	  /usr/lib/go-1.15/src/testing/testing.go:1088 +0x24d
  testing.tRunner(0xc000412180, 0xad9b38)
	  /usr/lib/go-1.15/src/testing/testing.go:1127 +0x125
  created by testing.(*T).Run
	  /usr/lib/go-1.15/src/testing/testing.go:1168 +0x2b3

  goroutine 16 [chan receive, 9 minutes]:
  testing.runTests.func1.1(0xc000001500)
	  /usr/lib/go-1.15/src/testing/testing.go:1444 +0x3b
  created by testing.runTests.func1
	  /usr/lib/go-1.15/src/testing/testing.go:1444 +0xac

  goroutine 34 [chan send, 9 minutes]:
  github.com/docker/docker/plugin.(*executorWithRunning).Signal(0xc0003e31e0, 0xc0000317c0, 0x40, 0xf, 0x3f, 0x3f)
	  /<<PKGBUILDDIR>>/_build/src/github.com/docker/docker/plugin/manager_linux_test.go:171 +0x73
  github.com/docker/docker/plugin.shutdownPlugin(0xc0003e6840, 0xc000096360, 0xb6dfc0, 0xc0003e31e0)
	  /<<PKGBUILDDIR>>/_build/src/github.com/docker/docker/plugin/manager_linux.go:157 +0x8a
  github.com/docker/docker/plugin.(*Manager).Shutdown(0xc0003e80c0)
	  /<<PKGBUILDDIR>>/_build/src/github.com/docker/docker/plugin/manager_linux.go:211 +0x1a7
  runtime.Goexit()
	  /usr/lib/go-1.15/src/runtime/panic.go:617 +0x1e5
  testing.(*common).FailNow(0xc000412a80)
	  /usr/lib/go-1.15/src/testing/testing.go:732 +0x3c
  testing.(*common).Fatal(0xc000412a80, 0xc00015ddc8, 0x1, 0x1)
	  /usr/lib/go-1.15/src/testing/testing.go:800 +0x78
  github.com/docker/docker/plugin.TestPluginAlreadyRunningOnStartup.func3(0xc000412a80)
	  /<<PKGBUILDDIR>>/_build/src/github.com/docker/docker/plugin/manager_linux_test.go:250 +0x919
  testing.tRunner(0xc000412a80, 0xc0003e4f90)
	  /usr/lib/go-1.15/src/testing/testing.go:1123 +0xef
  created by testing.(*T).Run
	  /usr/lib/go-1.15/src/testing/testing.go:1168 +0x2b3

  goroutine 35 [chan send, 9 minutes]:
  testing.tRunner.func1(0xc000412d80)
	  /usr/lib/go-1.15/src/testing/testing.go:1113 +0x373
  testing.tRunner(0xc000412d80, 0xc0003e4fc0)
	  /usr/lib/go-1.15/src/testing/testing.go:1127 +0x125
  created by testing.(*T).Run
	  /usr/lib/go-1.15/src/testing/testing.go:1168 +0x2b3

  goroutine 50 [IO wait, 9 minutes]:
  internal/poll.runtime_pollWait(0x7f7b26d75e70, 0x72, 0x0)
	  /usr/lib/go-1.15/src/runtime/netpoll.go:222 +0x55
  internal/poll.(*pollDesc).wait(0xc000518018, 0x72, 0x0, 0x0, 0xab05ec)
	  /usr/lib/go-1.15/src/internal/poll/fd_poll_runtime.go:87 +0x45
  internal/poll.(*pollDesc).waitRead(...)
	  /usr/lib/go-1.15/src/internal/poll/fd_poll_runtime.go:92
  internal/poll.(*FD).Accept(0xc000518000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	  /usr/lib/go-1.15/src/internal/poll/fd_unix.go:394 +0x1fc
  net.(*netFD).accept(0xc000518000, 0x64298f, 0xc000394080, 0x0)
	  /usr/lib/go-1.15/src/net/fd_unix.go:172 +0x45
  net.(*UnixListener).accept(0xc00050c0f0, 0xc000394080, 0x0, 0x0)
	  /usr/lib/go-1.15/src/net/unixsock_posix.go:162 +0x32
  net.(*UnixListener).Accept(0xc00050c0f0, 0x0, 0x0, 0x0, 0x0)
	  /usr/lib/go-1.15/src/net/unixsock.go:260 +0x65
  github.com/docker/docker/plugin.listenTestPlugin.func1(0xb6be00, 0xc00050c0f0)
	  /<<PKGBUILDDIR>>/_build/src/github.com/docker/docker/plugin/manager_linux_test.go:266 +0x3d
  created by github.com/docker/docker/plugin.listenTestPlugin
	  /<<PKGBUILDDIR>>/_build/src/github.com/docker/docker/plugin/manager_linux_test.go:264 +0x105

  goroutine 51 [chan receive, 9 minutes]:
  github.com/docker/docker/plugin.listenTestPlugin.func2(0xc000516000, 0xb6be00, 0xc00050c0f0, 0xc000514000, 0x65)
	  /<<PKGBUILDDIR>>/_build/src/github.com/docker/docker/plugin/manager_linux_test.go:274 +0x34
  created by github.com/docker/docker/plugin.listenTestPlugin
	  /<<PKGBUILDDIR>>/_build/src/github.com/docker/docker/plugin/manager_linux_test.go:273 +0x14f
  FAIL	github.com/docker/docker/plugin	600.013s

Signed-off-by: Arnaud Rebillout <elboulangero@gmail.com>
2020-12-15 09:48:06 +07:00
Kir Kolyshkin
39048cf656 Really switch to moby/sys/mount*
Switch to moby/sys/mount and mountinfo. Keep the pkg/mount for potential
outside users.

This commit was generated by the following bash script:

```
set -e -u -o pipefail

for file in $(git grep -l 'docker/docker/pkg/mount"' | grep -v ^pkg/mount); do
	sed -i -e 's#/docker/docker/pkg/mount"#/moby/sys/mount"#' \
		-e 's#mount\.\(GetMounts\|Mounted\|Info\|[A-Za-z]*Filter\)#mountinfo.\1#g' \
		$file
	goimports -w $file
done
```

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-20 09:46:25 -07:00
Sebastiaan van Stijn
9f0b3f5609
bump gotest.tools v3.0.1 for compatibility with Go 1.14
full diff: https://github.com/gotestyourself/gotest.tools/compare/v2.3.0...v3.0.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-11 00:06:42 +01:00
Sebastiaan van Stijn
07ff4f1de8
goimports: fix imports
Format the source according to latest goimports.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:56:54 +02:00
Justin Cormack
2df693e533
Entropy cannot be saved
Remove non cryptographic randomness.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2019-06-07 11:54:45 +01:00
Vincent Demeester
3845728524
Update tests to use gotest.tools 👼
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-06-13 09:04:30 +02:00
Brian Goff
dbeb432965 Fix panic on daemon restart with running plugin
Scenario:

Daemon is ungracefully shutdown and leaves plugins running (no
live-restore).
Daemon comes back up.
The next time a container tries to use that plugin it will cause a
daemon panic because the plugin client is not set.

This fixes that by ensuring that the plugin does get shutdown.
Note, I do not think there would be any harm in just re-attaching to the
running plugin instead of shutting it down, however historically we shut
down plugins and containers when live-restore is not enabled.

[kir@: consolidate code to deleteTaskAndContainer, a few minor nits]

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-06-07 17:27:02 -07:00
Sebastiaan van Stijn
f23c00d870
Various code-cleanup
remove unnescessary import aliases, brackets, and so on.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-05-23 17:50:54 +02:00
Vincent Demeester
a7999aaa53
Skip some tests requires root uid when run as user
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-04-23 10:14:39 +02:00
Anusha Ragunathan
89a882e2f1 Add missing error return for plugin creation.
Signed-off-by: Anusha Ragunathan <anusha.ragunathan@docker.com>
2018-03-23 12:07:43 -07:00
Daniel Nephin
4f0d95fa6e Add canonical import comment
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-02-05 16:51:57 -05:00
Brian Goff
5017b5bef5 Add test to check for plugin mounts on remove
Ensures that when a plugin is removed that it doesn't interfere with
other plugins mounts and also ensures its own mounts are cleaned up.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-12-04 22:01:14 -05:00