From 20eae644c58d0a8ab675fe965a66c8ba0234e72c Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Mon, 2 Jul 2018 21:11:10 +0200 Subject: [PATCH] add warn log with cause to AbstractNeutronNorthbound for 442 and 500 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 --- .../northbound/api/AbstractNeutronNorthbound.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/AbstractNeutronNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/AbstractNeutronNorthbound.java index bb9158f53..c1c1dd794 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/AbstractNeutronNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/AbstractNeutronNorthbound.java @@ -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, R extends INeutronRequest, I extends INeutronCRUD> { + private static final Logger LOG = LoggerFactory.getLogger(AbstractNeutronNorthbound.class); + // T extends INeutronObject as 0th type argument private static final int NEUTRON_ARGUMENT_TYPE_INDEX = 0; // NeutronRequest extends INeutronRequest as 1st type argument @@ -97,6 +101,7 @@ public abstract class AbstractNeutronNorthbound, 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, 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, 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, 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); } } -- 2.36.6