Page MenuHomeDevCentral

Listen to Docker events
Changes PlannedPublic

Authored by dereckson on Mar 28 2023, 23:40.
Tags
None
Referenced Files
F3928536: D2940.id7486.diff
Sun, Dec 22, 05:25
Unknown Object (File)
Tue, Dec 17, 19:43
Unknown Object (File)
Sun, Dec 15, 04:35
Unknown Object (File)
Sat, Dec 14, 05:38
Unknown Object (File)
Fri, Dec 13, 03:34
Unknown Object (File)
Sun, Dec 8, 14:44
Unknown Object (File)
Fri, Dec 6, 19:49
Unknown Object (File)
Mon, Dec 2, 10:51
Subscribers
None

Details

Summary

Start a daemon to listen to Docker events and match them
to reactor rules, to run external commands when needed.

References:

Ref T1809

Test Plan

Tested on Dwellers with P322

Diff Detail

Repository
rDOCKERTIDE Docker Tide
Lint
Lint Skipped
Unit
No Test Coverage
Branch
main
Build Status
Buildable 4637
Build 4912: arc lint + arc unit

Event Timeline

dereckson created this revision.
dereckson added inline comments.
bin/docker-tide
22

A -v argument to switch logging to debug level (see comment in reactor.py for that)?

setup.cfg
7

This one is missing.

src/dockertide/reactor.py
34

Need to be set at DEBUG when needed, that's useful to understand what is called and so debug reactor rules:

Event received: {'status': 'resize', 'id': '02708df009af69014aebc710f1b97cb5c90e5a6197ee7eae934a2eaca2cb7231', 'from': 'nasqueron/arcanist:5001-5001', 'Type': 'container', 'Action': 'resize', 'Actor': {'ID': '02708df009af69014aebc710f1b97cb5c90e5a6197ee7eae934a2eaca2cb7231', 'Attributes': {'height': '29', 'image': 'nasqueron/arcanist:5001-5001', 'name': 'exciting_leakey', 'width': '222'}}, 'scope': 'local', 'time': 1680046788, 'timeNano': 1680046788623110893}
Action matches event: Fire notification on container lifecycle event
Running command: ['notification-push', '--project', 'Nasqueron', '--service', 'Docker', '--type', 'container.resize', '--group', 'ops', '--text', 'Docker container exciting_leakey: resize', '--link', 'dwellers.nasqueron.org']
Can't run command: [Errno 2] No such file or directory: 'notification-push'
Action matches event: Propagate all events to Salt
Running command: ['sudo', 'salt-call', 'event.send', 'tide/docker', '{"status": "resize", "id": "02708df009af69014aebc710f1b97cb5c90e5a6197ee7eae934a2eaca2cb7231", "from": "nasqueron/arcanist:5001-5001", "Type": "container", "Action": "resize", "Actor": {"ID": "02708df009af69014aebc710f1b97cb5c90e5a6197ee7eae934a2eaca2cb7231", "Attributes": {"height": "29", "image": "nasqueron/arcanist:5001-5001", "name": "exciting_leakey", "width": "222"}}, "scope": "local", "time": 1680046788, "timeNano": 1680046788623110893}%%']
Command successful: CompletedProcess(args=['sudo', 'salt-call', 'event.send', 'tide/docker', '{"status": "resize", "id": "02708df009af69014aebc710f1b97cb5c90e5a6197ee7eae934a2eaca2cb7231", "from": "nasqueron/arcanist:5001-5001", "Type": "container", "Action": "resize", "Actor": {"ID": "02708df009af69014aebc710f1b97cb5c90e5a6197ee7eae934a2eaca2cb7231", "Attributes": {"height": "29", "image": "nasqueron/arcanist:5001-5001", "name": "exciting_leakey", "width": "222"}}, "scope": "local", "time": 1680046788, "timeNano": 1680046788623110893}%%'], returncode=0, stdout=b'local:\n    True\n', stderr=b'')

For example, I'm pretty sure we aren't interested by container.resize on IRC and can discard them. Also, if a command fails, we've the full process stdout/stderr information. If it succeeeds? debug has it.

About logging, with WARNING, the example given above would be limited to one line:
Can't run command: [Errno 2] No such file or directory: 'notification-push'