an [abandoned] attempt to slice out the docker/docker/pkg package
Find a file
Jiri Popelka bc71145164 React to firewalld's reload/restart
When firewalld (or iptables service) restarts/reloads,
all previously added docker firewall rules are flushed.

With firewalld we can react to its Reloaded() [1]
D-Bus signal and recreate the firewall rules.
Also when firewalld gets restarted (stopped & started)
we can catch the NameOwnerChanged signal [2].
To specify which signals we want to react to we use AddMatch [3].

Libvirt has been doing this for quite a long time now.

Docker changes firewall rules on basically 3 places.
1) daemon/networkdriver/portmapper/mapper.go - port mappings
   Portmapper fortunatelly keeps list of mapped ports,
   so we can easily recreate firewall rules on firewalld restart/reload
   New ReMapAll() function does that
2) daemon/networkdriver/bridge/driver.go
   When setting a bridge, basic firewall rules are created.
   This is done at once during start, it's parametrized and nowhere
   tracked so how can one know what and how to set it again when
   there's been firewalld restart/reload ?
   The only solution that came to my mind is using of closures [4],
   i.e. I keep list of references to closures (anonymous functions
   together with a referencing environment) and when there's firewalld
   restart/reload I re-call them in the same order.
3) links/links.go - linking containers
   Link is added in Enable() and removed in Disable().
   In Enable() we add a callback function, which creates the link,
   that's OK so far.
   It'd be ideal if we could remove the same function from
   the list in Disable(). Unfortunatelly that's not possible AFAICT,
   because we don't know the reference to that function
   at that moment, so we can only add a reference to function,
   which removes the link. That means that after creating and
   removing a link there are 2 functions in the list,
   one adding and one removing the link and after
   firewalld restart/reload both are called.
   It works, but it's far from ideal.

[1] https://jpopelka.fedorapeople.org/firewalld/doc/firewalld.dbus.html#FirewallD1.Signals.Reloaded
[2] http://dbus.freedesktop.org/doc/dbus-specification.html#bus-messages-name-owner-changed
[3] http://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-routing-match-rules
[4] https://en.wikipedia.org/wiki/Closure_%28computer_programming%29

Signed-off-by: Jiri Popelka <jpopelka@redhat.com>
2015-04-20 13:02:09 +02:00
archive Fix vet warning 2015-04-13 11:43:30 -07:00
broadcastwriter pkg/broadcastwriter: reset after 4 KB w/o stream 2015-04-01 01:26:19 +03:00
chrootarchive Merge pull request #12360 from yestin/11601-supplement-tests-part-2 2015-04-14 21:00:12 -04:00
devicemapper devmapper: Use a pointer as argument to deferred function UdevWait() 2015-04-02 16:47:14 -04:00
directory Makes directory pkg compilable on Windows. 2015-03-12 15:54:22 +01:00
etchosts added documentation for functions 2015-04-15 19:28:01 -07:00
fileutils Refactor utils/utils, fixes #11923 2015-04-14 01:37:36 +02:00
graphdb Fix wrong graphdb refs paths purging 2015-04-14 23:10:43 +02:00
homedir If $HOME is not set, return homedir from /etc/passwd 2015-03-10 10:00:22 -04:00
httputils Refactor utils/utils, fixes #11923 2015-04-14 01:37:36 +02:00
ioutils Refactor utils/utils, fixes #11923 2015-04-14 01:37:36 +02:00
iptables React to firewalld's reload/restart 2015-04-20 13:02:09 +02:00
jsonlog pkg/jsonlog: add JSONLogBytes for low allocations 2015-04-01 01:02:18 +03:00
jsonmessage Fixes hacks from progressreader refactor 2015-03-25 18:21:02 -07:00
listenbuffer listenbuffer: add docs 2015-03-25 03:11:34 +00:00
mflag Refactor utils/flags.go, fixes #11892 2015-03-29 03:22:46 +02:00
mount Add documentation for exported functions and types 2015-04-03 11:33:34 +02:00
namesgenerator Merge pull request #12214 from ahmetalpbalkan/namesgenerator/localrand 2015-04-14 13:10:26 -04:00
parsers Add ability to refer to image by name + digest 2015-03-17 10:10:42 +00:00
pidfile Moved pidfile from utils to pkg 2015-03-24 23:59:32 +01:00
pools Remove pools_nopool.go & build tag from pools.go 2015-04-10 02:32:55 +03:00
progressreader Fix progress reader output on close 2015-03-31 13:17:25 -07:00
promise Move Go() promise-like func from utils to pkg/promise 2014-09-29 23:16:27 -07:00
proxy Replace aliased imports of logrus, fixes #11762 2015-03-26 23:22:04 +01:00
pubsub Remove publisher if no one is listening 2015-01-20 20:21:47 -08:00
reexec Fix relative path execution of docker daemon in reexec.Self() 2015-03-16 16:52:00 -04:00
requestdecorator Refactor utils/utils, fixes #11923 2015-04-14 01:37:36 +02:00
resolvconf Refactor utils/utils, fixes #11923 2015-04-14 01:37:36 +02:00
signal Replace aliased imports of logrus, fixes #11762 2015-03-26 23:22:04 +01:00
stdcopy correct pkg/stdcopy NewStdWriter function comments 2015-04-13 17:21:27 +08:00
streamformatter Fixes hacks from progressreader refactor 2015-03-25 18:21:02 -07:00
stringid Refactor pkg/common, Fixes #11599 2015-03-24 18:19:59 +01:00
stringutils Refactor utils/utils, fixes #11923 2015-04-14 01:37:36 +02:00
symlink Remove subdirectories MAINTAINERS files 2015-03-06 18:21:51 -08:00
sysinfo Update inline doc for New 2015-03-27 13:55:22 -04:00
system Add some documentation to pkg/system 2015-03-31 12:00:33 -07:00
systemd Remove subdirectories MAINTAINERS files 2015-03-06 18:21:51 -08:00
tailfile Implement tail for docker logs 2014-07-01 23:44:12 +04:00
tarsum Remove subdirectories MAINTAINERS files 2015-03-06 18:21:51 -08:00
term fix some typos 2015-04-17 08:12:13 +00:00
timeoutconn Rename package timeout to timeoutconn. 2015-02-25 20:52:37 +01:00
timeutils Remove subdirectories MAINTAINERS files 2015-03-06 18:21:51 -08:00
truncindex Removed redundant err == nil check 2015-03-26 11:36:13 +01:00
ulimit Fixes pointer error 2015-03-25 20:45:17 -07:00
units Remove subdirectories MAINTAINERS files 2015-03-06 18:21:51 -08:00
urlutil Move git and url checks into pkg 2014-11-24 18:10:37 -05:00
version Fix minor typo 2015-03-25 00:46:22 +08:00
README.md Add README to pkg 2013-12-23 23:12:19 +00:00

pkg/ is a collection of utility packages used by the Docker project without being specific to its internals.

Utility packages are kept separate from the docker core codebase to keep it as small and concise as possible. If some utilities grow larger and their APIs stabilize, they may be moved to their own repository under the Docker organization, to facilitate re-use by other projects. However that is not the priority.

The directory pkg is named after the same directory in the camlistore project. Since Brad is a core Go maintainer, we thought it made sense to copy his methods for organizing Go code :) Thanks Brad!

Because utility packages are small and neatly separated from the rest of the codebase, they are a good place to start for aspiring maintainers and contributors. Get in touch if you want to help maintain them!