55 "fmt"
66 "time"
77
8+ "github.com/kubeflow/katib/pkg/controller.v1alpha3/consts"
9+
10+ grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry"
811 "google.golang.org/grpc"
912 "google.golang.org/grpc/codes"
1013 "google.golang.org/grpc/status"
@@ -105,7 +108,15 @@ func (g *General) SyncAssignments(
105108func (g * General ) ValidateAlgorithmSettings (instance * suggestionsv1alpha3.Suggestion , e * experimentsv1alpha3.Experiment ) error {
106109 logger := log .WithValues ("Suggestion" , types.NamespacedName {Name : instance .GetName (), Namespace : instance .GetNamespace ()})
107110 endpoint := util .GetAlgorithmEndpoint (instance )
108- conn , err := grpc .Dial (endpoint , grpc .WithInsecure ())
111+
112+ callOpts := []grpc_retry.CallOption {
113+ grpc_retry .WithBackoff (grpc_retry .BackoffLinear (consts .DefaultGRPCRetryPeriod )),
114+ grpc_retry .WithMax (consts .DefaultGRPCRetryAttempts ),
115+ }
116+ conn , err := grpc .Dial (endpoint , grpc .WithInsecure (),
117+ grpc .WithStreamInterceptor (grpc_retry .StreamClientInterceptor (callOpts ... )),
118+ grpc .WithUnaryInterceptor (grpc_retry .UnaryClientInterceptor (callOpts ... )),
119+ )
109120 if err != nil {
110121 return err
111122 }
@@ -118,6 +129,7 @@ func (g *General) ValidateAlgorithmSettings(instance *suggestionsv1alpha3.Sugges
118129 request := & suggestionapi.ValidateAlgorithmSettingsRequest {
119130 Experiment : g .ConvertExperiment (e ),
120131 }
132+
121133 // See https://github.com/grpc/grpc-go/issues/2636
122134 // See https://github.com/grpc/grpc-go/pull/2503
123135 _ , err = client .ValidateAlgorithmSettings (ctx , request , grpc .WaitForReady (true ))
0 commit comments