[VOL-1719] Kubernetes Probes for R/O Core
Change-Id: I5a9e8963f312aa75cd7ca7c38440850f4cfae53f
diff --git a/ro_core/core/core.go b/ro_core/core/core.go
index 54cd455..cd27a42 100644
--- a/ro_core/core/core.go
+++ b/ro_core/core/core.go
@@ -19,6 +19,7 @@
"context"
grpcserver "github.com/opencord/voltha-go/common/grpc"
"github.com/opencord/voltha-go/common/log"
+ "github.com/opencord/voltha-go/common/probe"
"github.com/opencord/voltha-go/db/kvstore"
"github.com/opencord/voltha-go/db/model"
"github.com/opencord/voltha-go/ro_core/config"
@@ -113,9 +114,24 @@
core.grpcServer.AddService(f)
log.Info("grpc-service-added")
+ /*
+ * Start the GRPC server
+ *
+ * This is a bit sub-optimal here as the grpcServer.Start call does not return (blocks)
+ * until something fails, but we want to send a "start" status update. As written this
+ * means that we are actually sending the "start" status update before the server is
+ * started, which means it is possible that the status is "running" before it actually is.
+ *
+ * This means that there is a small window in which the core could return its status as
+ * ready, when it really isn't.
+ */
+ probe.UpdateStatusFromContext(ctx, "grpc-service", probe.ServiceStatusRunning)
+
// Start the server
- core.grpcServer.Start(context.Background())
log.Info("grpc-server-started")
+ core.grpcServer.Start(context.Background())
+
+ probe.UpdateStatusFromContext(ctx, "grpc-service", probe.ServiceStatusStopped)
}
func (core *Core) startDeviceManager(ctx context.Context) {
diff --git a/ro_core/core/device_manager.go b/ro_core/core/device_manager.go
index 90c7822..c42eee3 100644
--- a/ro_core/core/device_manager.go
+++ b/ro_core/core/device_manager.go
@@ -18,6 +18,7 @@
import (
"context"
"github.com/opencord/voltha-go/common/log"
+ "github.com/opencord/voltha-go/common/probe"
"github.com/opencord/voltha-go/db/model"
"github.com/opencord/voltha-protos/go/voltha"
"google.golang.org/grpc/codes"
@@ -44,12 +45,14 @@
func (dMgr *DeviceManager) start(ctx context.Context, logicalDeviceMgr *LogicalDeviceManager) {
log.Info("starting-device-manager")
dMgr.logicalDeviceMgr = logicalDeviceMgr
+ probe.UpdateStatusFromContext(ctx, "device-manager", probe.ServiceStatusRunning)
log.Info("device-manager-started")
}
func (dMgr *DeviceManager) stop(ctx context.Context) {
log.Info("stopping-device-manager")
dMgr.exitChannel <- 1
+ probe.UpdateStatusFromContext(ctx, "device-manager", probe.ServiceStatusStopped)
log.Info("device-manager-stopped")
}
diff --git a/ro_core/core/logical_device_manager.go b/ro_core/core/logical_device_manager.go
index db220d5..215a406 100644
--- a/ro_core/core/logical_device_manager.go
+++ b/ro_core/core/logical_device_manager.go
@@ -18,6 +18,7 @@
import (
"context"
"github.com/opencord/voltha-go/common/log"
+ "github.com/opencord/voltha-go/common/probe"
"github.com/opencord/voltha-go/db/model"
"github.com/opencord/voltha-protos/go/voltha"
"google.golang.org/grpc/codes"
@@ -49,12 +50,14 @@
func (ldMgr *LogicalDeviceManager) start(ctx context.Context) {
log.Info("starting-logical-device-manager")
+ probe.UpdateStatusFromContext(ctx, "logical-device-manager", probe.ServiceStatusRunning)
log.Info("logical-device-manager-started")
}
func (ldMgr *LogicalDeviceManager) stop(ctx context.Context) {
log.Info("stopping-logical-device-manager")
ldMgr.exitChannel <- 1
+ probe.UpdateStatusFromContext(ctx, "logical-device-manager", probe.ServiceStatusStopped)
log.Info("logical-device-manager-stopped")
}