Skip to content

Commit

Permalink
vmuser: remove rate limit on delete
Browse files Browse the repository at this point in the history
  • Loading branch information
Haleygo committed Jun 19, 2023
1 parent 27cd5e5 commit 6ab747e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion controllers/factory/vmauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func CreateOrUpdateVMAuth(ctx context.Context, cr *victoriametricsv1beta1.VMAuth
}
newDeploy, err := newDeployForVMAuth(cr, c)
if err != nil {
return fmt.Errorf("cannot build new deploy for vmagent: %w", err)
return fmt.Errorf("cannot build new deploy for vmauth: %w", err)
}

return k8stools.HandleDeployUpdate(ctx, rclient, newDeploy)
Expand Down
24 changes: 12 additions & 12 deletions controllers/vmuser_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,12 @@ func (r *VMUserReconciler) Scheme() *runtime.Scheme {
return r.OriginScheme
}

var (
vmauthRateLimiter = limiter.NewRateLimiter("vmauth", 5)
)
var vmauthRateLimiter = limiter.NewRateLimiter("vmauth", 5)

// Reconcile implements interface
// +kubebuilder:rbac:groups=operator.victoriametrics.com,resources=vmusers,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=operator.victoriametrics.com,resources=vmusers/status,verbs=get;update;patch
func (r *VMUserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, err error) {

l := r.Log.WithValues("vmuser", req.NamespacedName)

var instance operatorv1beta1.VMUser
Expand All @@ -63,9 +60,18 @@ func (r *VMUserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
return handleGetError(req, "vmuser", err)
}
RegisterObjectStat(&instance, "vmuser")
if err := finalize.AddFinalizer(ctx, r.Client, &instance); err != nil {
return result, err

if !instance.DeletionTimestamp.IsZero() {
// need to remove finalizer and delete related resources.
if err := finalize.OnVMUserDelete(ctx, r, &instance); err != nil {
return result, fmt.Errorf("cannot remove finalizer for vmuser: %w", err)
}
} else {
if err := finalize.AddFinalizer(ctx, r.Client, &instance); err != nil {
return result, err
}
}

if vmauthRateLimiter.MustThrottleReconcile() {
return
}
Expand Down Expand Up @@ -97,12 +103,6 @@ func (r *VMUserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
return ctrl.Result{}, fmt.Errorf("cannot create or update vmauth deploy for vmuser: %w", err)
}
}
if !instance.DeletionTimestamp.IsZero() {
// need to remove finalizer and delete related resources.
if err := finalize.OnVMUserDelete(ctx, r, &instance); err != nil {
return result, fmt.Errorf("cannot remove finalizer for vmuser: %w", err)
}
}
return
}

Expand Down
8 changes: 5 additions & 3 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ var (
initNamespace sync.Once
)

const prefixVar = "VM"
const UnLimitedResource = "unlimited"
const (
prefixVar = "VM"
UnLimitedResource = "unlimited"
)

// WatchNamespaceEnvVar is the constant for env variable WATCH_NAMESPACE
// which specifies the Namespace to watch.
Expand Down Expand Up @@ -244,7 +246,7 @@ type BaseOperatorConf struct {
PodWaitReadyTimeout time.Duration `default:"80s"`
PodWaitReadyIntervalCheck time.Duration `default:"5s"`
PodWaitReadyInitDelay time.Duration `default:"10s"`
// configures force resync interval for VMAgent, VMAlert and VMAlertmanager
// configures force resync interval for VMAgent, VMAlert, VMAlertmanager and VMAuth
ForceResyncInterval time.Duration `default:"60s"`
}

Expand Down

0 comments on commit 6ab747e

Please sign in to comment.