glusterd2
glusterd2 copied to clipboard
API Custom error codes
REST API status code can be used to identify the request is failed or not. Granular error code should be available in error response.
General HTTP status codes
- Success: 200, 201, 204
- Resource not found: 404
- Invalid input/Bad request: 400
- Conflict/Busy: 409
- API error from server: 500
Custom error codes are required for the following(incomplete list, need to identify other failure scenarios)
- Peer add:
- Peer already Exists
- Peer Remove
- Peer not found(HTTP status 404)
- Volume Create
- Volume already exists
- Volume Start
- Volume not found
- Volume already started
- Volume Stop
- Volume not found
- Volume already stopped
- Volume Delete
- Volume not found
@sac @prashanthpai @kshlm @Madhu-1 please add if any other error codes are required.
http.StatusUnauthorized http.StatusUnprocessableEntity
http.StatusUnprocessableEntity
is hard to get right - it's debatable what it means. We removed it a while ago. I'd simply use 400
instead.
I want StatusUnprocessableEntity
to mean that JSON parsing failed but that's not what it's intended for: https://httpstatuses.com/422
@prashanthpai AFAIK we are using http.StatusUnprocessableEntity
in gd2
./glusterd2/commands/snapshot/snapshot-create.go: restutils.SendHTTPError(ctx, w, http.StatusUnprocessableEntity, gderrors.ErrInvalidSnapName)
./glusterd2/commands/snapshot/snapshot-activate.go: restutils.SendHTTPError(ctx, w, http.StatusUnprocessableEntity, err)
./glusterd2/commands/snapshot/snapshot-clone.go: restutils.SendHTTPError(ctx, w, http.StatusUnprocessableEntity, errors.New("Snapshot name should not be empty"))
./glusterd2/commands/snapshot/snapshot-clone.go: restutils.SendHTTPError(ctx, w, http.StatusUnprocessableEntity, gderrors.ErrInvalidVolName)
@Madhu-1 Those needs to be changed
See https://github.com/gluster/glusterd2/issues/611
@prashanthpai agreed.
@aravindavk looks okay to me. I'll check the library once and get back to this.
@Madhu-1 What more work is pending here?
Not a blocker for GCS/1.0 from the revised MVP perspective.