mirror of
https://github.com/1Password/onepassword-operator.git
synced 2025-10-22 07:28:06 +00:00
Requeue after 1 munute if faced reate limit error from 1password
This commit is contained in:
@@ -28,8 +28,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
"time"
|
||||||
|
|
||||||
kubeSecrets "github.com/1Password/onepassword-operator/pkg/kubernetessecrets"
|
kubeSecrets "github.com/1Password/onepassword-operator/pkg/kubernetessecrets"
|
||||||
"github.com/1Password/onepassword-operator/pkg/logs"
|
"github.com/1Password/onepassword-operator/pkg/logs"
|
||||||
@@ -46,6 +46,7 @@ import (
|
|||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
|
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
|
||||||
logf "sigs.k8s.io/controller-runtime/pkg/log"
|
logf "sigs.k8s.io/controller-runtime/pkg/log"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||||
)
|
)
|
||||||
|
|
||||||
var logDeployment = logf.Log.WithName("controller_deployment")
|
var logDeployment = logf.Log.WithName("controller_deployment")
|
||||||
@@ -102,7 +103,12 @@ func (r *DeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Request)
|
|||||||
}
|
}
|
||||||
// Handles creation or updating secrets for deployment if needed
|
// Handles creation or updating secrets for deployment if needed
|
||||||
if err = r.handleApplyingDeployment(deployment, deployment.Namespace, annotations, req); err != nil {
|
if err = r.handleApplyingDeployment(deployment, deployment.Namespace, annotations, req); err != nil {
|
||||||
return ctrl.Result{}, err
|
if strings.Contains(err.Error(), "rate limit") {
|
||||||
|
reqLogger.V(logs.InfoLevel).Info("1Password rate limit hit. Requeuing after 1 minute.")
|
||||||
|
return ctrl.Result{RequeueAfter: time.Minute}, nil
|
||||||
|
} else {
|
||||||
|
return ctrl.Result{}, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ctrl.Result{}, nil
|
return ctrl.Result{}, nil
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,8 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
onepasswordv1 "github.com/1Password/onepassword-operator/api/v1"
|
onepasswordv1 "github.com/1Password/onepassword-operator/api/v1"
|
||||||
kubeSecrets "github.com/1Password/onepassword-operator/pkg/kubernetessecrets"
|
kubeSecrets "github.com/1Password/onepassword-operator/pkg/kubernetessecrets"
|
||||||
@@ -103,6 +105,12 @@ func (r *OnePasswordItemReconciler) Reconcile(ctx context.Context, req ctrl.Requ
|
|||||||
|
|
||||||
// Handles creation or updating secrets for deployment if needed
|
// Handles creation or updating secrets for deployment if needed
|
||||||
err = r.handleOnePasswordItem(onepassworditem, req)
|
err = r.handleOnePasswordItem(onepassworditem, req)
|
||||||
|
if err != nil {
|
||||||
|
if strings.Contains(err.Error(), "rate limit") {
|
||||||
|
reqLogger.V(logs.InfoLevel).Info("1Password rate limit hit. Requeuing after 1 minute.")
|
||||||
|
return ctrl.Result{RequeueAfter: time.Minute}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
if updateStatusErr := r.updateStatus(onepassworditem, err); updateStatusErr != nil {
|
if updateStatusErr := r.updateStatus(onepassworditem, err); updateStatusErr != nil {
|
||||||
return ctrl.Result{}, fmt.Errorf("cannot update status: %s", updateStatusErr)
|
return ctrl.Result{}, fmt.Errorf("cannot update status: %s", updateStatusErr)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user