Skip to content

Commit

Permalink
Disable service controller for now
Browse files Browse the repository at this point in the history
  • Loading branch information
ykadowak committed Dec 18, 2023
1 parent ad1be28 commit b5de93d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion pkg/discoverer/k8s/handler/grpc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (s *server) Nodes(ctx context.Context, req *payload.Discoverer_Request) (*p
return cn, nil
}

// Services returns the services infomation that match the request.
// Services returns the services information that match the request.
func (s *server) Services(ctx context.Context, req *payload.Discoverer_Request) (*payload.Info_Services, error) {
ctx, span := trace.StartSpan(ctx, apiName+".Services")
defer func() {
Expand Down
50 changes: 25 additions & 25 deletions pkg/discoverer/k8s/service/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,31 +182,31 @@ func New(selector *config.Selectors, opts ...Option) (dsc Discoverer, err error)
node.WithLabels(selector.GetNodeLabels()),
)),
// Only required when service reconciation is required like read replica.
k8s.WithResourceController(service.New(
service.WithControllerName("service discoverer"),
service.WithOnErrorFunc(func(err error) {
log.Error("failed to reconcile:", err)
}),
service.WithOnReconcileFunc(func(svcs []service.Service) {
log.Debugf("svc resource reconciled\t%#v", svcs)
svcsmap := make(map[string]struct{}, len(svcs))
for i := range svcs {
svc := &svcs[i]
svcsmap[svc.Name] = struct{}{}
d.services.Store(svc.Name, svc)
}
d.services.Range(func(name string, _ *service.Service) bool {
_, ok := svcsmap[name]
if !ok {
d.services.Delete(name)
}
return true
})
}),
service.WithNamespace(d.namespace),
service.WithFields(selector.GetServiceFields()),
service.WithLabels(selector.GetServiceLabels()),
)),
// k8s.WithResourceController(service.New(
// service.WithControllerName("service discoverer"),
// service.WithOnErrorFunc(func(err error) {
// log.Error("failed to reconcile:", err)
// }),
// service.WithOnReconcileFunc(func(svcs []service.Service) {
// log.Debugf("svc resource reconciled\t%#v", svcs)
// svcsmap := make(map[string]struct{}, len(svcs))
// for i := range svcs {
// svc := &svcs[i]
// svcsmap[svc.Name] = struct{}{}
// d.services.Store(svc.Name, svc)
// }
// d.services.Range(func(name string, _ *service.Service) bool {
// _, ok := svcsmap[name]
// if !ok {
// d.services.Delete(name)
// }
// return true
// })
// }),
// service.WithNamespace(d.namespace),
// service.WithFields(selector.GetServiceFields()),
// service.WithLabels(selector.GetServiceLabels()),
// )),
)

d.ctrl, err = k8s.New(k8sOpts...)

Check warning on line 212 in pkg/discoverer/k8s/service/discover.go

View check run for this annotation

Codecov / codecov/patch

pkg/discoverer/k8s/service/discover.go#L212

Added line #L212 was not covered by tests
Expand Down

0 comments on commit b5de93d

Please sign in to comment.