Page MenuHomeDevCentral

Listen to Docker events
Changes PlannedPublic

Authored by dereckson on Mar 28 2023, 23:40.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 17, 03:44
Unknown Object (File)
Sat, Nov 16, 21:06
Unknown Object (File)
Fri, Nov 15, 17:15
Unknown Object (File)
Thu, Nov 14, 22:11
Unknown Object (File)
Thu, Nov 14, 19:27
Unknown Object (File)
Wed, Nov 13, 05:48
Unknown Object (File)
Tue, Nov 12, 06:59
Unknown Object (File)
Fri, Nov 8, 05:38
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'