|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
jcline commented 6 years ago | ||
mjia commented 6 years ago Yeah, I believe this will more likely be changed when more policies are added. I would like to keep it like that for the first version. | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
jcline commented 6 years ago I know there was a decision to not use a REST framework, but this schema validation could be handled in a much more readable way with any number of libraries. Something like marshmallow (which, incidentally, flask-restful is going to start recommending) would do this and it pulls the schema definition/validation out of the request handler. Just a thought. | ||
mjia commented 6 years ago Marshmallow might be a good option if we have many APIs doing this like that. For this small app, it might be overkill. I would rather improve the error messages to be more readable. | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
jcline commented 6 years ago This approach defeats the purpose of using a session since the session is discarded after each request is handled. The session must live beyond the request/response cycle. | ||
mjia commented 6 years ago I'm not quite sure what you mean since I'm using a context manager here which creates a global session. It will be closed once all the requests inside the context manager are handled. | ||
|
||
|
||
|
||
|
||
|
||
|
||
jcline commented 6 years ago I don't see any error handling code for the exception this raises, so the response is likely an HTTP 500 rather than a more useful error message about the service being unavailable or something. The cleanest way to handle this likely with an error handler for the various requests exception types. | ||
mjia commented 6 years ago Yeah, I will fix this in the following PRs. | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
dcallagh commented 6 years ago If we are going full container, then we can probably take this stuff back out. There is no real solution for structured logging in OpenShift, it's all just plain text to stdout (a big step backwards IMHO). | ||
dcallagh commented 6 years ago If we are going full container, then we can probably take this stuff back out. There is no real solution for structured logging in OpenShift, it's all just plain text to stdout (a big step backwards IMHO). | ||
mjia commented 6 years ago Well, I would say it doesn't hurt to have this here. | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
dcallagh commented 6 years ago Actually looking at the ruleset it seems there is no actual requirement that the RPMDiff results pass or are waived. :-) But we can fix that in a later patch once this is merged... | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
Imagine that Errata wants to move a RHEL-7 advisory from New Files to QE. It will send a query to Greenwave to ask for a decision.
A POST request could be sent to https://greenwave.example.com/api/v1.0/decision with a json body:
{
'product_version': 'rhel-7',
'decision_context' : 'errta_newfile_to_qe',
'subject' : ['java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3']
}
Greenwave returns a decision as a JSON object. If all the policies are satisfied, the response could be
{
'policies_satisified': True,
'summary': 'java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3: policy 1 is satisfied as all required tests are passing',
'applicable_policies': [1],
'unsatisfied_requirements': None
}
If one of the polices is not satisfied, the response could be
{
'policies_satisified': False,
'summary': 'java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3: 2 of 3 required tests failed, the policy 1 is not satisfied',
'applicable_policies': [1],
'unsatisfied_requirements': [
{
'item': 'java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3',
'testcase': 'dist.rpmdiff.comparison.xml_validity',
'type': 'test-result-missing'
} ,
{
'item': 'java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3',
'testcase': 'dist.rpmdiff.comparison.virus_scan',
'type': 'test-result-failed'
} ,
....
]
}
TODO: add more policies
I suggest refactoring this function into several smaller functions that the route handler ties together. It's difficult to follow due to the multiple nested loops and if statements.