[FIXED] JetStream: return error on negative replicas count

If a stream is created or updated with a negative replicas count,
and error is now returned. Same for consumers.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
Ivan Kozlovic
2022-10-03 17:06:03 -06:00
parent d9bf82bbda
commit 3c7aa554f7
5 changed files with 90 additions and 0 deletions

View File

@@ -245,6 +245,9 @@ const (
// JSRaftGeneralErrF General RAFT error string ({err})
JSRaftGeneralErrF ErrorIdentifier = 10041
// JSReplicasCountCannotBeNegative replicas count cannot be negative
JSReplicasCountCannotBeNegative ErrorIdentifier = 10133
// JSRestoreSubscribeFailedErrF JetStream unable to subscribe to restore snapshot {subject}: {err}
JSRestoreSubscribeFailedErrF ErrorIdentifier = 10042
@@ -481,6 +484,7 @@ var (
JSNotEnabledForAccountErr: {Code: 503, ErrCode: 10039, Description: "JetStream not enabled for account"},
JSPeerRemapErr: {Code: 503, ErrCode: 10075, Description: "peer remap failed"},
JSRaftGeneralErrF: {Code: 500, ErrCode: 10041, Description: "{err}"},
JSReplicasCountCannotBeNegative: {Code: 400, ErrCode: 10133, Description: "replicas count cannot be negative"},
JSRestoreSubscribeFailedErrF: {Code: 500, ErrCode: 10042, Description: "JetStream unable to subscribe to restore snapshot {subject}: {err}"},
JSSequenceNotFoundErrF: {Code: 400, ErrCode: 10043, Description: "sequence {seq} not found"},
JSSnapshotDeliverSubjectInvalidErr: {Code: 400, ErrCode: 10015, Description: "deliver subject not valid"},
@@ -1423,6 +1427,16 @@ func NewJSRaftGeneralError(err error, opts ...ErrorOption) *ApiError {
}
}
// NewJSReplicasCountCannotBeNegativeError creates a new JSReplicasCountCannotBeNegative error: "replicas count cannot be negative"
func NewJSReplicasCountCannotBeNegativeError(opts ...ErrorOption) *ApiError {
eopts := parseOpts(opts)
if ae, ok := eopts.err.(*ApiError); ok {
return ae
}
return ApiErrors[JSReplicasCountCannotBeNegative]
}
// NewJSRestoreSubscribeFailedError creates a new JSRestoreSubscribeFailedErrF error: "JetStream unable to subscribe to restore snapshot {subject}: {err}"
func NewJSRestoreSubscribeFailedError(err error, subject interface{}, opts ...ErrorOption) *ApiError {
eopts := parseOpts(opts)