Files
versitygw/rdma/rcroutes/errors_linux.go
T
Jihyeon Gim 1a8d4c9c97 rdma: serialize RC route errors at the route boundary
The RC control routes returned fiber.Error values for 400, 404,
409, 429, 502, and 503 outcomes, but the production S3 error
handler converts ordinary fiber errors into a generic 500
response, so clients observed InternalError for every protocol
outcome. The routes now send the final status and S3-style XML
body themselves through a shared terminal serializer.

S3-aware errors from authentication, authorization, and the
object backend keep their status and code. Session-server
failures map to protocol error codes: InvalidRdmaRequest,
NoSuchRdmaSession, RdmaSessionConflict, RdmaResourceLimit,
RdmaTransferFailed, and RdmaServiceUnavailable. Owner mismatch
answers the same 404 as an unknown session so a session id is
never disclosed across principals. The platform stub keeps its
501 answer and uses the same response shape.
2026-09-04 19:44:45 +09:00

85 lines
2.7 KiB
Go

// Copyright 2026 Versity Software
// This file is licensed under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an "AS
// IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language
// governing permissions and limitations under the License.
//go:build linux && amd64 && cgo
package rcroutes
import (
"errors"
"github.com/versity/versitygw/rdma/rcserver"
)
// This file keeps the Linux-only error classifiers next to the
// shared terminal serializer in errors.go. The marker types below
// carry only the intended protocol class; the HTTP status and XML
// body are decided in one place.
// errRouteBadRequest marks a malformed control request (invalid
// header value, bad argument).
type errRouteBadRequest struct{}
func (errRouteBadRequest) Error() string { return "invalid RDMA control request" }
// errRouteUnavailable marks admission refusal during shutdown.
type errRouteUnavailable struct{}
func (errRouteUnavailable) Error() string {
return "RDMA service is shutting down"
}
// isRouteBadRequest reports whether err is a malformed-request
// class error from the Linux route handlers.
func isRouteBadRequest(err error) bool {
var bad errRouteBadRequest
return errors.As(err, &bad)
}
// isRouteNotFound reports whether err identifies an unknown or
// cross-principal session; both map to the same response so the
// session id is not disclosed across principals.
func isRouteNotFound(err error) bool {
return errors.Is(err, rcserver.ErrNoSession)
}
// isRouteConflict reports whether err is a stale, duplicate, or
// wrong-state session error.
func isRouteConflict(err error) bool {
return errors.Is(err, rcserver.ErrStale) ||
errors.Is(err, rcserver.ErrState) ||
errors.Is(err, rcserver.ErrDouble)
}
// isRouteLimit reports whether err was caused by a configured
// resource limit.
func isRouteLimit(err error) bool {
return errors.Is(err, rcserver.ErrLimit)
}
// isRouteBadGateway reports whether the RC wire transfer failed.
func isRouteBadGateway(err error) bool {
return errors.Is(err, rcserver.ErrWire)
}
// isRouteUnavailable reports whether the RC service refused
// admission or is shutting down.
func isRouteUnavailable(err error) bool {
var unavail errRouteUnavailable
return errors.As(err, &unavail)
}
// isRouteNotImplemented reports whether the platform stub answered
// the request; always false on Linux builds.
func isRouteNotImplemented(err error) bool { return false }