add warn log with cause to AbstractNeutronNorthbound for 442 and 500 65/73665/2
authorMichael Vorburger <vorburger@redhat.com>
Mon, 2 Jul 2018 19:11:10 +0000 (21:11 +0200)
committerMichael Vorburger <vorburger@redhat.com>
Mon, 2 Jul 2018 19:12:21 +0000 (21:12 +0200)
Just in case the Neutron Driver does not log what we propagate to it
nicely for operators to find in debugging, it perhaps does not hurt if
we put a WARN log on the ODL side in case of problems due to both the
new dependency check mechanism and datastore exceptions propagate
(including mandatory YANG validation).

JIRA: NEUTRON-157
Change-Id: I2c55e707c9d48f78fd60a8e22af6a799976d86bf
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/AbstractNeutronNorthbound.java

index bb9158f53a97624c4016b5b677c1765aab919409..c1c1dd794cf628df21ba65a6fb73cec4d903d226 100644 (file)
@@ -21,10 +21,14 @@ import org.opendaylight.neutron.spi.INeutronCRUD;
 import org.opendaylight.neutron.spi.INeutronCRUD.Result;
 import org.opendaylight.neutron.spi.INeutronObject;
 import org.opendaylight.yangtools.yang.common.OperationFailedException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public abstract class AbstractNeutronNorthbound<T extends INeutronObject<T>, R extends INeutronRequest<T>,
         I extends INeutronCRUD<T>> {
 
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractNeutronNorthbound.class);
+
     // T extends INeutronObject<T> as 0th type argument
     private static final int NEUTRON_ARGUMENT_TYPE_INDEX = 0;
     // NeutronRequest extends INeutronRequest<T> as 1st type argument
@@ -97,6 +101,7 @@ public abstract class AbstractNeutronNorthbound<T extends INeutronObject<T>, R e
                 return Response.status(HttpURLConnection.HTTP_OK).entity(newNeutronRequest(ans)).build();
             }
         } catch (OperationFailedException e) {
+            LOG.warn("get failed due to datastore problem; uuid: {}", uuid);
             throw new DatastoreOperationFailedWebApplicationException(e);
         }
     }
@@ -117,12 +122,14 @@ public abstract class AbstractNeutronNorthbound<T extends INeutronObject<T>, R e
                 for (T test : input.getBulk()) {
                     test.initDefaults();
                     if (neutronCRUD.add(test).equals(DependencyMissing)) {
+                        LOG.warn("create failed due to input missing dependencies: {}", input);
                         return Response.status(HTTP_MISSING_DEPENDENCY).entity(input).build();
                     }
                 }
             }
             return Response.status(HttpURLConnection.HTTP_CREATED).entity(input).build();
         } catch (OperationFailedException e) {
+            LOG.warn("create failed due to datastore problem (possibly missing required fields); input: {}", input);
             throw new DatastoreOperationFailedWebApplicationException(e);
         }
     }
@@ -166,11 +173,13 @@ public abstract class AbstractNeutronNorthbound<T extends INeutronObject<T>, R e
             if (updateResult.equals(DoesNotExist)) {
                 throw new ResourceNotFoundException(uuidNoExist());
             } else if (updateResult.equals(DependencyMissing)) {
+                LOG.warn("update failed due to missing dependencies; input: {}", input);
                 return Response.status(HTTP_MISSING_DEPENDENCY).entity(input).build();
             }
             T updated = neutronCRUD.get(uuid);
             return Response.status(HttpURLConnection.HTTP_OK).entity(newNeutronRequest(updated)).build();
         } catch (OperationFailedException e) {
+            LOG.warn("update failed due to datastore problem (possibly missing required fields); input: {}", input);
             throw new DatastoreOperationFailedWebApplicationException(e);
         }
     }
@@ -184,6 +193,7 @@ public abstract class AbstractNeutronNorthbound<T extends INeutronObject<T>, R e
                 return Response.status(HttpURLConnection.HTTP_NO_CONTENT).build();
             }
         } catch (OperationFailedException e) {
+            LOG.warn("delete failed due to datastore problem; uuid: {}", uuid);
             throw new DatastoreOperationFailedWebApplicationException(e);
         }
     }