Skip to content

Commit

Permalink
OSSM-1689 Simplify IOR (maistra#747)
Browse files Browse the repository at this point in the history
* Rework IOR initialization

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Remove `initialSync`

`initialSync` is not needed.

- During boostrap, `SetNamesapces`is always called with no namespaces.
- When removing or adding a namespace, the underlaying informer will
  trigger an `ADD` event for all resources the informer watches

Signed-off-by: Yann Liu <yannliu@redhat.com>

* DIsable TestPref

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Rename

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Call `findService` once for each gateway

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Use original host to generate Route name

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Skip duplicate update test

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Improve concurrency test

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Introduce update Route on Gateway update

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Fix data race

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Format and lint

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Respect log level

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Refactor IOR

- `gatawayMap` is removed. `Routes` are retrived via API.
-  `reconcileGateway` is used to achieve the desired state.
- `processEvent` will only process the latest and try to abort early.

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Remove unused functions

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Use `Lister` for finding target service

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Start IOR before kube client

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Remove unused properties

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Rework test initialization

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Log correct debug information

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Remove unnecessary parameters

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Remove ResourceVersion usage

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Avoid deletion of a route when failing to update

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Update FakeRouter to record API call counts

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Rework initialization

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Keep startup process order consistent

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Fix creating matching service

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Test IOR to be idempotent

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Remove unused parameters

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Rename symbol

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Remove used struct

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Improve styling and wording

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Add support list across namespaces in faker

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Lint and format

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Introduce Openshift Route informer

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Lint

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Run make gen

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Fix data race

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Fix test data race

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Lint

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Rename variables

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Fix update route

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Linit

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Increase wait for the delete

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Maximize time to wait for the route deletion

* Fix route update

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Fix route update

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Test with a 30 second wait

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Fix  flaky test

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Add disabling IOR and clean up

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Defer clean up

Signed-off-by: Yann Liu <yannliu@redhat.com>

* Clear only ior routes

Signed-off-by: Yann Liu <yannliu@redhat.com>

* rename newRoute to newRouteController

* rename route.go to controller.go

---------

Signed-off-by: Yann Liu <yannliu@redhat.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Signed-off-by: Yann Liu <yannliu@redhat.com>
  • Loading branch information
yannuil and luksa committed Aug 31, 2023
1 parent 0777418 commit f5f88ba
Show file tree
Hide file tree
Showing 12 changed files with 847 additions and 1,312 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ require (
github.com/opencontainers/image-spec v1.1.0-rc3 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/errors v0.9.1
github.com/prometheus/procfs v0.9.0 // indirect
github.com/prometheus/prom2json v1.3.2 // indirect
github.com/prometheus/statsd_exporter v0.23.0 // indirect
Expand All @@ -226,7 +226,7 @@ require (
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/stoewer/go-strcase v1.3.0
github.com/stretchr/testify v1.8.2
github.com/stretchr/testify v1.8.2 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/vbatts/tar-split v0.11.2 // indirect
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f // indirect
Expand Down
38 changes: 10 additions & 28 deletions pilot/pkg/bootstrap/configcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ func (s *Server) initConfigController(args *PilotArgs) error {
// Create the config store.
s.environment.ConfigStore = aggregateConfigController

s.startIOR(args)

// Defer starting the controller until after the service is created.
s.addStartFunc(func(stop <-chan struct{}) error {
go s.configController.Run(stop)
Expand All @@ -135,32 +133,6 @@ func (s *Server) initConfigController(args *PilotArgs) error {
return nil
}

// startIOR tries to start IOR, if it's enabled. If it encounters any failure, it logs an error and continue
func (s *Server) startIOR(args *PilotArgs) {
if !features.EnableIOR {
return
}

routerClient, err := ior.NewRouterClient()
if err != nil {
ior.IORLog.Errorf("error creating an openshift router client: %v", err)
return
}

iorKubeClient := ior.NewKubeClient(s.kubeClient)

s.addStartFunc(func(stop <-chan struct{}) error {
go leaderelection.
NewLeaderElection(args.Namespace, args.PodName, leaderelection.IORController, args.Revision, s.kubeClient).
AddRunFunction(func(stop <-chan struct{}) {
if err := ior.Register(iorKubeClient, routerClient, s.configController, args.Namespace, s.kubeClient.GetMemberRollController(), stop, nil); err != nil {
ior.IORLog.Error(err)
}
}).Run(stop)
return nil
})
}

func (s *Server) initK8SConfigStore(args *PilotArgs) error {
if s.kubeClient == nil {
return nil
Expand Down Expand Up @@ -233,6 +205,16 @@ func (s *Server) initK8SConfigStore(args *PilotArgs) error {
return err
}
}
if features.EnableIOR {
s.addTerminatingStartFunc(func(stop <-chan struct{}) error {
leaderelection.
NewLeaderElection(args.Namespace, args.PodName, leaderelection.IORController, args.Revision, s.kubeClient).
AddRunFunction(func(leaderStop <-chan struct{}) {
ior.Run(s.kubeClient, configController, leaderStop)
}).Run(stop)
return nil
})
}
s.RWConfigStore, err = configaggregate.MakeWriteableCache(s.ConfigStores, configController)
if err != nil {
return err
Expand Down

0 comments on commit f5f88ba

Please sign in to comment.