dlr-eoc / prosEO

prosEO – A Processing System for Earth Observation Data
GNU General Public License v3.0
14 stars 1 forks source link

Production Planner: Forward error messages to caller using "Warning" HTTP header #93

Closed tangobravo62 closed 1 year ago

tangobravo62 commented 4 years ago

Currently, a lot of error messages in the Production Planner get logged, but they are not returned to the requester of the REST call, e. g. it is logged: (E3036) Processing order 'NM4T_Order_1' requested processor(s) not set but later on the distinction of the error causes is lost, and a generic RuntimeException is issued (resulting in an HTTP status code 500):

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: publishOrder rollback] with root cause
java.lang.RuntimeException: publishOrder rollback

The code of the Production Planner shall be reworked overall so as to make the original cause of each single error visible to the originator by returning a suitable HTTP status code (400 BAD REQUEST in this case) and the original error message including error code in the "Warning:" HTTP header.

tangobravo62 commented 3 years ago

Another example of this, where it would be helpful to get the original error (cause: product file name template cannot be formatted with current product data, because one parameter value is missing):

2020-11-02 16:49:22.090 ERROR 1 --- [nio-8080-exec-2] d.dlr.proseo.planner.kubernetes.KubeJob  : Creation of job order for job step 48747 failed
org.springframework.expression.spel.SpelEvaluationException: EL1011E: Method call: Attempted to call method getParameterValue() on null context object
    at org.springframework.expression.spel.ast.MethodReference.throwIfNotNullSafe(MethodReference.java:153)
    at org.springframework.expression.spel.ast.MethodReference.getValueRef(MethodReference.java:82)
    at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:68)
    at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:89)
    at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:109)
    at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:201)
    at de.dlr.proseo.model.Product.generateFilename(Product.java:562)
    at de.dlr.proseo.planner.dispatcher.JobDispatcher.addIpfIOOutput(JobDispatcher.java:265)
    at de.dlr.proseo.planner.dispatcher.JobDispatcher.addIpfIOOutput(JobDispatcher.java:281)
    at de.dlr.proseo.planner.dispatcher.JobDispatcher.createJobOrder(JobDispatcher.java:142)
    at de.dlr.proseo.planner.kubernetes.KubeJob.createJob(KubeJob.java:296)
    at de.dlr.proseo.planner.kubernetes.KubeConfig.createJob(KubeConfig.java:501)
    at de.dlr.proseo.planner.util.JobStepUtil.checkOrderToRun(JobStepUtil.java:676)
    at de.dlr.proseo.planner.util.JobStepUtil$$FastClassBySpringCGLIB$$ff789608.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
    at de.dlr.proseo.planner.util.JobStepUtil$$EnhancerBySpringCGLIB$$c53cdd7e.checkOrderToRun(<generated>)
    at de.dlr.proseo.planner.rest.OrderControllerImpl.releaseOrder(OrderControllerImpl.java:277)
    at de.dlr.proseo.planner.rest.OrderControllerImpl$$FastClassBySpringCGLIB$$3448bed9.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
    at de.dlr.proseo.planner.rest.OrderControllerImpl$$EnhancerBySpringCGLIB$$3500e291.releaseOrder(<generated>)
    at de.dlr.proseo.model.rest.OrderControllerDecorator.releaseOrder(OrderControllerDecorator.java:94)
    at de.dlr.proseo.model.rest.OrderControllerDecorator$$FastClassBySpringCGLIB$$58418ef9.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.validation.beanvalidation.MethodValidationInterceptor.invoke(MethodValidationInterceptor.java:119)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
    at de.dlr.proseo.model.rest.OrderControllerDecorator$$EnhancerBySpringCGLIB$$95c6e3d0.releaseOrder(<generated>)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:879)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
emelchinger commented 3 years ago

The error messages are forwarded to the caller(s). Especially in planOrder (which wasn't implemented yet). This is tested with in some cases, mostly using debugger to set "wrong" answers, e.g.:

/proseo/planner/v0.1/orders/plan/4661?facility=Lerchenhof1 -> Warning: (E3047) Processing facility 'unknown' does not exist

proseo/planner/v0.1/orders/plan/4661?facility=Lerchenhof -> Warning: (E3108) Internal Server Error: Illegal Argument Exception '(E3042) OrderDispatcher: no configured processor found for product class 'PTM_L2B'' | (E3108) Internal Server Error: Illegal Argument Exception 'L2orbits3000-3002-1'

/proseo/planner/v0.1/orders/release/4661 -> Warning: 199 proseo-planner (E3021) Processing order '4661' has to be planned