-
Notifications
You must be signed in to change notification settings - Fork 5
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
Make ETOS API compatible with the kubernetes controller poc #69
base: main
Are you sure you want to change the base?
Conversation
:return: Downloaded test suite as JSON. | ||
""" | ||
try: | ||
suite = requests.get(test_suite_url, timeout=60) |
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.
Should we perhaps add retries? Doesn't etos-library have convenience utils for this?
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.
Adding retries is a bit harder than it seems due to the fact that we are using asyncio. We would need to change from requests to another library for downloads and make sure we have retries that work for that library and the verification would take longer.
We've not had any retries for this function before (I just moved this from the validator to the router), so I'm not making any changes to it and would rather we write a change request on ETOS to fix this.
internal/config/config.go
Outdated
@@ -48,6 +50,7 @@ func Get() Config { | |||
|
|||
flag.StringVar(&conf.serviceHost, "address", EnvOrDefault("SERVICE_HOST", "127.0.0.1"), "Address to serve API on") | |||
flag.StringVar(&conf.servicePort, "port", EnvOrDefault("SERVICE_PORT", "8080"), "Port to serve API on") | |||
flag.StringVar(&conf.stripPrefix, "stripprefix", EnvOrDefault("STRIP_PREFIX", ""), "Which prefix to strip, if any") |
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 text description should be a bit more descriptive. If you don't have access to the code, or know it by heart it's hard to figure out what a prefix is and how it realts to something that needs to be stripped
span.set_attribute("etos.artifact.identity", identity) | ||
|
||
try: | ||
name = test_suite[0].get("name") |
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.
Is it safe to assume the first element in the list is the one we're interested in? Even If so, we should still add code comment.
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.
Not really no, but until we have another input I believe we should try to use at least one name.
Added a comment.
try: | ||
name = test_suite[0].get("name") | ||
# Convert to kubernetes accepted name | ||
name = re.sub(r'[^a-zA-Z0-9]+', '-', name).lower() |
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.
Check length of name and truncate
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.
Added a more robust conversion, added tests for it and a rudimentary truncation in order to be able to add a hyphen at the end. This is only for readability and Kubernetes will truncate the string in generateName if necessary.
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.
Perhaps add a test to check that invalid and too long names gets fixed/truncated.
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.
Added tests for rfc-1123 conversion. Names get truncated by kubernetes when using generateName.
Add a new router for starting ETOS using the new TestRun resource from the ETOS kubernetes controller. Added a root path for the ETOS API python code so that we can make a standard Ingress for the ETOS API. Added StripPrefix to the SSE and LogArea services for so that we can make a standard Ingress for the ETOS API.
d70bb1d
to
f858232
Compare
Force push because of rebase |
Applicable Issues
eiffel-community/etos#242
Description of the Change
Add a new router for starting ETOS using the new TestRun resource from the ETOS kubernetes controller.
Added a root path for the ETOS API python code so that we can make a standard Ingress for the ETOS API.
Added StripPrefix to the SSE and LogArea services for so that we can make a standard Ingress for the ETOS API.
This new router is optional and for use with the proof of concept implementation of an ETOS kubernetes controller.
Alternate Designs
I cannot think of any other. I wanted to remove a few more things, such as the validator etc and move them into the suite runner instead and report the error back to the TestRun object using the controller. I wanted to avoid making too big changes when implementing this poc to make it easier to review what is happening.
Possible Drawbacks
This is, potentially, code that may not be used. This is only a problem if we lose track of it.
Sign-off
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
Signed-off-by: Tobias Persson [email protected]