17
import "github.com/cubefs/cubefs/util/errors"
21
ErrSuc = errors.New("success")
22
ErrInternalError = errors.New("internal error")
23
ErrParamError = errors.New("parameter error")
24
ErrInvalidCfg = errors.New("bad configuration file")
25
ErrPersistenceByRaft = errors.New("persistence by raft occurred error")
26
ErrMarshalData = errors.New("marshal data error")
27
ErrUnmarshalData = errors.New("unmarshal data error")
28
ErrVolNotExists = errors.New("vol not exists")
29
ErrMetaPartitionNotExists = errors.New("meta partition not exists")
30
ErrDataPartitionNotExists = errors.New("data partition not exists")
31
ErrDataNodeNotExists = errors.New("data node not exists")
32
ErrMetaNodeNotExists = errors.New("meta node not exists")
33
ErrDuplicateVol = errors.New("duplicate vol")
34
ErrActiveDataNodesTooLess = errors.New("no enough active data node")
35
ErrActiveMetaNodesTooLess = errors.New("no enough active meta node")
36
ErrInvalidMpStart = errors.New("invalid meta partition start value")
37
ErrNoAvailDataPartition = errors.New("no available data partition")
38
ErrReshuffleArray = errors.New("the array to be reshuffled is nil")
40
ErrIllegalDataReplica = errors.New("data replica is illegal")
42
ErrMissingReplica = errors.New("a missing data replica is found")
43
ErrHasOneMissingReplica = errors.New("there is a missing replica")
45
ErrNoDataNodeToWrite = errors.New("No data node available for creating a data partition")
46
ErrNoMetaNodeToWrite = errors.New("No meta node available for creating a meta partition")
48
ErrCannotBeOffLine = errors.New("cannot take the data replica offline")
49
ErrNoDataNodeToCreateDataPartition = errors.New("no enough data nodes for creating a data partition")
50
ErrNoZoneToCreateDataPartition = errors.New("no zone available for creating a data partition")
51
ErrNoZoneToCreateMetaPartition = errors.New("no zone available for creating a meta partition")
52
ErrNoNodeSetToCreateDataPartition = errors.New("no node set available for creating a data partition")
53
ErrNoNodeSetToCreateMetaPartition = errors.New("no node set available for creating a meta partition")
54
ErrNoMetaNodeToCreateMetaPartition = errors.New("no enough meta nodes for creating a meta partition")
55
ErrIllegalMetaReplica = errors.New("illegal meta replica")
56
ErrNoEnoughReplica = errors.New("no enough replicas")
57
ErrNoLeader = errors.New("no leader")
58
ErrVolAuthKeyNotMatch = errors.New("client and server auth key do not match")
59
ErrAuthKeyStoreError = errors.New("auth keystore error")
60
ErrAuthAPIAccessGenRespError = errors.New("auth API access response error")
61
ErrAuthOSCapsOpGenRespError = errors.New("auth Object Storage node API response error")
62
ErrKeyNotExists = errors.New("key not exists")
63
ErrDuplicateKey = errors.New("duplicate key")
64
ErrAccessKeyNotExists = errors.New("access key not exists")
65
ErrInvalidTicket = errors.New("invalid ticket")
66
ErrInvalidClientIDKey = errors.New("invalid clientIDKey")
67
ErrExpiredTicket = errors.New("expired ticket")
68
ErrMasterAPIGenRespError = errors.New("master API generate response error")
69
ErrDuplicateUserID = errors.New("duplicate user id")
70
ErrUserNotExists = errors.New("user not exists")
71
ErrReadBodyError = errors.New("read request body failed")
72
ErrVolPolicyNotExists = errors.New("vol policy not exists")
73
ErrDuplicateAccessKey = errors.New("duplicate access key")
74
ErrHaveNoPolicy = errors.New("no vol policy")
75
ErrZoneNotExists = errors.New("zone not exists")
76
ErrOwnVolExists = errors.New("own vols not empty")
77
ErrSuperAdminExists = errors.New("super administrator exists ")
78
ErrInvalidUserID = errors.New("invalid user ID")
79
ErrInvalidUserType = errors.New("invalid user type")
80
ErrNoPermission = errors.New("no permission")
81
ErrTokenNotFound = errors.New("token not found")
82
ErrInvalidAccessKey = errors.New("invalid access key")
83
ErrInvalidSecretKey = errors.New("invalid secret key")
84
ErrIsOwner = errors.New("user owns the volume")
85
ErrZoneNum = errors.New("zone num not qualified")
86
ErrNoNodeSetToUpdateDecommissionLimit = errors.New("no node set available for updating decommission limit")
87
ErrNoNodeSetToQueryDecommissionLimitStatus = errors.New("no node set available for query decommission limit status")
88
ErrNoNodeSetToDecommission = errors.New("no node set available to decommission ")
89
ErrVolNoAvailableSpace = errors.New("vol has no available space")
90
ErrVolNoCacheAndRule = errors.New("vol has no cache and rule")
91
ErrNoAclPermission = errors.New("acl no permission")
92
ErrQuotaNotExists = errors.New("quota not exists")
93
ErrCodeVersionOp = errors.New("version op failed")
94
ErrNoSuchLifecycleConfiguration = errors.New("The lifecycle configuration does not exist")
95
ErrNoNodeSetToUpdateDecommissionDiskFactor = errors.New("no node set available for updating decommission disk factor")
96
ErrNoNodeSetToQueryDecommissionDiskLimit = errors.New("no node set available for query decommission disk limit")
97
ErrNodeSetNotExists = errors.New("node set not exists")
98
ErrCompressFailed = errors.New("compress data failed")
99
ErrDecompressFailed = errors.New("decompress data failed")
104
ErrCodeSuccess = iota
108
ErrCodePersistenceByRaft
112
ErrCodeMetaPartitionNotExists
113
ErrCodeDataPartitionNotExists
114
ErrCodeDataNodeNotExists
115
ErrCodeMetaNodeNotExists
117
ErrCodeActiveDataNodesTooLess
118
ErrCodeActiveMetaNodesTooLess
119
ErrCodeInvalidMpStart
120
ErrCodeNoAvailDataPartition
121
ErrCodeReshuffleArray
122
ErrCodeIllegalDataReplica
123
ErrCodeMissingReplica
124
ErrCodeHasOneMissingReplica
125
ErrCodeNoDataNodeToWrite
126
ErrCodeNoMetaNodeToWrite
127
ErrCodeCannotBeOffLine
128
ErrCodeNoDataNodeToCreateDataPartition
129
ErrCodeNoZoneToCreateDataPartition
130
ErrCodeNoNodeSetToCreateDataPartition
131
ErrCodeNoNodeSetToCreateMetaPartition
132
ErrCodeNoMetaNodeToCreateMetaPartition
133
ErrCodeIllegalMetaReplica
134
ErrCodeNoEnoughReplica
136
ErrCodeVolAuthKeyNotMatch
137
ErrCodeAuthKeyStoreError
138
ErrCodeAuthAPIAccessGenRespError
139
ErrCodeAuthRaftNodeGenRespError
140
ErrCodeAuthOSCapsOpGenRespError
141
ErrCodeAuthReqRedirectError
142
ErrCodeAccessKeyNotExists
144
ErrCodeInvalidClientIDKey
146
ErrCodeMasterAPIGenRespError
147
ErrCodeDuplicateUserID
150
ErrCodeVolPolicyNotExists
151
ErrCodeDuplicateAccessKey
153
ErrCodeNoZoneToCreateMetaPartition
156
ErrCodeSuperAdminExists
158
ErrCodeInvalidUserType
161
ErrCodeInvalidAccessKey
162
ErrCodeInvalidSecretKey
165
ErrCodeVersionOpError
166
ErrCodeNodeSetNotExists
170
var Err2CodeMap = map[error]int32{
171
ErrSuc: ErrCodeSuccess,
172
ErrInternalError: ErrCodeInternalError,
173
ErrParamError: ErrCodeParamError,
174
ErrInvalidCfg: ErrCodeInvalidCfg,
175
ErrPersistenceByRaft: ErrCodePersistenceByRaft,
176
ErrMarshalData: ErrCodeMarshalData,
177
ErrUnmarshalData: ErrCodeUnmarshalData,
178
ErrVolNotExists: ErrCodeVolNotExists,
179
ErrMetaPartitionNotExists: ErrCodeMetaPartitionNotExists,
180
ErrDataPartitionNotExists: ErrCodeDataPartitionNotExists,
181
ErrDataNodeNotExists: ErrCodeDataNodeNotExists,
182
ErrMetaNodeNotExists: ErrCodeMetaNodeNotExists,
183
ErrDuplicateVol: ErrCodeDuplicateVol,
184
ErrActiveDataNodesTooLess: ErrCodeActiveDataNodesTooLess,
185
ErrActiveMetaNodesTooLess: ErrCodeActiveMetaNodesTooLess,
186
ErrInvalidMpStart: ErrCodeInvalidMpStart,
187
ErrNoAvailDataPartition: ErrCodeNoAvailDataPartition,
188
ErrReshuffleArray: ErrCodeReshuffleArray,
189
ErrIllegalDataReplica: ErrCodeIllegalDataReplica,
190
ErrMissingReplica: ErrCodeMissingReplica,
191
ErrHasOneMissingReplica: ErrCodeHasOneMissingReplica,
192
ErrNoDataNodeToWrite: ErrCodeNoDataNodeToWrite,
193
ErrNoMetaNodeToWrite: ErrCodeNoMetaNodeToWrite,
194
ErrCannotBeOffLine: ErrCodeCannotBeOffLine,
195
ErrNoDataNodeToCreateDataPartition: ErrCodeNoDataNodeToCreateDataPartition,
196
ErrNoZoneToCreateDataPartition: ErrCodeNoZoneToCreateDataPartition,
197
ErrNoZoneToCreateMetaPartition: ErrCodeNoZoneToCreateMetaPartition,
198
ErrNoNodeSetToCreateDataPartition: ErrCodeNoNodeSetToCreateDataPartition,
199
ErrNoNodeSetToCreateMetaPartition: ErrCodeNoNodeSetToCreateMetaPartition,
200
ErrNoMetaNodeToCreateMetaPartition: ErrCodeNoMetaNodeToCreateMetaPartition,
201
ErrIllegalMetaReplica: ErrCodeIllegalMetaReplica,
202
ErrNoEnoughReplica: ErrCodeNoEnoughReplica,
203
ErrNoLeader: ErrCodeNoLeader,
204
ErrVolAuthKeyNotMatch: ErrCodeVolAuthKeyNotMatch,
205
ErrAuthKeyStoreError: ErrCodeAuthKeyStoreError,
206
ErrAuthAPIAccessGenRespError: ErrCodeAuthAPIAccessGenRespError,
207
ErrAuthOSCapsOpGenRespError: ErrCodeAuthOSCapsOpGenRespError,
208
ErrAccessKeyNotExists: ErrCodeAccessKeyNotExists,
209
ErrInvalidTicket: ErrCodeInvalidTicket,
210
ErrInvalidClientIDKey: ErrCodeInvalidClientIDKey,
211
ErrExpiredTicket: ErrCodeExpiredTicket,
212
ErrMasterAPIGenRespError: ErrCodeMasterAPIGenRespError,
213
ErrDuplicateUserID: ErrCodeDuplicateUserID,
214
ErrUserNotExists: ErrCodeUserNotExists,
215
ErrReadBodyError: ErrCodeReadBodyError,
216
ErrVolPolicyNotExists: ErrCodeVolPolicyNotExists,
217
ErrDuplicateAccessKey: ErrCodeDuplicateAccessKey,
218
ErrHaveNoPolicy: ErrCodeHaveNoPolicy,
219
ErrZoneNotExists: ErrCodeZoneNotExists,
220
ErrOwnVolExists: ErrCodeOwnVolExists,
221
ErrSuperAdminExists: ErrCodeSuperAdminExists,
222
ErrInvalidUserID: ErrCodeInvalidUserID,
223
ErrInvalidUserType: ErrCodeInvalidUserType,
224
ErrNoPermission: ErrCodeNoPermission,
225
ErrTokenNotFound: ErrCodeTokenNotExist,
226
ErrInvalidAccessKey: ErrCodeInvalidAccessKey,
227
ErrInvalidSecretKey: ErrCodeInvalidSecretKey,
228
ErrIsOwner: ErrCodeIsOwner,
229
ErrZoneNum: ErrCodeZoneNumError,
230
ErrCodeVersionOp: ErrCodeVersionOpError,
231
ErrNodeSetNotExists: ErrCodeNodeSetNotExists,
234
func ParseErrorCode(code int32) error {
235
if err, exist := code2ErrMap[code]; exist {
238
return ErrInternalError
242
var code2ErrMap = map[int32]error{
243
ErrCodeSuccess: ErrSuc,
244
ErrCodeInternalError: ErrInternalError,
245
ErrCodeParamError: ErrParamError,
246
ErrCodeInvalidCfg: ErrInvalidCfg,
247
ErrCodePersistenceByRaft: ErrPersistenceByRaft,
248
ErrCodeMarshalData: ErrMarshalData,
249
ErrCodeUnmarshalData: ErrUnmarshalData,
250
ErrCodeVolNotExists: ErrVolNotExists,
251
ErrCodeMetaPartitionNotExists: ErrMetaPartitionNotExists,
252
ErrCodeDataPartitionNotExists: ErrDataPartitionNotExists,
253
ErrCodeDataNodeNotExists: ErrDataNodeNotExists,
254
ErrCodeMetaNodeNotExists: ErrMetaNodeNotExists,
255
ErrCodeDuplicateVol: ErrDuplicateVol,
256
ErrCodeActiveDataNodesTooLess: ErrActiveDataNodesTooLess,
257
ErrCodeActiveMetaNodesTooLess: ErrActiveMetaNodesTooLess,
258
ErrCodeInvalidMpStart: ErrInvalidMpStart,
259
ErrCodeNoAvailDataPartition: ErrNoAvailDataPartition,
260
ErrCodeReshuffleArray: ErrReshuffleArray,
261
ErrCodeIllegalDataReplica: ErrIllegalDataReplica,
262
ErrCodeMissingReplica: ErrMissingReplica,
263
ErrCodeHasOneMissingReplica: ErrHasOneMissingReplica,
264
ErrCodeNoDataNodeToWrite: ErrNoDataNodeToWrite,
265
ErrCodeNoMetaNodeToWrite: ErrNoMetaNodeToWrite,
266
ErrCodeCannotBeOffLine: ErrCannotBeOffLine,
267
ErrCodeNoDataNodeToCreateDataPartition: ErrNoDataNodeToCreateDataPartition,
268
ErrCodeNoZoneToCreateDataPartition: ErrNoZoneToCreateDataPartition,
269
ErrCodeNoZoneToCreateMetaPartition: ErrNoZoneToCreateMetaPartition,
270
ErrCodeNoNodeSetToCreateDataPartition: ErrNoNodeSetToCreateDataPartition,
271
ErrCodeNoNodeSetToCreateMetaPartition: ErrNoNodeSetToCreateMetaPartition,
272
ErrCodeNoMetaNodeToCreateMetaPartition: ErrNoMetaNodeToCreateMetaPartition,
273
ErrCodeIllegalMetaReplica: ErrIllegalMetaReplica,
274
ErrCodeNoEnoughReplica: ErrNoEnoughReplica,
275
ErrCodeNoLeader: ErrNoLeader,
276
ErrCodeVolAuthKeyNotMatch: ErrVolAuthKeyNotMatch,
277
ErrCodeAuthKeyStoreError: ErrAuthKeyStoreError,
278
ErrCodeAuthAPIAccessGenRespError: ErrAuthAPIAccessGenRespError,
279
ErrCodeAuthOSCapsOpGenRespError: ErrAuthOSCapsOpGenRespError,
280
ErrCodeAccessKeyNotExists: ErrAccessKeyNotExists,
281
ErrCodeInvalidTicket: ErrInvalidTicket,
282
ErrCodeInvalidClientIDKey: ErrInvalidClientIDKey,
283
ErrCodeExpiredTicket: ErrExpiredTicket,
284
ErrCodeMasterAPIGenRespError: ErrMasterAPIGenRespError,
285
ErrCodeDuplicateUserID: ErrDuplicateUserID,
286
ErrCodeUserNotExists: ErrUserNotExists,
287
ErrCodeReadBodyError: ErrReadBodyError,
288
ErrCodeVolPolicyNotExists: ErrVolPolicyNotExists,
289
ErrCodeDuplicateAccessKey: ErrDuplicateAccessKey,
290
ErrCodeHaveNoPolicy: ErrHaveNoPolicy,
291
ErrCodeZoneNotExists: ErrZoneNotExists,
292
ErrCodeOwnVolExists: ErrOwnVolExists,
293
ErrCodeSuperAdminExists: ErrSuperAdminExists,
294
ErrCodeInvalidUserType: ErrInvalidUserType,
295
ErrCodeInvalidUserID: ErrInvalidUserID,
296
ErrCodeNoPermission: ErrNoPermission,
297
ErrCodeTokenNotExist: ErrTokenNotFound,
298
ErrCodeInvalidAccessKey: ErrInvalidAccessKey,
299
ErrCodeInvalidSecretKey: ErrInvalidSecretKey,
300
ErrCodeIsOwner: ErrIsOwner,
301
ErrCodeZoneNumError: ErrZoneNum,
302
ErrCodeVersionOpError: ErrCodeVersionOp,
303
ErrCodeNodeSetNotExists: ErrNodeSetNotExists,
306
type GeneralResp struct {
311
func Success(msg string) *GeneralResp {
312
return &GeneralResp{Message: msg, Code: ErrCodeSuccess}