Skip to content

Commit

Permalink
MESH-5878: Admiral does not create envoy filter on client onboardings
Browse files Browse the repository at this point in the history
- Introduce RoutingPolicyProcessor interface
- Inject RoutingPolicyService into DependencyHandler

Tech-Debt:
- Increase coverage for routingpolicy_handler.go

Signed-off-by: Adil Fulara <[email protected]>
  • Loading branch information
Adil Fulara committed Dec 17, 2024
1 parent 82738c6 commit d2ffc07
Show file tree
Hide file tree
Showing 10 changed files with 765 additions and 241 deletions.
4 changes: 4 additions & 0 deletions admiral/pkg/clusters/dependency_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type DependencyHandler struct {
RemoteRegistry *RemoteRegistry
DepController *admiral.DependencyController
DestinationServiceProcessor DestinationServiceProcessor
RoutingPolicyProcessor RoutingPolicyProcessor
}

func (dh *DependencyHandler) Added(ctx context.Context, obj *v1.Dependency) error {
Expand Down Expand Up @@ -74,6 +75,9 @@ func (dh *DependencyHandler) HandleDependencyRecord(ctx context.Context, obj *v1
return handleDepRecordErrors
}

// process routing policies
_ = dh.RoutingPolicyProcessor.DeltaUpdate(ctx, eventType, obj)

remoteRegistry.AdmiralCache.SourceToDestinations.put(obj)
return handleDepRecordErrors
}
Expand Down
4 changes: 0 additions & 4 deletions admiral/pkg/clusters/envoyfilter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import (
func TestCreateOrUpdateEnvoyFilter(t *testing.T) {
registry := getRegistry("1.13,1.17")

handler := RoutingPolicyHandler{}

rpFilterCache := &routingPolicyFilterCache{}
rpFilterCache.filterCache = make(map[string]map[string]map[string]string)
rpFilterCache.mutex = &sync.Mutex{}
Expand Down Expand Up @@ -89,8 +87,6 @@ func TestCreateOrUpdateEnvoyFilter(t *testing.T) {
registry.AdmiralCache.IdentityDependencyCache.Put("foo", "bar", "bar")
registry.AdmiralCache.IdentityClusterCache.Put("bar", remoteController.ClusterID, remoteController.ClusterID)

handler.RemoteRegistry = registry

routingPolicyFoo := &v1.RoutingPolicy{
TypeMeta: metav1.TypeMeta{},
ObjectMeta: metav1.ObjectMeta{
Expand Down
6 changes: 5 additions & 1 deletion admiral/pkg/clusters/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ func InitAdmiral(ctx context.Context, params common.AdmiralParams) (*RemoteRegis

var err error
destinationServiceProcessor := &ProcessDestinationService{}
routingPolicyProcessor := NewRoutingPolicyProcessor(rr)
wd := DependencyHandler{
RemoteRegistry: rr,
DestinationServiceProcessor: destinationServiceProcessor,
RoutingPolicyProcessor: routingPolicyProcessor,
}

wd.DepController, err = admiral.NewDependencyController(ctx.Done(), &wd, params.KubeconfigPath, params.DependenciesNamespace, 0, rr.ClientLoader)
Expand Down Expand Up @@ -197,7 +199,9 @@ func (r *RemoteRegistry) createCacheController(clientConfig *rest.Config, cluste
return fmt.Errorf("error with NodeController controller initialization, err: %v", err)
}
logrus.Infof("starting RoutingPoliciesController for clusterID: %v", clusterID)
rc.RoutingPolicyController, err = admiral.NewRoutingPoliciesController(stop, &RoutingPolicyHandler{RemoteRegistry: r, ClusterID: clusterID}, clientConfig, 0, r.ClientLoader)
rpProcessor := NewRoutingPolicyProcessor(r)
rpHandler := NewRoutingPolicyHandler(r, clusterID, rpProcessor)
rc.RoutingPolicyController, err = admiral.NewRoutingPoliciesController(stop, rpHandler, clientConfig, 0, r.ClientLoader)
if err != nil {
return fmt.Errorf("error with RoutingPoliciesController initialization, err: %v", err)
}
Expand Down
1 change: 1 addition & 0 deletions admiral/pkg/clusters/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ func TestAdded(t *testing.T) {
RemoteRegistry: rr,
DepController: d,
DestinationServiceProcessor: &MockDestinationServiceProcessor{},
RoutingPolicyProcessor: &MockPolicyProcessor{},
}

depData := v1.Dependency{
Expand Down
Loading

0 comments on commit d2ffc07

Please sign in to comment.