Skip to content

Commit

Permalink
Add workaround for gRPC issues
Browse files Browse the repository at this point in the history
fixes 168

not very happy with this, but it's really unclear why this happens
  • Loading branch information
csweichel committed Sep 8, 2022
1 parent d3782cd commit 8922500
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions pkg/plugin/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import (
"os"
"os/signal"
"reflect"
"strings"
"syscall"

v1 "github.com/csweichel/werft/pkg/api/v1"
"github.com/csweichel/werft/pkg/plugin/common"
log "github.com/sirupsen/logrus"
"golang.org/x/xerrors"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"gopkg.in/yaml.v3"
)

Expand Down Expand Up @@ -191,9 +194,19 @@ func Serve(configType interface{}, opts ...ServeOpt) {
log.Fatalf("cannot serve as %s plugin", tpe)
}
go func() {
err := sv.Run(ctx, config, socketfn)
if err != nil && err != context.Canceled {
errchan <- err
for {
err := sv.Run(ctx, config, socketfn)
if err != nil && status.Code(err) == codes.Internal && strings.Contains(err.Error(), "cannot parse invalid wire-format data") {
// odd bug in werft #168
log.WithError(err).Error("plugin received invalid wire-format data - don't know how this happens. Will restart the plugin.")
continue
} else if err != nil && err != context.Canceled {
errchan <- err
return
} else {
// no error - shut down
return
}
}
}()

Expand Down

0 comments on commit 8922500

Please sign in to comment.