Page MenuHomeDevCentral

Listen to Docker events
Changes PlannedPublic

Authored by dereckson on Mar 28 2023, 23:40.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 18, 19:27
Unknown Object (File)
Thu, Apr 18, 02:27
Unknown Object (File)
Sun, Apr 14, 21:57
Unknown Object (File)
Sun, Apr 14, 18:26
Unknown Object (File)
Sun, Apr 14, 13:12
Unknown Object (File)
Tue, Apr 9, 19:06
Unknown Object (File)
Tue, Apr 9, 07:31
Unknown Object (File)
Fri, Apr 5, 02:19
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'