feat: handle application not found (#1913)
Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
parent
473c5d33f7
commit
c20c457abd
|
|
@ -996,6 +996,10 @@ func (s *Server) ListApplications(ctx context.Context, req *managerv1.ListApplic
|
|||
log.Debugf("%s cache miss", cacheKey)
|
||||
var applications []model.Application
|
||||
if err := s.db.WithContext(ctx).Find(&applications).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, status.Error(codes.NotFound, err.Error())
|
||||
}
|
||||
|
||||
return nil, status.Error(codes.Unknown, err.Error())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -371,12 +371,22 @@ func (mc *managerClient) Get() (any, error) {
|
|||
Ip: mc.config.Server.AdvertiseIP,
|
||||
})
|
||||
if err != nil {
|
||||
// TODO Compatible with old version manager.
|
||||
if s, ok := status.FromError(err); ok && s.Code() == codes.Unimplemented {
|
||||
return DynconfigData{
|
||||
Scheduler: getSchedulerResp,
|
||||
Applications: nil,
|
||||
}, nil
|
||||
if s, ok := status.FromError(err); ok {
|
||||
// TODO Compatible with old version manager.
|
||||
if s.Code() == codes.Unimplemented {
|
||||
return DynconfigData{
|
||||
Scheduler: getSchedulerResp,
|
||||
Applications: nil,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Handle application not found.
|
||||
if s.Code() == codes.NotFound {
|
||||
return DynconfigData{
|
||||
Scheduler: getSchedulerResp,
|
||||
Applications: nil,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, err
|
||||
|
|
|
|||
Loading…
Reference in New Issue