Skip to content

Commit 3ebdc32

Browse files
jeanp413roboquat
authored andcommitted
Do not log error when it has Unavailable code
1 parent eaf8197 commit 3ebdc32

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

components/supervisor/pkg/serverapi/publicapi.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ import (
2424
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
2525
"github.com/prometheus/client_golang/prometheus"
2626
"google.golang.org/grpc"
27+
"google.golang.org/grpc/codes"
2728
"google.golang.org/grpc/credentials"
2829
"google.golang.org/grpc/metadata"
30+
"google.golang.org/grpc/status"
2931
)
3032

3133
type APIInterface interface {
@@ -280,7 +282,9 @@ func (s *Service) onInstanceUpdates(ctx context.Context) {
280282
if errors.Is(err, context.Canceled) || errors.Is(err, io.EOF) {
281283
continue
282284
}
283-
log.WithField("method", "InstanceUpdates").WithError(err).Error("failed to listen")
285+
if status.Code(err) != codes.Unavailable {
286+
log.WithField("method", "InstanceUpdates").WithError(err).Error("failed to listen")
287+
}
284288
cancel()
285289
time.Sleep(time.Second * 2)
286290
cancel = processUpdate(s.usePublicAPI(ctx))
@@ -335,7 +339,7 @@ func (s *Service) publicAPIInstanceUpdate(ctx context.Context, errChan chan erro
335339
for {
336340
resp, err := resp.Recv()
337341
if err != nil {
338-
if err != io.EOF {
342+
if err != io.EOF && status.Code(err) != codes.Unavailable {
339343
log.WithField("method", "StreamWorkspaceStatus").WithError(err).Error("failed to receive status update")
340344
}
341345
if ctx.Err() != nil {

0 commit comments

Comments
 (0)