Skip to content

Commit

Permalink
Upgrade flyteidl, preload lb policy and add default service config fo…
Browse files Browse the repository at this point in the history
…r catalog client (flyteorg#447)
  • Loading branch information
honnix authored Jun 2, 2022
1 parent 133e527 commit b9fb6e3
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 6 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/DiSiqueira/GoTree v1.0.1-0.20180907134536-53a8e837f295
github.com/benlaurie/objecthash v0.0.0-20180202135721-d1e3d6079fc1
github.com/fatih/color v1.10.0
github.com/flyteorg/flyteidl v1.1.0
github.com/flyteorg/flyteidl v1.1.5
github.com/flyteorg/flyteplugins v1.0.0
github.com/flyteorg/flytestdlib v1.0.0
github.com/ghodss/yaml v1.0.0
Expand All @@ -15,6 +15,7 @@ require (
github.com/golang/protobuf v1.4.3
github.com/google/uuid v1.2.0
github.com/grpc-ecosystem/go-grpc-middleware v1.1.0
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/imdario/mergo v0.3.11
github.com/magiconair/properties v1.8.4
github.com/mitchellh/mapstructure v1.4.1
Expand Down Expand Up @@ -86,7 +87,6 @@ require (
github.com/google/gofuzz v1.2.0 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/googleapis/gnostic v0.5.1 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
github.com/flyteorg/flyteidl v1.0.0/go.mod h1:JW0z1ZaHS9zWvDAwSMIyGhsf+V4zrzBBgh5IuqzMFCM=
github.com/flyteorg/flyteidl v1.1.0 h1:f8tdMXOuorS/d+4Ut2QarfDbdCOriK0S+EnlQzrwz9E=
github.com/flyteorg/flyteidl v1.1.0/go.mod h1:JW0z1ZaHS9zWvDAwSMIyGhsf+V4zrzBBgh5IuqzMFCM=
github.com/flyteorg/flyteidl v1.1.5 h1:awptNJfw2yESkdNOm1Pe9KPILAzVImkiViUFP1K7UPk=
github.com/flyteorg/flyteidl v1.1.5/go.mod h1:f1tvw5CDjqmrzNxKpRYr6BdAhHL8f7Wp1Duxl0ZOV4g=
github.com/flyteorg/flyteplugins v1.0.0 h1:77hUJjiIxBmQ9rd3+cXjSGnzOVAFrSzCd59aIaYFB/8=
github.com/flyteorg/flyteplugins v1.0.0/go.mod h1:4Cpn+9RfanIieTTh2XsuL6zPYXtsR5UDe8YaEmXONT4=
github.com/flyteorg/flytestdlib v1.0.0 h1:gb99ignMsVcNTUmWzArtcIDdkRjyzQQVBkWNOQakiFg=
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"github.com/prometheus/client_golang/prometheus"

"google.golang.org/grpc"
_ "google.golang.org/grpc/balancer/roundrobin" //nolint

apiextensionsclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"

Expand Down
8 changes: 7 additions & 1 deletion pkg/controller/nodes/task/catalog/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ type Config struct {
Insecure bool `json:"insecure" pflag:"false, Use insecure grpc connection"`
MaxCacheAge config.Duration `json:"max-cache-age" pflag:", Cache entries past this age will incur cache miss. 0 means cache never expires"`
UseAdminAuth bool `json:"use-admin-auth" pflag:"false, Use the same gRPC credentials option as the flyteadmin client"`

// Set the gRPC service config formatted as a json string https://github.com/grpc/grpc/blob/master/doc/service_config.md
// eg. {"loadBalancingConfig": [{"round_robin":{}}], "methodConfig": [{"name":[{"service": "foo", "method": "bar"}, {"service": "baz"}], "timeout": "1.000000001s"}]}
// find the full schema here https://github.com/grpc/grpc-proto/blob/master/grpc/service_config/service_config.proto#L625
// Note that required packages may need to be preloaded to support certain service config. For example "google.golang.org/grpc/balancer/roundrobin" should be preloaded to have round-robin policy supported.
DefaultServiceConfig string `json:"default-service-config" pflag:"\"\", Set the default service config for the catalog gRPC client"`
}

// Gets loaded config for Discovery
Expand All @@ -48,7 +54,7 @@ func NewCatalogClient(ctx context.Context, authOpt grpc.DialOption) (catalog.Cli

switch catalogConfig.Type {
case DataCatalogType:
return datacatalog.NewDataCatalog(ctx, catalogConfig.Endpoint, catalogConfig.Insecure, catalogConfig.MaxCacheAge.Duration, catalogConfig.UseAdminAuth, authOpt)
return datacatalog.NewDataCatalog(ctx, catalogConfig.Endpoint, catalogConfig.Insecure, catalogConfig.MaxCacheAge.Duration, catalogConfig.UseAdminAuth, catalogConfig.DefaultServiceConfig, authOpt)
case NoOpDiscoveryType, "":
return NOOPCatalog{}, nil
}
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/nodes/task/catalog/config_flags.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions pkg/controller/nodes/task/catalog/config_flags_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion pkg/controller/nodes/task/catalog/datacatalog/datacatalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func (m *CatalogClient) ReleaseReservation(ctx context.Context, key catalog.Key,
}

// Create a new Datacatalog client for task execution caching
func NewDataCatalog(ctx context.Context, endpoint string, insecureConnection bool, maxCacheAge time.Duration, useAdminAuth bool, authOpt grpc.DialOption) (*CatalogClient, error) {
func NewDataCatalog(ctx context.Context, endpoint string, insecureConnection bool, maxCacheAge time.Duration, useAdminAuth bool, defaultServiceConfig string, authOpt grpc.DialOption) (*CatalogClient, error) {
var opts []grpc.DialOption
if useAdminAuth && authOpt != nil {
opts = append(opts, authOpt)
Expand All @@ -379,6 +379,10 @@ func NewDataCatalog(ctx context.Context, endpoint string, insecureConnection boo
opts = append(opts, grpc.WithTransportCredentials(creds))
}

if defaultServiceConfig != "" {
opts = append(opts, grpc.WithDefaultServiceConfig(defaultServiceConfig))
}

retryInterceptor := grpcRetry.UnaryClientInterceptor(grpcOptions...)

finalUnaryInterceptor := grpcMiddleware.ChainUnaryClient(
Expand Down
2 changes: 2 additions & 0 deletions propeller-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,12 @@ event:
admin:
endpoint: localhost:30081
insecure: true
defaultServiceConfig: '{"loadBalancingConfig": [{"round_robin":{}}]}'
catalog-cache:
type: noop
endpoint: datacatalog:8089
insecure: true
default-service-config: '{"loadBalancingConfig": [{"round_robin":{}}]}'
logger:
level: 5
show-source: true
Expand Down

0 comments on commit b9fb6e3

Please sign in to comment.