logs should return for non existent services (#1906)

This commit is contained in:
Dominic Wong 2020-08-06 22:56:05 +01:00 committed by GitHub
parent 74907987d1
commit 835343d6a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -364,6 +364,7 @@ func (k *kubernetes) Logs(s *runtime.Service, options ...runtime.LogsOption) (ru
for _, record := range records {
kstream.Chan() <- record
}
kstream.Stop()
}()
return kstream, nil
}

View File

@ -9,6 +9,7 @@ import (
"strconv"
"time"
"github.com/micro/go-micro/v3/errors"
"github.com/micro/go-micro/v3/runtime"
"github.com/micro/go-micro/v3/util/kubernetes/client"
"github.com/micro/go-micro/v3/util/log"
@ -105,6 +106,9 @@ func (k *klog) Read() ([]runtime.LogRecord, error) {
if err != nil {
return nil, err
}
if len(pods) == 0 {
return nil, errors.NotFound("runtime.logs", "no such service")
}
var records []runtime.LogRecord