Skip to content

Commit

Permalink
orca: cleanup old code, and get grpc package to use new code (#5627)
Browse files Browse the repository at this point in the history
  • Loading branch information
easwars authored Sep 27, 2022
1 parent e8866a8 commit 36e4810
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 183 deletions.
2 changes: 1 addition & 1 deletion balancer/balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ type DoneInfo struct {
// ServerLoad is the load received from server. It's usually sent as part of
// trailing metadata.
//
// The only supported type now is *orca_v1.LoadReport.
// The only supported type now is *orca_v3.LoadReport.
ServerLoad interface{}
}

Expand Down
22 changes: 22 additions & 0 deletions orca/orca.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/internal"
"google.golang.org/grpc/internal/balancerload"
"google.golang.org/grpc/metadata"
"google.golang.org/protobuf/proto"

Expand Down Expand Up @@ -162,3 +163,24 @@ func ToLoadReport(md metadata.MD) (*v3orcapb.OrcaLoadReport, error) {
}
return ret, nil
}

// loadParser implements the Parser interface defined in `internal/balancerload`
// package. This interface is used by the client stream to parse load reports
// sent by the server in trailer metadata. The parsed loads are then sent to
// balancers via balancer.DoneInfo.
//
// The grpc package cannot directly call orca.ToLoadReport() as that would cause
// an import cycle. Hence this roundabout method is used.
type loadParser struct{}

func (loadParser) Parse(md metadata.MD) interface{} {
lr, err := ToLoadReport(md)
if err != nil {
logger.Errorf("Parse(%v) failed: %v", err)
}
return lr
}

func init() {
balancerload.SetParser(loadParser{})
}
5 changes: 3 additions & 2 deletions xds/internal/balancer/clusterimpl/picker.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
package clusterimpl

import (
orcapb "github.com/cncf/xds/go/xds/data/orca/v3"
"google.golang.org/grpc/balancer"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/internal/wrr"
"google.golang.org/grpc/status"
"google.golang.org/grpc/xds/internal/xdsclient"
"google.golang.org/grpc/xds/internal/xdsclient/load"

v3orcapb "github.com/cncf/xds/go/xds/data/orca/v3"
)

// NewRandomWRR is used when calculating drops. It's exported so that tests can
Expand Down Expand Up @@ -158,7 +159,7 @@ func (d *picker) Pick(info balancer.PickInfo) (balancer.PickResult, error) {
}
d.loadStore.CallFinished(lIDStr, info.Err)

load, ok := info.ServerLoad.(*orcapb.OrcaLoadReport)
load, ok := info.ServerLoad.(*v3orcapb.OrcaLoadReport)
if !ok {
return
}
Expand Down
84 changes: 0 additions & 84 deletions xds/internal/balancer/orca/orca.go

This file was deleted.

96 changes: 0 additions & 96 deletions xds/internal/balancer/orca/orca_test.go

This file was deleted.

0 comments on commit 36e4810

Please sign in to comment.