-
Notifications
You must be signed in to change notification settings - Fork 835
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add timeout to contexts in client calls (#6125)
* add timeout context from infer call for modelgateway * add timeout context to pipeline gateway * set timeout context on process request * add a test for grpc call timeout * add agent k8s api call timeout * add context timeout for shutting down services * add timeout for controller k8s api calls * add timeout for control plane context * add timeout context to reconcile logic * pr comments
- Loading branch information
Showing
26 changed files
with
413 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ func (r *ExperimentReconciler) handleFinalizer(ctx context.Context, logger logr. | |
// Add our finalizer | ||
if !utils.ContainsStr(experiment.ObjectMeta.Finalizers, constants.ExperimentFinalizerName) { | ||
experiment.ObjectMeta.Finalizers = append(experiment.ObjectMeta.Finalizers, constants.ExperimentFinalizerName) | ||
if err := r.Update(context.Background(), experiment); err != nil { | ||
if err := r.Update(ctx, experiment); err != nil { | ||
return true, err | ||
} | ||
} | ||
|
@@ -84,6 +84,8 @@ func (r *ExperimentReconciler) handleFinalizer(ctx context.Context, logger logr. | |
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
func (r *ExperimentReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
logger := log.FromContext(ctx).WithName("Reconcile") | ||
ctx, cancel := context.WithTimeout(ctx, constants.ReconcileTimeout) | ||
defer cancel() | ||
|
||
experiment := &mlopsv1alpha1.Experiment{} | ||
if err := r.Get(ctx, req.NamespacedName, experiment); err != nil { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ func (r *PipelineReconciler) handleFinalizer( | |
// Add our finalizer | ||
if !utils.ContainsStr(pipeline.ObjectMeta.Finalizers, constants.PipelineFinalizerName) { | ||
pipeline.ObjectMeta.Finalizers = append(pipeline.ObjectMeta.Finalizers, constants.PipelineFinalizerName) | ||
if err := r.Update(context.Background(), pipeline); err != nil { | ||
if err := r.Update(ctx, pipeline); err != nil { | ||
return true, err | ||
} | ||
} | ||
|
@@ -94,6 +94,8 @@ func (r *PipelineReconciler) handleFinalizer( | |
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
func (r *PipelineReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
logger := log.FromContext(ctx).WithName("Reconcile") | ||
ctx, cancel := context.WithTimeout(ctx, constants.ReconcileTimeout) | ||
defer cancel() | ||
|
||
pipeline := &mlopsv1alpha1.Pipeline{} | ||
if err := r.Get(ctx, req.NamespacedName, pipeline); err != nil { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,7 @@ func (r *SeldonRuntimeReconciler) handleFinalizer(ctx context.Context, logger lo | |
// Add our finalizer | ||
if !utils.ContainsStr(runtime.ObjectMeta.Finalizers, constants.RuntimeFinalizerName) { | ||
runtime.ObjectMeta.Finalizers = append(runtime.ObjectMeta.Finalizers, constants.RuntimeFinalizerName) | ||
if err := r.Update(context.Background(), runtime); err != nil { | ||
if err := r.Update(ctx, runtime); err != nil { | ||
return true, err | ||
} | ||
} | ||
|
@@ -120,6 +120,8 @@ func (r *SeldonRuntimeReconciler) handleFinalizer(ctx context.Context, logger lo | |
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
func (r *SeldonRuntimeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
logger := log.FromContext(ctx).WithName("Reconcile") | ||
ctx, cancel := context.WithTimeout(ctx, constants.ReconcileTimeout) | ||
defer cancel() | ||
|
||
seldonRuntime := &mlopsv1alpha1.SeldonRuntime{} | ||
if err := r.Get(ctx, req.NamespacedName, seldonRuntime); err != nil { | ||
|
@@ -214,9 +216,11 @@ func (r *SeldonRuntimeReconciler) updateStatus(seldonRuntime *mlopsv1alpha1.Seld | |
// Find SeldonRuntimes that reference the changes SeldonConfig | ||
// TODO: pass an actual context from the caller to be used here | ||
func (r *SeldonRuntimeReconciler) mapSeldonRuntimesFromSeldonConfig(_ context.Context, obj client.Object) []reconcile.Request { | ||
logger := log.FromContext(context.Background()).WithName("mapSeldonRuntimesFromSeldonConfig") | ||
ctx, cancel := context.WithTimeout(context.Background(), constants.K8sAPICallsTxTimeout) | ||
defer cancel() | ||
logger := log.FromContext(ctx).WithName("mapSeldonRuntimesFromSeldonConfig") | ||
var seldonRuntimes mlopsv1alpha1.SeldonRuntimeList | ||
if err := r.Client.List(context.Background(), &seldonRuntimes); err != nil { | ||
if err := r.Client.List(ctx, &seldonRuntimes); err != nil { | ||
logger.Error(err, "error listing seldonRuntimes") | ||
return nil | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ import ( | |
mlopsv1alpha1 "github.com/seldonio/seldon-core/operator/v2/apis/mlops/v1alpha1" | ||
"github.com/seldonio/seldon-core/operator/v2/controllers/reconcilers/common" | ||
serverreconcile "github.com/seldonio/seldon-core/operator/v2/controllers/reconcilers/server" | ||
"github.com/seldonio/seldon-core/operator/v2/pkg/constants" | ||
scheduler "github.com/seldonio/seldon-core/operator/v2/scheduler" | ||
) | ||
|
||
|
@@ -65,6 +66,8 @@ type ServerReconciler struct { | |
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
func (r *ServerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
logger := log.FromContext(ctx).WithName("Reconcile") | ||
ctx, cancel := context.WithTimeout(ctx, constants.ReconcileTimeout) | ||
defer cancel() | ||
|
||
logger.Info("Received reconcile for Server", "name", req.Name, "namespace", req.NamespacedName.Namespace) | ||
|
||
|
@@ -186,9 +189,11 @@ func (r *ServerReconciler) updateStatus(server *mlopsv1alpha1.Server) error { | |
// Find Servers that need reconcilliation from a change to a given ServerConfig | ||
// TODO: pass an actual context from the caller to be used here | ||
func (r *ServerReconciler) mapServerFromServerConfig(_ context.Context, obj client.Object) []reconcile.Request { | ||
logger := log.FromContext(context.Background()).WithName("mapServerFromServerConfig") | ||
ctx, cancel := context.WithTimeout(context.Background(), constants.K8sAPICallsTxTimeout) | ||
defer cancel() | ||
logger := log.FromContext(ctx).WithName("mapServerFromServerConfig") | ||
var servers mlopsv1alpha1.ServerList | ||
if err := r.Client.List(context.Background(), &servers); err != nil { | ||
if err := r.Client.List(ctx, &servers); err != nil { | ||
logger.Error(err, "error listing servers") | ||
return nil | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.