Skip to content

Commit

Permalink
fix: Register grpc reflection service in Init (#1519)
Browse files Browse the repository at this point in the history
* fix: Register grpc reflection service in Init

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Update grpc

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Add WithReflection option as opt-out

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
  • Loading branch information
ondrej-fabry authored and VladoLavor committed Oct 15, 2019
1 parent 54f0a43 commit fc5a019
Show file tree
Hide file tree
Showing 98 changed files with 6,595 additions and 2,531 deletions.
13 changes: 10 additions & 3 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions plugins/orchestrator/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func NewPlugin(opts ...Option) *Plugin {
p.GRPC = &grpc.DefaultPlugin
p.KVScheduler = &kvscheduler.DefaultPlugin
p.Watcher = local.DefaultRegistry
p.reflection = true

for _, o := range opts {
o(p)
Expand All @@ -42,3 +43,9 @@ func NewPlugin(opts ...Option) *Plugin {

// Option is a function that acts on a Plugin to inject Dependencies or configuration
type Option func(*Plugin)

func WithReflection(enabled bool) Option {
return func(p *Plugin) {
p.reflection = enabled
}
}
10 changes: 7 additions & 3 deletions plugins/orchestrator/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type Plugin struct {
resyncChan chan datasync.ResyncEvent
watchDataReg datasync.WatchRegistration

reflection bool

*dispatcher
}

Expand Down Expand Up @@ -79,6 +81,11 @@ func (p *Plugin) Init() (err error) {
if grpcServer := p.GRPC.GetServer(); grpcServer != nil {
generic.RegisterManagerServer(grpcServer, p.manager)
generic.RegisterMetaServiceServer(grpcServer, p.manager)
// register grpc services for reflection
if p.reflection {
p.Log.Infof("registering grpc reflection service")
reflection.Register(grpcServer)
}
} else {
p.log.Infof("grpc server not available")
}
Expand Down Expand Up @@ -117,9 +124,6 @@ func (p *Plugin) AfterInit() (err error) {
p.kvs.WatchValueStatus(statusChan, nil)
go p.watchStatus(statusChan)

// register grpc services for reflection
reflection.Register(p.GRPC.GetServer())

return nil
}

Expand Down
17 changes: 9 additions & 8 deletions vendor/google.golang.org/grpc/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/google.golang.org/grpc/CODE-OF-CONDUCT.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 44 additions & 18 deletions vendor/google.golang.org/grpc/CONTRIBUTING.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/google.golang.org/grpc/GOVERNANCE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions vendor/google.golang.org/grpc/MAINTAINERS.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vendor/google.golang.org/grpc/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fc5a019

Please sign in to comment.