Skip to content

Commit

Permalink
chore: add a bit more logging to issues with datastore
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanLonguet committed Apr 25, 2024
1 parent 622cb9c commit 0d3ddd3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/datastore/api/plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (a *API) PutPlanHandler(c echo.Context) error {
content = []byte(request.Plan)
err = a.Storage.PutPlan(namespace, layer, run, attempt, format, content)
if err != nil {
return c.String(http.StatusInternalServerError, "could not put logs, there's an issue with the storage backend")
return c.String(http.StatusInternalServerError, "could not put logs, there's an issue with the storage backend: "+err.Error())
}
return c.NoContent(http.StatusOK)
}
6 changes: 5 additions & 1 deletion internal/datastore/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ func (c *DefaultClient) PutPlan(namespace string, layer string, run string, atte
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("could not put plan, there's an issue with the storage backend")
message, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("could not put plan, there's an issue reading the response from datastore")
}
return fmt.Errorf("could not put plan, there's an issue with the storage backend: %s", string(message))
}
return nil
}
Expand Down

0 comments on commit 0d3ddd3

Please sign in to comment.