[VOL-3929] Fix for bbsim restart on grpc server restart followed by a device disable/delete
Change-Id: I47902c8a94b481933d2b14bb2530124523622046
diff --git a/VERSION b/VERSION
index 26ca594..4bb2004 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.5.1
+1.5.2-dev
diff --git a/internal/bbsim/api/grpc_api_server.go b/internal/bbsim/api/grpc_api_server.go
index 5fd6392..01c7f4f 100644
--- a/internal/bbsim/api/grpc_api_server.go
+++ b/internal/bbsim/api/grpc_api_server.go
@@ -149,10 +149,15 @@
logger.Infof("Received request to start Openolt gRPC Server")
- _, err := o.StartOltServer()
+ if o.OltServer != nil {
+ return nil, fmt.Errorf("Openolt gRPC server already running.")
+ }
+
+ oltGrpcServer, err := o.StartOltServer()
if err != nil {
return nil, err
}
+ o.OltServer = oltGrpcServer
return res, nil
}
@@ -168,12 +173,13 @@
go func() {
time.Sleep(time.Duration(req.Delay) * time.Second)
- _, err := o.StartOltServer()
+ oltGrpcServer, err := o.StartOltServer()
if err != nil {
logger.WithFields(log.Fields{
"err": err,
}).Error("Cannot restart Openolt gRPC server")
}
+ o.OltServer = oltGrpcServer
logger.Infof("Openolt gRPC Server restarted after %v seconds", req.Delay)
}()
diff --git a/internal/bbsim/devices/olt.go b/internal/bbsim/devices/olt.go
index b2c82d9..f6a4b40 100644
--- a/internal/bbsim/devices/olt.go
+++ b/internal/bbsim/devices/olt.go
@@ -49,7 +49,7 @@
type OltDevice struct {
sync.Mutex
- oltServer *grpc.Server
+ OltServer *grpc.Server
// BBSIM Internals
ID int
@@ -226,8 +226,8 @@
func (o *OltDevice) InitOlt() {
- if o.oltServer == nil {
- o.oltServer, _ = o.StartOltServer()
+ if o.OltServer == nil {
+ o.OltServer, _ = o.StartOltServer()
} else {
oltLogger.Fatal("OLT server already running.")
}
@@ -355,12 +355,12 @@
// StopOltServer stops the OpenOLT grpc server
func (o *OltDevice) StopOltServer() {
- if o.oltServer != nil {
+ if o.OltServer != nil {
oltLogger.WithFields(log.Fields{
"oltId": o.SerialNumber,
}).Warnf("Stopping OLT gRPC server")
- o.oltServer.Stop()
- o.oltServer = nil
+ o.OltServer.Stop()
+ o.OltServer = nil
}
}