bump reva

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
Jörn Friedrich Dreyer
2024-07-30 16:14:19 +02:00
parent 4d2774c075
commit f7523ca16b
18 changed files with 1042 additions and 22 deletions
@@ -325,12 +325,12 @@ func getGRPCConfig(opaque *typespb.Opaque) (bool, bool) {
func getConn(host string, ins, skipverify bool) (*grpc.ClientConn, error) {
if ins {
return grpc.Dial(host, grpc.WithTransportCredentials(insecure.NewCredentials()))
return grpc.NewClient(host, grpc.WithTransportCredentials(insecure.NewCredentials()))
}
// TODO(labkode): if in the future we want client-side certificate validation,
// we need to load the client cert here
tlsconf := &tls.Config{InsecureSkipVerify: skipverify}
creds := credentials.NewTLS(tlsconf)
return grpc.Dial(host, grpc.WithTransportCredentials(creds))
return grpc.NewClient(host, grpc.WithTransportCredentials(creds))
}
@@ -292,6 +292,12 @@ func (s *svc) executePathCopy(ctx context.Context, selector pool.Selectable[gate
return err
}
defer httpDownloadRes.Body.Close()
if httpDownloadRes.StatusCode == http.StatusForbidden {
w.WriteHeader(http.StatusForbidden)
b, err := errors.Marshal(http.StatusForbidden, http.StatusText(http.StatusForbidden), "", strconv.Itoa(http.StatusForbidden))
errors.HandleWebdavError(log, w, b, err)
return nil
}
if httpDownloadRes.StatusCode != http.StatusOK {
return fmt.Errorf("status code %d", httpDownloadRes.StatusCode)
}
+1 -1
View File
@@ -133,7 +133,7 @@ func newgrpc(ctx context.Context, opt *Options) (erpc.EosClient, error) {
log := appctx.GetLogger(ctx)
log.Info().Str("Setting up GRPC towards ", "'"+opt.GrpcURI+"'").Msg("")
conn, err := grpc.Dial(opt.GrpcURI, grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.NewClient(opt.GrpcURI, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Warn().Str("Error connecting to ", "'"+opt.GrpcURI+"' ").Str("err", err.Error()).Msg("")
}
+25 -3
View File
@@ -38,7 +38,7 @@ var (
// NewConn creates a new connection to a grpc server
// with open census tracing support.
// TODO(labkode): make grpc tls configurable.
func NewConn(address string, opts ...Option) (*grpc.ClientConn, error) {
func NewConn(target string, opts ...Option) (*grpc.ClientConn, error) {
options := ClientOptions{}
if err := options.init(); err != nil {
@@ -84,12 +84,34 @@ func NewConn(address string, opts ...Option) (*grpc.ClientConn, error) {
maxRcvMsgSize = s
}
conn, err := grpc.Dial(
address,
conn, err := grpc.NewClient(
target,
grpc.WithTransportCredentials(cred),
grpc.WithDefaultCallOptions(
grpc.MaxCallRecvMsgSize(maxRcvMsgSize),
),
grpc.WithDefaultServiceConfig(`{
"loadBalancingPolicy":"round_robin"
}`),
/* we may want to retry more often than the default transparent retry, see https://grpc.io/docs/guides/retry/#retry-configuration
grpc.WithDefaultServiceConfig(`{
"loadBalancingPolicy":"round_robin"
"methodConfig": [
{
"name": [
{ "service": "grpc.examples.echo.Echo" }
],
"retryPolicy": {
"maxAttempts": 3,
"initialBackoff": "0.1s",
"maxBackoff": "1s",
"backoffMultiplier": 2,
"retryableStatusCodes": ["UNAVAILABLE", "CANCELLED", "RESOURCE_EXHAUSTED", "DEADLINE_EXCEEDED"]
}
}
]
}`),
*/
grpc.WithStatsHandler(otelgrpc.NewClientHandler(
otelgrpc.WithTracerProvider(
options.tracerProvider,
+28 -8
View File
@@ -20,6 +20,7 @@ package pool
import (
"fmt"
"strings"
"sync"
appProvider "github.com/cs3org/go-cs3apis/cs3/app/provider/v1beta1"
@@ -43,9 +44,16 @@ import (
tx "github.com/cs3org/go-cs3apis/cs3/tx/v1beta1"
"github.com/cs3org/reva/v2/pkg/registry"
"github.com/pkg/errors"
"github.com/sercand/kuberesolver/v5"
"google.golang.org/grpc"
)
func init() {
// grpc go resolver.Register must only be called during initialization time (i.e. in
// an init() function), and is not thread-safe.
kuberesolver.RegisterInCluster()
}
type Selectable[T any] interface {
Next(opts ...Option) (T, error)
}
@@ -93,8 +101,19 @@ func (s *Selector[T]) Next(opts ...Option) (T, error) {
opt(&options)
}
address := s.id
if options.registry != nil {
target := s.id
// if the target is given as a recognized gRPC URI, skip registry lookup
// see https://github.com/grpc/grpc/blob/master/doc/naming.md#name-syntax
prefix := strings.SplitN(s.id, ":", 2)[0]
switch {
case prefix == "dns":
fallthrough
case prefix == "unix":
fallthrough
case prefix == "kubernetes":
// use target as is and skip registry lookup
case options.registry != nil:
// use service registry to look up address
services, err := options.registry.GetService(s.id)
if err != nil {
return *new(T), fmt.Errorf("%s: %w", s.id, err)
@@ -104,22 +123,23 @@ func (s *Selector[T]) Next(opts ...Option) (T, error) {
if err != nil {
return *new(T), fmt.Errorf("%s: %w", s.id, err)
}
address = nodeAddress
target = nodeAddress
default:
// if no registry is available, use the target as is
}
existingClient, ok := s.clientMap.Load(address)
existingClient, ok := s.clientMap.Load(target)
if ok {
return existingClient.(T), nil
}
conn, err := NewConn(address, allOpts...)
conn, err := NewConn(target, allOpts...)
if err != nil {
return *new(T), errors.Wrap(err, fmt.Sprintf("could not create connection for %s to %s", s.id, address))
return *new(T), errors.Wrap(err, fmt.Sprintf("could not create connection for %s to %s", s.id, target))
}
newClient := s.clientFactory(conn)
s.clientMap.Store(address, newClient)
s.clientMap.Store(target, newClient)
return newClient, nil
}
+1 -4
View File
@@ -22,7 +22,6 @@ import (
"context"
"fmt"
"sync"
"time"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
@@ -106,13 +105,11 @@ func DefaultProvider() trace.TracerProvider {
// getOtelTracerProvider returns a new TracerProvider, configure for the specified service
func getOtlpTracerProvider(options Options) trace.TracerProvider {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
transportCredentials := options.TransportCredentials
if options.Insecure {
transportCredentials = insecure.NewCredentials()
}
conn, err := grpc.DialContext(ctx, options.Endpoint,
conn, err := grpc.NewClient(options.Endpoint,
grpc.WithTransportCredentials(transportCredentials),
)
if err != nil {