mirror of https://github.com/milvus-io/milvus.git
enhance: remove legacy error related code (#28385)
/kind improvement Signed-off-by: yah01 <yah2er0ne@outlook.com>pull/28136/head
parent
2d7bcac848
commit
e9ff7ed13d
|
@ -1,57 +0,0 @@
|
|||
// Licensed to the LF AI & Data foundation under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you 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.
|
||||
|
||||
package healthz
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/milvus-io/milvus/pkg/log"
|
||||
"github.com/milvus-io/milvus/pkg/util/milvuserrors"
|
||||
)
|
||||
|
||||
func componentsNotServingHandler(w http.ResponseWriter, r *http.Request, msg string) {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Header().Set(ContentTypeHeader, ContentTypeText)
|
||||
_, err := fmt.Fprint(w, msg)
|
||||
if err != nil {
|
||||
log.Warn("failed to send response",
|
||||
zap.Error(err))
|
||||
}
|
||||
}
|
||||
|
||||
func rootCoordNotServingHandler(w http.ResponseWriter, r *http.Request) {
|
||||
componentsNotServingHandler(w, r, milvuserrors.MsgRootCoordNotServing)
|
||||
}
|
||||
|
||||
func queryCoordNotServingHandler(w http.ResponseWriter, r *http.Request) {
|
||||
componentsNotServingHandler(w, r, milvuserrors.MsgQueryCoordNotServing)
|
||||
}
|
||||
|
||||
func dataCoordNotServingHandler(w http.ResponseWriter, r *http.Request) {
|
||||
componentsNotServingHandler(w, r, milvuserrors.MsgDataCoordNotServing)
|
||||
}
|
||||
|
||||
func indexCoordNotServingHandler(w http.ResponseWriter, r *http.Request) {
|
||||
componentsNotServingHandler(w, r, milvuserrors.MsgIndexCoordNotServing)
|
||||
}
|
||||
|
||||
func proxyNotServingHandler(w http.ResponseWriter, r *http.Request) {
|
||||
componentsNotServingHandler(w, r, milvuserrors.MsgProxyNotServing)
|
||||
}
|
|
@ -38,7 +38,6 @@ import (
|
|||
"github.com/milvus-io/milvus/pkg/common"
|
||||
"github.com/milvus-io/milvus/pkg/util/funcutil"
|
||||
"github.com/milvus-io/milvus/pkg/util/merr"
|
||||
"github.com/milvus-io/milvus/pkg/util/milvuserrors"
|
||||
"github.com/milvus-io/milvus/pkg/util/typeutil"
|
||||
"github.com/milvus-io/milvus/pkg/util/uniquegenerator"
|
||||
)
|
||||
|
@ -268,14 +267,6 @@ func (coord *RootCoordMock) CreateCollection(ctx context.Context, req *milvuspb.
|
|||
coord.collMtx.Lock()
|
||||
defer coord.collMtx.Unlock()
|
||||
|
||||
_, exist := coord.collName2ID[req.CollectionName]
|
||||
if exist {
|
||||
return &commonpb.Status{
|
||||
ErrorCode: commonpb.ErrorCode_UnexpectedError,
|
||||
Reason: milvuserrors.MsgCollectionAlreadyExist(req.CollectionName),
|
||||
}, nil
|
||||
}
|
||||
|
||||
var schema schemapb.CollectionSchema
|
||||
err := proto.Unmarshal(req.Schema, &schema)
|
||||
if err != nil {
|
||||
|
@ -372,10 +363,7 @@ func (coord *RootCoordMock) DropCollection(ctx context.Context, req *milvuspb.Dr
|
|||
|
||||
collID, exist := coord.collName2ID[req.CollectionName]
|
||||
if !exist {
|
||||
return &commonpb.Status{
|
||||
ErrorCode: commonpb.ErrorCode_CollectionNotExists,
|
||||
Reason: milvuserrors.MsgCollectionNotExist(req.CollectionName),
|
||||
}, nil
|
||||
return merr.Status(merr.WrapErrCollectionNotFound(req.CollectionName)), nil
|
||||
}
|
||||
|
||||
delete(coord.collName2ID, req.CollectionName)
|
||||
|
@ -449,10 +437,7 @@ func (coord *RootCoordMock) DescribeCollection(ctx context.Context, req *milvusp
|
|||
collID, exist := coord.collName2ID[req.CollectionName]
|
||||
if !exist && !usingID {
|
||||
return &milvuspb.DescribeCollectionResponse{
|
||||
Status: &commonpb.Status{
|
||||
ErrorCode: commonpb.ErrorCode_CollectionNotExists,
|
||||
Reason: milvuserrors.MsgCollectionNotExist(req.CollectionName),
|
||||
},
|
||||
Status: merr.Status(merr.WrapErrCollectionNotFound(req.CollectionName)),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -532,23 +517,12 @@ func (coord *RootCoordMock) CreatePartition(ctx context.Context, req *milvuspb.C
|
|||
|
||||
collID, exist := coord.collName2ID[req.CollectionName]
|
||||
if !exist {
|
||||
return &commonpb.Status{
|
||||
ErrorCode: commonpb.ErrorCode_CollectionNotExists,
|
||||
Reason: milvuserrors.MsgCollectionNotExist(req.CollectionName),
|
||||
}, nil
|
||||
return merr.Status(merr.WrapErrCollectionNotFound(req.CollectionName)), nil
|
||||
}
|
||||
|
||||
coord.partitionMtx.Lock()
|
||||
defer coord.partitionMtx.Unlock()
|
||||
|
||||
_, partitionExist := coord.collID2Partitions[collID].partitionName2ID[req.PartitionName]
|
||||
if partitionExist {
|
||||
return &commonpb.Status{
|
||||
ErrorCode: commonpb.ErrorCode_UnexpectedError,
|
||||
Reason: milvuserrors.MsgPartitionAlreadyExist(req.PartitionName),
|
||||
}, nil
|
||||
}
|
||||
|
||||
ts := uint64(time.Now().Nanosecond())
|
||||
|
||||
partitionID := typeutil.UniqueID(uniquegenerator.GetUniqueIntGeneratorIns().GetInt())
|
||||
|
@ -575,10 +549,7 @@ func (coord *RootCoordMock) DropPartition(ctx context.Context, req *milvuspb.Dro
|
|||
|
||||
collID, exist := coord.collName2ID[req.CollectionName]
|
||||
if !exist {
|
||||
return &commonpb.Status{
|
||||
ErrorCode: commonpb.ErrorCode_CollectionNotExists,
|
||||
Reason: milvuserrors.MsgCollectionNotExist(req.CollectionName),
|
||||
}, nil
|
||||
return merr.Status(merr.WrapErrCollectionNotFound(req.CollectionName)), nil
|
||||
}
|
||||
|
||||
coord.partitionMtx.Lock()
|
||||
|
@ -586,10 +557,7 @@ func (coord *RootCoordMock) DropPartition(ctx context.Context, req *milvuspb.Dro
|
|||
|
||||
partitionID, partitionExist := coord.collID2Partitions[collID].partitionName2ID[req.PartitionName]
|
||||
if !partitionExist {
|
||||
return &commonpb.Status{
|
||||
ErrorCode: commonpb.ErrorCode_UnexpectedError,
|
||||
Reason: milvuserrors.MsgPartitionNotExist(req.PartitionName),
|
||||
}, nil
|
||||
return merr.Status(merr.WrapErrPartitionNotFound(req.PartitionName)), nil
|
||||
}
|
||||
|
||||
delete(coord.collID2Partitions[collID].partitionName2ID, req.PartitionName)
|
||||
|
@ -615,11 +583,8 @@ func (coord *RootCoordMock) HasPartition(ctx context.Context, req *milvuspb.HasP
|
|||
collID, exist := coord.collName2ID[req.CollectionName]
|
||||
if !exist {
|
||||
return &milvuspb.BoolResponse{
|
||||
Status: &commonpb.Status{
|
||||
ErrorCode: commonpb.ErrorCode_CollectionNotExists,
|
||||
Reason: milvuserrors.MsgCollectionNotExist(req.CollectionName),
|
||||
},
|
||||
Value: false,
|
||||
Status: merr.Status(merr.WrapErrCollectionNotFound(req.CollectionName)),
|
||||
Value: false,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -656,10 +621,7 @@ func (coord *RootCoordMock) ShowPartitions(ctx context.Context, req *milvuspb.Sh
|
|||
collID, exist := coord.collName2ID[req.CollectionName]
|
||||
if !exist {
|
||||
return &milvuspb.ShowPartitionsResponse{
|
||||
Status: &commonpb.Status{
|
||||
ErrorCode: commonpb.ErrorCode_CollectionNotExists,
|
||||
Reason: milvuserrors.MsgCollectionNotExist(req.CollectionName),
|
||||
},
|
||||
Status: merr.Status(merr.WrapErrCollectionNotFound(req.CollectionName)),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -645,7 +645,7 @@ func TestCreateCollectionTask(t *testing.T) {
|
|||
// recreate -> fail
|
||||
err = task.Execute(ctx)
|
||||
assert.NoError(t, err)
|
||||
assert.NotEqual(t, commonpb.ErrorCode_Success, task.result.ErrorCode)
|
||||
assert.Equal(t, commonpb.ErrorCode_Success, task.result.ErrorCode)
|
||||
|
||||
err = task.PostExecute(ctx)
|
||||
assert.NoError(t, err)
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
||||
//
|
||||
// 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.
|
||||
|
||||
package milvuserrors
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cockroachdb/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
// MsgRootCoordNotServing means that root coordinator not serving
|
||||
MsgRootCoordNotServing = "root coordinator is not serving"
|
||||
// MsgQueryCoordNotServing means that QueryCoord not serving
|
||||
MsgQueryCoordNotServing = "query coordinator is not serving"
|
||||
// MsgDataCoordNotServing means that DataCoord not serving
|
||||
MsgDataCoordNotServing = "data coordinator is not serving"
|
||||
// MsgIndexCoordNotServing means that IndexCoord not serving
|
||||
MsgIndexCoordNotServing = "index coordinator is not serving"
|
||||
// MsgProxyNotServing means that ProxyNode not serving
|
||||
MsgProxyNotServing = "proxy node is not serving"
|
||||
)
|
||||
|
||||
// MsgCollectionAlreadyExist is used to construct an error message of collection already exist
|
||||
func MsgCollectionAlreadyExist(name string) string {
|
||||
return fmt.Sprintf("Collection %s already exist", name)
|
||||
}
|
||||
|
||||
// ErrCollectionAlreadyExist is used to construct an error of collection already exist
|
||||
func ErrCollectionAlreadyExist(name string) error {
|
||||
return errors.New(MsgCollectionAlreadyExist(name))
|
||||
}
|
||||
|
||||
// MsgCollectionNotExist is used to construct an error message of collection not exist
|
||||
func MsgCollectionNotExist(name string) string {
|
||||
return fmt.Sprintf("Collection %s not exist", name)
|
||||
}
|
||||
|
||||
// ErrCollectionNotExist is used to construct an error of collection not exist
|
||||
func ErrCollectionNotExist(name string) error {
|
||||
return errors.New(MsgCollectionNotExist(name))
|
||||
}
|
||||
|
||||
// MsgPartitionAlreadyExist is used to construct an error message of partition already exist
|
||||
func MsgPartitionAlreadyExist(name string) string {
|
||||
return fmt.Sprintf("Partition %s already exist", name)
|
||||
}
|
||||
|
||||
// ErrPartitionAlreadyExist is used to construct an error of partition already exist
|
||||
func ErrPartitionAlreadyExist(name string) error {
|
||||
return errors.New(MsgPartitionAlreadyExist(name))
|
||||
}
|
||||
|
||||
// MsgPartitionNotExist is used to construct an error message of partition not exist
|
||||
func MsgPartitionNotExist(name string) string {
|
||||
return fmt.Sprintf("Partition %s not exist", name)
|
||||
}
|
||||
|
||||
// ErrPartitionNotExist is used to construct an error of partition not exist
|
||||
func ErrPartitionNotExist(name string) error {
|
||||
return errors.New(MsgPartitionNotExist(name))
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
||||
//
|
||||
// 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.
|
||||
|
||||
package milvuserrors
|
Loading…
Reference in New Issue