Skip to content

Commit

Permalink
hack verify
Browse files Browse the repository at this point in the history
  • Loading branch information
evansheng committed Feb 2, 2022
1 parent b9c8f23 commit 51b1a1c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 16 deletions.
16 changes: 16 additions & 0 deletions cluster-autoscaler/expander/grpcplugin/example/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package example

import "flag"
Expand Down
17 changes: 8 additions & 9 deletions cluster-autoscaler/expander/grpcplugin/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"google.golang.org/grpc/credentials"
)

const GRPCTimeout = 5 * time.Second
const gRPCTimeout = 5 * time.Second

type grpcclientstrategy struct {
grpcClient protos.ExpanderClient
Expand All @@ -52,14 +52,13 @@ func createGRPCClient(expanderCert string, expanderUrl string) protos.ExpanderCl
if expanderCert == "" {
log.Fatalf("GRPC Expander Cert not specified, insecure connections not allowed")
return nil
} else {
creds, err := credentials.NewClientTLSFromFile(expanderCert, "")
if err != nil {
log.Fatalf("Failed to create TLS credentials %v", err)
return nil
}
dialOpt = grpc.WithTransportCredentials(creds)
}
creds, err := credentials.NewClientTLSFromFile(expanderCert, "")
if err != nil {
log.Fatalf("Failed to create TLS credentials %v", err)
return nil
}
dialOpt = grpc.WithTransportCredentials(creds)
klog.V(2).Infof("Dialing: %s with dialopt: %v", expanderUrl, dialOpt)
conn, err := grpc.Dial(expanderUrl, dialOpt)
if err != nil {
Expand All @@ -81,7 +80,7 @@ func (g *grpcclientstrategy) BestOptions(expansionOptions []expander.Option, nod

// call gRPC server to get BestOption
klog.V(2).Infof("GPRC call of best options to server with %v options", len(nodeGroupIDOptionMap))
ctx, cancel := context.WithTimeout(context.Background(), GRPCTimeout)
ctx, cancel := context.WithTimeout(context.Background(), gRPCTimeout)
defer cancel()
bestOptionsResponse, err := g.grpcClient.BestOptions(ctx, &protos.BestOptionsRequest{Options: grpcOptionsSlice, NodeMap: grpcNodeMap})
if err != nil {
Expand Down
25 changes: 18 additions & 7 deletions cluster-autoscaler/expander/grpcplugin/protos/expander.pb.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.17.3
// source: cluster-autoscaler/expander/grpcplugin/protos/expander.proto
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package protos

import (
context "context"
reflect "reflect"
sync "sync"

grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
v1 "k8s.io/api/core/v1"
reflect "reflect"
sync "sync"
)

const (
Expand Down

0 comments on commit 51b1a1c

Please sign in to comment.