Skip to content

Commit

Permalink
cleanup istio extension objects when it cannot calculate effective po…
Browse files Browse the repository at this point in the history
…licies

Signed-off-by: Guilherme Cassolato <[email protected]>
  • Loading branch information
guicassolato committed Oct 8, 2024
1 parent 894f93d commit 625850f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions controllers/istio_extension_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ func (r *istioExtensionReconciler) Reconcile(ctx context.Context, _ []controller
if err != nil {
if errors.Is(err, ErrMissingStateEffectiveRateLimitPolicies) {
logger.V(1).Info(err.Error())
return nil
} else {
return err

Check warning on line 61 in controllers/istio_extension_reconciler.go

View check run for this annotation

Codecov / codecov/patch

controllers/istio_extension_reconciler.go#L61

Added line #L61 was not covered by tests
}
return err
}

// reconcile for each gateway based on the desired wasm plugin policies calculated before
Expand Down Expand Up @@ -130,15 +130,15 @@ func (r *istioExtensionReconciler) Reconcile(ctx context.Context, _ []controller
func (r *istioExtensionReconciler) buildWasmPoliciesPerGateway(ctx context.Context, state *sync.Map) (map[string][]wasm.Policy, error) {
logger := controller.LoggerFromContext(ctx).WithName("istioExtensionReconciler").WithName("buildWasmPolicies")

wasmPolicies := make(map[string][]wasm.Policy)

effectivePolicies, ok := state.Load(StateEffectiveRateLimitPolicies)
if !ok {
return nil, ErrMissingStateEffectiveRateLimitPolicies
return wasmPolicies, ErrMissingStateEffectiveRateLimitPolicies
}

logger.V(1).Info("building wasm policies for istio extension", "effectivePolicies", len(effectivePolicies.(EffectiveRateLimitPolicies)))

wasmPolicies := make(map[string][]wasm.Policy)

// build wasm config for effective rate limit policies
for pathID, effectivePolicy := range effectivePolicies.(EffectiveRateLimitPolicies) {
// assumes the path is always [gatewayclass, gateway, listener, httproute, httprouterule]
Expand Down

0 comments on commit 625850f

Please sign in to comment.