-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement the report using the Tern #3
base: main
Are you sure you want to change the base?
Conversation
6233661
to
62c7f23
Compare
This commit implements the report using Tern The reports use the ``concurrent.futures``, but instead of building all the implementation for it, we use flask-executer that makes the implementation on top of Flask. All the report requests go to the ``tern-tasks`` (Futures) and are handled such as a Celery implementation. https://docs.celeryproject.org/en/stable/reference/celery.states.html#misc All tasks start with the status 'PENDING', which means that the task has no defined status until the ``tern-tasks`` knows it. Once the task is in picked up by the ``tern-tasks`` it is moved to 'RUNNING'. If the processing finishes, the status is moved to 'SUCCESS' independently of the task content/result. Here the status is for the task itself. The 'FAILURE' status is given when the task cannot finish its routine. The Tern, for now, is called using ``subprocess``, and the output is handled by the stdout and stderr. The initial API specification was changed a bit for more clearness. How to run as Docker container was added to the ``README.md``. Signed-off-by: Kairo de Araujo <[email protected]>
The logic is easy, but add some quick reference. Signed-off-by: Kairo de Araujo <[email protected]>
62c7f23
to
a645222
Compare
Fix the invalid UNKNOWN status. Correct initial status is PENDING. This issue causes HTTP 500 when requested the status endpoint. Signed-off-by: Kairo de Araujo <[email protected]>
Missing License header in the Makefile was added. Signed-off-by: Kairo de Araujo <[email protected]>
This commit adds to tox.ini the unit tests. It guarantee that the tests will run in the CI if new changes or tests are added. Signed-off-by: Kairo de Araujo <[email protected]>
This commit adds all the tern-rest-api reports implementation tests covering 100% Adjusts the repository to use Docker. Signed-off-by: Kairo de Araujo <[email protected]>
45d8342
to
53a9ef0
Compare
The documentation offline is available on http://tern-tools.github.io/tern-rest-api and tests to see if the API documentation is updated is a must. The Makefile contains the entry to build the offline documentation. Signed-off-by: Kairo de Araujo <[email protected]>
@kairoaraujo how can I test this PR against my changes here? https://github.com/nishakm/tern/tree/api |
else: | ||
report = tern(command) | ||
|
||
return report |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can modify this function logic.
Instead of calling tern(command)
, it could call the tern library API.
Also, modify the submit()
to build the needed arguments for the tern library API instead command
.
Having It in a specific function (see tern
line 38) is even better to handle the possible exceptions cases and make task management consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any suggestions on how to test the API other than using curl from the command line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can even use the service itself.
The swagger documentation has the option "try it" for each endpoint when the application runs, and it works fine.
The second option is using postman.
tern_app.config["TERN_API_CACHE_DIR"] = os.getenv("TERN_API_CACHE_DIR") | ||
tern_app.config["TERN_DEFAULT_REGISTRY"] = os.getenv("TERN_DEFAULT_REGISTRY") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cache directory can be retrieved from tern using tern.utils.rootfs.get_working_directory()
. You may also want to add a note in the README about setting the TERN_DEFAULT_REGISTRY value when not working with the docker container.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @nishakm, sorry for my late reply.
I'm not sure we are talking about the same caching directory here.
- The reports generated by the API use this cache
- This cache will be stored inside the container, the path given is inside the container, and the variable is to allow the user to use specific data storage and manage it.
I think it is possible to combine both caching, maybe a new issue for it?
I will document the default settings in the README.
Simple document the container evironment variables in the README.md Two variables can be used to change the default value. - ``TERN_API_CACHE_DIR``: The directory where the tern reports are cached. Default: ``/var/opt/tern-rest-api/cache`` - ``TERN_DEFAULT_REGISTRY``: Optional default registry to use when no registry is passed to the API requests. Default: ``docker.io`` Signed-off-by: Kairo de Araujo <[email protected]>
This commit implements the report using Tern
The reports use the
concurrent.futures
, but instead of buildingall the implementation for it, we use flask-executer that makes the
implementation on top of Flask.
All the report requests go to the
tern-tasks
(Futures) and arehandled such as a Celery implementation.
All tasks start with the status 'UNKNOWN', which means that the task
has no defined status until the
tern-tasks
start processing it.Once the task is in picked up by the
tern-tasks
it is moved to'RUNNING'.
If the processing finishes, the status is moved to 'FINISH'
independently of the task content/result. Here the status is for
the task itself.
The FAIL status is given when the task cannot finish its routine.
The Tern, for now, is called using
subprocess
, and the output ishandled by the stdout and stderr.
The initial API specification was changed a bit for more clearness.
How to run as Docker container was added to the README.md.
Signed-off-by: Kairo de Araujo [email protected]