feat: add python script to translate pod health summary#503
feat: add python script to translate pod health summary#503Elsie4ever wants to merge 4 commits intoAzure:devfrom
Conversation
|
|
||
| # get current time | ||
| current_time = datetime.fromisoformat(get_timestamp_now_utc()).replace(tzinfo=timezone.utc) | ||
| translated["age"] = str(current_time - created_at) |
There was a problem hiding this comment.
I would not do this - it will provide invalid data based on how old the support bundle is.
Is there a way to get the time the support bundle is created (ex: the support bundle name, assuming it is not changed - you can prob throw an error if the name has changed)
|
|
||
| if is_pod_terminated: | ||
| # status is the reason for termination | ||
| translated["status"] = [ |
There was a problem hiding this comment.
nit: you can use next here and in the next if branch
| console = Console(file=write_file) | ||
| console.print(table) | ||
|
|
||
| # Test serialized content |
There was a problem hiding this comment.
maybe have a flag to do test the script?
| TestCase().assertEqual(data, payload_to_integrate) | ||
| elif output_format == "txt": | ||
| payload_to_integrate = content | ||
| test_file_path = "./test_file.txt" |
There was a problem hiding this comment.
this can be an issue if the test_file.txt is already there (and has data)
| import sys | ||
| from unittest import TestCase | ||
| from zipfile import ZipFile | ||
| from rich.console import Console |
There was a problem hiding this comment.
see if you can avoid using rich (to avoid having dependencies). If needed, make sure you note that this is a dependency (you can make a long comment at the top after the header)
|
|
||
| import yaml | ||
|
|
||
| from azext_edge.edge.util.common import get_timestamp_now_utc |
There was a problem hiding this comment.
same thing here as for rich - see if you can still use the script if you install the whl
(basically try to see if you can make this a script others can run without setting up the azure-iot-ops extension for development)
| from azext_edge.edge.util.common import get_timestamp_now_utc | ||
|
|
||
|
|
||
| def process_supportbundle(bundle_path: str, output_format: str = "json"): |
There was a problem hiding this comment.
add docstrings (it is obvious for us but would be useful for others)
As discussed, creating a python script to translate pod health summary from all the pod .yaml files
the input will be:
json format

txt format

Has validated the output with multiple support bundle instances by comparing output with
kubectl get podsthe logic of this translation are from Kubernetes git hub repos and official documentations
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
Thank you for contributing to Azure IoT Operations tooling!
This checklist is used to make sure that common guidelines for a pull request are followed.
General Guidelines
Intent for Production
devormainare of production grade. Corollary to this, any merged contributions to these branches may be deployed in a public release at any given time. By checking this box, you agree and commit to the expected production quality of code.Basic expectations
pytest <project root> -vv. Please provide evidence in the form of a screenshot showing a succesful run of tests locally OR a link to a test pipeline that has been run against the change-set..pylintrcand.flake8rules? Look at the CI scripts for example usage.Azure IoT Operations CLI maintainers reserve the right to enforce any of the outlined expectations.
A PR is considered ready for review when all basic expectations have been met (or do not apply).