Skip to content

Commit e663cbd

Browse files
committed
Add grpc health check service
Fixes: containerd#615 Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
1 parent a160a6a commit e663cbd

File tree

6 files changed

+281
-0
lines changed

6 files changed

+281
-0
lines changed

cmd/containerd/builtins.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
_ "github.com/docker/containerd/linux"
66
_ "github.com/docker/containerd/services/content"
77
_ "github.com/docker/containerd/services/execution"
8+
_ "github.com/docker/containerd/services/healthcheck"
89
_ "github.com/docker/containerd/snapshot/btrfs"
910
_ "github.com/docker/containerd/snapshot/overlay"
1011
)

cmd/containerd/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ func main() {
125125
return err
126126
}
127127
}
128+
log.G(global).Info("starting GRPC API server...")
128129
if err := serveGRPC(server); err != nil {
129130
return err
130131
}

services/healthcheck/service.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package healthcheck
2+
3+
import (
4+
"github.com/docker/containerd/plugin"
5+
6+
"google.golang.org/grpc"
7+
"google.golang.org/grpc/health"
8+
"google.golang.org/grpc/health/grpc_health_v1"
9+
)
10+
11+
type Service struct {
12+
serve *health.Server
13+
}
14+
15+
func init() {
16+
plugin.Register("healthcheck-grpc", &plugin.Registration{
17+
Type: plugin.GRPCPlugin,
18+
Init: NewService,
19+
})
20+
}
21+
22+
func NewService(ic *plugin.InitContext) (interface{}, error) {
23+
return &Service{
24+
health.NewServer(),
25+
}, nil
26+
}
27+
28+
func (s *Service) Register(server *grpc.Server) error {
29+
grpc_health_v1.RegisterHealthServer(server, s.serve)
30+
return nil
31+
}

vendor/google.golang.org/grpc/health/grpc_health_v1/health.pb.go

Lines changed: 176 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/google.golang.org/grpc/health/grpc_health_v1/health.proto

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/google.golang.org/grpc/health/health.go

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)