-
Notifications
You must be signed in to change notification settings - Fork 52
/
errors.go
36 lines (31 loc) · 2.35 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package errors
import (
"errors"
"fmt"
utilerrors "github.com/rancher/opni/pkg/util/errors"
"google.golang.org/grpc/codes"
)
var (
ErrInvalidList = utilerrors.New(codes.FailedPrecondition, errors.New("list did not return exactly 1 result"))
ErrInvalidPersistence = utilerrors.New(codes.InvalidArgument, errors.New("invalid persistence config"))
ErrInvalidDataPersistence = utilerrors.New(codes.InvalidArgument, errors.New("minimum of 2 data nodes required if no persistent storage"))
ErrInvalidUpgradeOptions = utilerrors.New(codes.InvalidArgument, errors.New("upgrade options not valid with current cluster config"))
ErrClusterIDMissing = utilerrors.New(codes.InvalidArgument, errors.New("request does not include cluster ID"))
ErrOpensearchResponse = utilerrors.New(codes.Unavailable, errors.New("opensearch request unsuccessful"))
ErrNoOpensearchClient = utilerrors.New(codes.Unavailable, errors.New("opensearch client is not set"))
ErrLoggingCapabilityExists = utilerrors.New(codes.FailedPrecondition, errors.New("at least one cluster has logging capability installed"))
ErrInvalidDuration = utilerrors.New(codes.InvalidArgument, errors.New("duration must be integer and time unit, e.g 7d"))
ErrRequestMissingMemory = utilerrors.New(codes.InvalidArgument, errors.New("memory limit must be configured"))
ErrMissingDataNode = utilerrors.New(codes.InvalidArgument, errors.New("request must contain data nodes"))
ErrRequestGtLimits = utilerrors.New(codes.InvalidArgument, errors.New("cpu requests must not be more than cpu limits"))
ErrReplicasZero = utilerrors.New(codes.InvalidArgument, errors.New("replicas must be a positive nonzero integer"))
ErrAlreadyExists = utilerrors.New(codes.AlreadyExists, errors.New("object with that name already exists"))
ErrObjectNotFound = utilerrors.New(codes.NotFound, errors.New("object not found"))
ErrSnapshotName = utilerrors.New(codes.InvalidArgument, errors.New("snapshot name is required"))
)
func WrappedGetPrereqFailed(inner error) *utilerrors.GRPCError {
return utilerrors.New(codes.FailedPrecondition, fmt.Errorf("failed to get required object: %w", inner))
}
func WrappedOpensearchFailure(inner error) *utilerrors.GRPCError {
return utilerrors.New(codes.Internal, fmt.Errorf("error communicating with opensearch: %w", inner))
}