Skip to content

Fix logic for deleting Services from ProviderResources #536

@chauhanshubham

Description

@chauhanshubham

Description
The current logic attempts to Delete Services from the ProviderResources map when no Routes are found on the cluster, for a given namespace.

r.resources.Services.Delete(request.NamespacedName)

Snippet

// Delete the Namespace and Service from the resource maps if no other
// routes exist in the namespace.
routeList = &gwapiv1b1.HTTPRouteList{}
if err := r.client.List(ctx, routeList, &client.ListOptions{Namespace: request.Namespace}); err != nil {
	return reconcile.Result{}, fmt.Errorf("error listing httproutes")
}
if len(routeList.Items) == 0 {
	r.resources.Namespaces.Delete(request.Namespace)
	log.Info("deleted namespace from resource map")
	r.resources.Services.Delete(request.NamespacedName)
	log.Info("deleted service from resource map")
}

This tries deleting a Service with namespace/name that matches the HTTPRoute which came in to be Reconciled. This will not be the case most of the times.
We must delete the Services which were referred to by the HTTPRoute that has been now deleted.

Metadata

Metadata

Labels

kind/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions