Skip to content

Commit

Permalink
Fix database create logging code (#1187)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardartoul authored Nov 19, 2018
1 parent b76c38f commit 0b4f851
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/query/api/v1/handler/database/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,18 @@ func (h *createHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {

initPlacement, err := h.placementInitHandler.Init(placement.M3DBServiceName, r, placementRequest)
if err != nil {
// Attempt to delete the namespace that was just created to maintain idempotency
err = h.namespaceDeleteHandler.Delete(namespaceRequest.Name)
if err != nil {
logger.Error("unable to delete namespace we just added", zap.Any("error", err))
// Attempt to delete the namespace that was just created to maintain idempotency.
nsDeleteErr := h.namespaceDeleteHandler.Delete(namespaceRequest.Name)
if nsDeleteErr != nil {
logger.Error(
"unable to delete namespace we just added",
zap.Any("originalError", err),
zap.Any("namespaceDeleteError", nsDeleteErr))
xhttp.Error(w, err, http.StatusInternalServerError)
return
}

logger.Error("unable to add namespace", zap.Any("error", err))
logger.Error("unable to initialize placement", zap.Any("error", err))
xhttp.Error(w, err, http.StatusInternalServerError)
return
}
Expand Down

0 comments on commit 0b4f851

Please sign in to comment.