Feature/execute container
A function was written to execute a container with a certain command using a specific endpoint. A task with a (currently) fixed timeout interval was written which is executed after pulling the image from harbor. The exit code after the container execution is processed and shown in the logfile.
Triggering the DAG via command line is now done with two new parameters: 'cmd' and 'entrypoint'. Two examples:
> airflow trigger_dag 'pull_image' --conf '{"repository": "harbor.pht.medic.uni-tuebingen.de/library/busybox", "tag": "latest", "cmd": "\"echo Hello World!\"", "entrypoint": "/bin/sh -c"}'
Excerpt from the logfile:
[2020-06-25 18:36:21,288] {logging_mixin.py:112} INFO - Running command "echo Hello World!"
[2020-06-25 18:36:21,736] {logging_mixin.py:112} INFO - Hello World!
[2020-06-25 18:36:21,736] {logging_mixin.py:112} INFO -
[2020-06-25 18:36:21,997] {python_operator.py:114} INFO - Done. Returned value was: None
> airflow trigger_dag 'pull_image' --conf '{"repository": "harbor.pht.medic.uni-tuebingen.de/library/busybox", "tag": "latest", "cmd": "\"sudo su\"", "entrypoint": "/bin/sh -c"}'
Excerpt from the logfile:
[2020-06-25 18:35:10,003] {logging_mixin.py:112} INFO - Running command "sudo su"
[2020-06-25 18:35:10,493] {logging_mixin.py:112} INFO - /bin/sh: sudo: not found
[2020-06-25 18:35:10,493] {logging_mixin.py:112} INFO -
[2020-06-25 18:35:10,760] {logging_mixin.py:112} INFO - The command "sudo su" resulted in a non-zero exit code: 127