[VOL-5374] Update go version to 1.23
- Upgraded Go version for compatibility with recent toolchain
- Synced with latest dependency requirements
Change-Id: Ib526d29ec9e5d5e08e51354b741541038dcedb35
Signed-off-by: Akash Kankanala <akash.kankanala@radisys.com>
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index f6c3fa5..ca4e481 100755
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -79,47 +79,40 @@
// DeviceHandler will interact with the OLT device.
type DeviceHandler struct {
- cm *config.ConfigManager
- device *voltha.Device
- cfg *conf.AdapterFlags
- coreClient *vgrpc.Client
- childAdapterClients map[string]*vgrpc.Client
- lockChildAdapterClients sync.RWMutex
- EventProxy eventif.EventProxy
- openOLT *OpenOLT
- exitChannel chan struct{}
- lockDevice sync.RWMutex
- Client oop.OpenoltClient
- transitionMap *TransitionMap
- clientCon *grpc.ClientConn
- flowMgr []*OpenOltFlowMgr
- groupMgr *OpenOltGroupMgr
- eventMgr *OpenOltEventMgr
- resourceMgr []*rsrcMgr.OpenOltResourceMgr
- kvStore *db.Backend // backend kv store connection handle
+ EventProxy eventif.EventProxy
+ Client oop.OpenoltClient
+ cm *config.ConfigManager
+ device *voltha.Device
+ cfg *conf.AdapterFlags
+ coreClient *vgrpc.Client
+ childAdapterClients map[string]*vgrpc.Client
+ openOLT *OpenOLT
+ exitChannel chan struct{}
+ transitionMap *TransitionMap
+ clientCon *grpc.ClientConn
+ groupMgr *OpenOltGroupMgr
+ eventMgr *OpenOltEventMgr
+ kvStore *db.Backend // backend kv store connection handle
deviceInfo *oop.DeviceInfo
+ portStats *OpenOltStatisticsMgr
+ metrics *pmmetrics.PmMetrics
+ stopCollector chan bool
+ stopHeartbeatCheck chan bool
+ stopIndications chan bool
+ perPonOnuIndicationChannel map[uint32]onuIndicationChannels
+
// discOnus (map[onuSn]bool) contains a list of ONUs that have been discovered, indexed by ONU SerialNumber.
// if the value is true that means the OnuDiscovery indication
// is currently being processed and thus we can ignore concurrent requests
// if it's false it means the processing has completed and we shouldn't be receiving a new indication
// if we do it means something went wrong and we need to retry
- discOnus sync.Map
- onus sync.Map
- portStats *OpenOltStatisticsMgr
- metrics *pmmetrics.PmMetrics
- stopCollector chan bool
- isCollectorActive bool
- stopHeartbeatCheck chan bool
- isHeartbeatCheckActive bool
- activePorts sync.Map
- stopIndications chan bool
- isReadIndicationRoutineActive bool
-
- totalPonPorts uint32
- perPonOnuIndicationChannel map[uint32]onuIndicationChannels
- perPonOnuIndicationChannelLock sync.Mutex
+ discOnus sync.Map
+ onus sync.Map
+ activePorts sync.Map
+ flowMgr []*OpenOltFlowMgr
+ resourceMgr []*rsrcMgr.OpenOltResourceMgr
// Slice of channels. Each channel in slice, index by (mcast-group-id modulo MaxNumOfGroupHandlerChannels)
// A go routine per index, waits on a unique channel for incoming mcast flow or group (add/modify/remove).
@@ -127,11 +120,20 @@
stopMcastHandlerRoutine []chan bool
mcastHandlerRoutineActive []bool
+ lockChildAdapterClients sync.RWMutex
+ lockDevice sync.RWMutex
+ perPonOnuIndicationChannelLock sync.Mutex
+
+ totalPonPorts uint32
+ heartbeatSignature uint32
+ isCollectorActive bool
+ isHeartbeatCheckActive bool
+ isReadIndicationRoutineActive bool
+
adapterPreviouslyConnected bool
agentPreviouslyConnected bool
isDeviceDeletionInProgress bool
- heartbeatSignature uint32
prevOperStatus common.OperStatus_Types
}
@@ -140,12 +142,12 @@
deviceID string
deviceType string
serialNumber string
+ proxyDeviceID string
+ adapterEndpoint string
onuID uint32
intfID uint32
- proxyDeviceID string
losRaised bool
rdiRaised bool
- adapterEndpoint string
}
type onuIndicationMsg struct {
@@ -164,10 +166,10 @@
// and process them serially. The mcast flow/group are assigned these routines based on formula (group-id modulo MaxNumOfGroupHandlerChannels)
type McastFlowOrGroupControlBlock struct {
ctx context.Context // Flow/group handler context
- flowOrGroupAction string // one of McastFlowOrGroupAdd, McastFlowOrGroupModify or McastFlowOrGroupDelete
flow *of.OfpFlowStats // Flow message (can be nil or valid flow)
group *of.OfpGroupEntry // Group message (can be nil or valid group)
errChan *chan error // channel to report the mcast Flow/group handling error
+ flowOrGroupAction string // one of McastFlowOrGroupAdd, McastFlowOrGroupModify or McastFlowOrGroupDelete
}
var pmNames = []string{
@@ -235,7 +237,7 @@
dh.mcastHandlerRoutineActive[i] = true
go dh.mcastFlowOrGroupChannelHandlerRoutine(i, dh.incomingMcastFlowOrGroup[i], dh.stopMcastHandlerRoutine[i])
}
- //TODO initialize the support classes.
+ // TODO initialize the support classes.
return &dh
}
@@ -378,7 +380,6 @@
// GetportLabel returns the label for the NNI and the PON port based on port number and port type
func GetportLabel(portNum uint32, portType voltha.Port_PortType) (string, error) {
-
switch portType {
case voltha.Port_ETHERNET_NNI:
return fmt.Sprintf("nni-%d", portNum), nil
@@ -391,8 +392,8 @@
func makeOfpPort(macAddress string, speedMbps uint32) *of.OfpPort {
if speedMbps == 0 {
- //In case it was not set in the indication
- //and no other value was provided
+ // In case it was not set in the indication
+ // and no other value was provided
speedMbps = defaultPortSpeedMbps
}
@@ -423,8 +424,8 @@
Curr: capacity,
Advertised: capacity,
Peer: capacity,
- CurrSpeed: speedMbps * 1000, //kbps
- MaxSpeed: speedMbps * 1000, //kbps
+ CurrSpeed: speedMbps * 1000, // kbps
+ MaxSpeed: speedMbps * 1000, // kbps
}
return port
@@ -434,7 +435,7 @@
var operStatus common.OperStatus_Types
if state == "up" {
operStatus = voltha.OperStatus_ACTIVE
- //populating the intfStatus map
+ // populating the intfStatus map
dh.activePorts.Store(intfID, true)
} else {
operStatus = voltha.OperStatus_DISCOVERED
@@ -656,7 +657,7 @@
return nil
}
-// nolint: gocyclo
+// nolint: gocyclo,govet
func (dh *DeviceHandler) handleIndication(ctx context.Context, indication *oop.Indication) {
raisedTs := time.Now().Unix()
switch indication.Data.(type) {
@@ -708,7 +709,7 @@
onuDiscInd := indication.GetOnuDiscInd()
logger.Infow(ctx, "received-onu-discovery-indication", log.Fields{"OnuDiscInd": onuDiscInd, "device-id": dh.device.Id})
- //put message to channel and return immediately
+ // put message to channel and return immediately
dh.putOnuIndicationToChannel(ctx, indication, onuDiscInd.GetIntfId())
case *oop.Indication_OnuInd:
span, ctx := log.CreateChildSpan(ctx, "onu-indication", log.Fields{"device-id": dh.device.Id})
@@ -716,7 +717,7 @@
onuInd := indication.GetOnuInd()
logger.Infow(ctx, "received-onu-indication", log.Fields{"OnuInd": onuInd, "device-id": dh.device.Id})
- //put message to channel and return immediately
+ // put message to channel and return immediately
dh.putOnuIndicationToChannel(ctx, indication, onuInd.GetIntfId())
case *oop.Indication_OmciInd:
span, ctx := log.CreateChildSpan(ctx, "omci-indication", log.Fields{"device-id": dh.device.Id})
@@ -808,8 +809,8 @@
}
return alarmInd
}
-func generatePonLosAlarmIndication(intfID uint32, losStatus string) *oop.AlarmIndication {
+func generatePonLosAlarmIndication(intfID uint32, losStatus string) *oop.AlarmIndication {
ponlosAlarmInd := &oop.LosIndication{
IntfId: intfID,
Status: losStatus,
@@ -821,6 +822,7 @@
}
return alarmInd
}
+
func (dh *DeviceHandler) updateIntfOperStateAndRaiseIndication(ctx context.Context, operState string, intfID uint32) {
go func() {
if err := dh.addPort(ctx, intfID, voltha.Port_PON_OLT, operState, defaultPortSpeedMbps); err != nil {
@@ -833,16 +835,12 @@
}
func (dh *DeviceHandler) reconcileOnus(ctx context.Context) error {
-
onuDevicesFromCore, err := dh.getChildDevicesFromCore(ctx, dh.device.Id)
if err != nil {
-
logger.Error(ctx, "unable to fetch child device", log.Fields{"eeror": err})
-
return err
}
for _, onuDeviceFromCore := range onuDevicesFromCore.Items {
-
onuOperStatusFromCore := onuDeviceFromCore.OperStatus
onuConnectStatusFromCore := onuDeviceFromCore.ConnectStatus
intfID := plt.PortNoToIntfID(onuDeviceFromCore.ParentPortNo, voltha.Port_PON_OLT)
@@ -851,7 +849,6 @@
onuDeviceFromOlt, err := dh.getOnuInfo(ctx, intfID, &onuID)
if err != nil {
logger.Error(ctx, "unable to get onu object from olt agent", log.Fields{"eeror": err})
-
} else {
onuOperStatusFromOlt := onuDeviceFromOlt.GetState()
onuLosFromOlt := onuDeviceFromOlt.GetLosi()
@@ -861,18 +858,15 @@
dh.putOnuIndicationToChannel(ctx, OnuIndication, intfID)
case onuLosFromOlt.String() == "ON" && onuConnectStatusFromCore.String() == "REACHABLE":
- OnuIndication := generateOnuIndication(intfID, onuID, "down", "down") //check bal cli login notepad
+ OnuIndication := generateOnuIndication(intfID, onuID, "down", "down") // check bal cli login notepad
alarmInd := generateOnuAlarmIndication(intfID, onuID, "on")
raisedTs := time.Now().Unix()
go dh.eventMgr.ProcessEvents(ctx, alarmInd, dh.device.Id, raisedTs)
dh.putOnuIndicationToChannel(ctx, OnuIndication, intfID)
}
-
}
-
}
-
return nil
}
@@ -883,9 +877,7 @@
})
if err != nil {
logger.Error(ctx, "unable to fetch ports from core", log.Fields{"eeror": err})
-
return err
-
}
for _, portFromCore := range portsFromCore.Items {
portNum := portFromCore.GetPortNo()
@@ -907,7 +899,6 @@
ponLosindication := generatePonLosAlarmIndication(intfID, "on")
raisedTs := time.Now().Unix()
go dh.eventMgr.ProcessEvents(ctx, ponLosindication, dh.device.Id, raisedTs)
-
}
switch {
case portStateFromOlt.String() == "ACTIVE_WORKING" && portOperStatusFromCore.String() != "ACTIVE":
@@ -934,13 +925,9 @@
"portOperStatusFromCore": portOperStatusFromCore.String(),
"device-id": dh.device.Id,
"port": portNum})
-
}
-
}
-
}
-
return nil
}
@@ -978,17 +965,15 @@
dh.stopIndications <- true
}
dh.lockDevice.RUnlock()
- if err := dh.cleanupDeviceResources(ctx); err != nil {
+ if err = dh.cleanupDeviceResources(ctx); err != nil {
logger.Error(ctx, "unable to clean up device resources", log.Fields{"error": err})
return fmt.Errorf("cleanup device resources failed: %w", err)
}
- if err := dh.initializeDeviceHandlerModules(ctx); err != nil {
+ if err = dh.initializeDeviceHandlerModules(ctx); err != nil {
return olterrors.NewErrAdapter("device-handler-initialization-failed", log.Fields{"device-id": dh.device.Id}, err).LogAt(log.ErrorLevel)
}
go startHeartbeatCheck(ctx, dh)
-
//dh.lockDevice.RUnlock()
-
} else if device.OperStatus == voltha.OperStatus_RECONCILING {
// Log the device's operational status if it's RECONCILING
logger.Info(ctx, "Device is being reconciled", log.Fields{
@@ -1036,7 +1021,7 @@
return olterrors.NewErrAdapter("device-state-update-failed", log.Fields{"device-id": dh.device.Id}, err)
}
- //Clear olt communication failure event
+ // Clear olt communication failure event
dh.device.ConnectStatus = voltha.ConnectStatus_REACHABLE
dh.device.OperStatus = voltha.OperStatus_ACTIVE
raisedTs := time.Now().Unix()
@@ -1057,7 +1042,7 @@
cloned := proto.Clone(device).(*voltha.Device)
- //Update the device oper state and connection status
+ // Update the device oper state and connection status
cloned.OperStatus = voltha.OperStatus_UNKNOWN
dh.lockDevice.Lock()
dh.device = cloned
@@ -1071,7 +1056,7 @@
return olterrors.NewErrAdapter("state-update-failed", log.Fields{"device-id": device.Id}, err)
}
- //get the child device for the parent device
+ // get the child device for the parent device
onuDevices, err := dh.getChildDevicesFromCore(ctx, dh.device.Id)
if err != nil {
return olterrors.NewErrAdapter("child-device-fetch-failed", log.Fields{"device-id": dh.device.Id}, err)
@@ -1097,7 +1082,7 @@
"onu-indicator": onuInd,
"device-type": onuDevice.Type,
"device-id": onuDevice.Id}, err).LogAt(log.ErrorLevel)
- //Do not return here and continue to process other ONUs
+ // Do not return here and continue to process other ONUs
} else {
logger.Debugw(ctx, "sending inter adapter down ind to onu success", log.Fields{"olt-device-id": device.Id, "onu-device-id": onuDevice.Id})
}
@@ -1280,7 +1265,7 @@
for i = 0; i < dh.totalPonPorts+1; i++ {
// Instantiate flow manager
if dh.flowMgr[i] = NewFlowManager(ctx, dh, dh.resourceMgr[i], dh.groupMgr, i); dh.flowMgr[i] == nil {
- //Continue to check the rest of the ports
+ // Continue to check the rest of the ports
logger.Errorw(ctx, "error-initializing-flow-manager-for-intf", log.Fields{"intfID": i, "device-id": dh.device.Id})
} else {
dh.resourceMgr[i].TechprofileRef = dh.flowMgr[i].techprofile
@@ -1294,12 +1279,12 @@
dh.portStats = NewOpenOltStatsMgr(ctx, dh)
return nil
-
}
func (dh *DeviceHandler) populateDeviceInfo(ctx context.Context) (*oop.DeviceInfo, error) {
var err error
var deviceInfo *oop.DeviceInfo
+ var genmac string
deviceInfo, err = dh.Client.GetDeviceInfo(log.WithSpanFromContext(context.Background(), ctx), new(oop.Empty))
@@ -1321,7 +1306,7 @@
if deviceInfo.DeviceId == "" {
logger.Warnw(ctx, "no-device-id-provided-using-host", log.Fields{"hostport": dh.device.GetHostAndPort()})
host := strings.Split(dh.device.GetHostAndPort(), ":")[0]
- genmac, err := generateMacFromHost(ctx, host)
+ genmac, err = generateMacFromHost(ctx, host)
if err != nil {
return nil, olterrors.NewErrAdapter("failed-to-generate-mac-host", log.Fields{"host": host}, err)
}
@@ -1442,7 +1427,6 @@
return nil, olterrors.NewErrNotFound("no-flow-manager-found", log.Fields{"intf-id": ifID, "parent-device-id": request.ParentDeviceId, "child-device-id": request.DeviceId}, nil).Log()
}
return dh.flowMgr[ifID].getTechProfileDownloadMessage(ctx, request.TpInstancePath, request.OnuId, request.DeviceId)
-
}
func (dh *DeviceHandler) omciIndication(ctx context.Context, omciInd *oop.OmciIndication) error {
@@ -1461,7 +1445,6 @@
onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId)
if onuInCache, ok := dh.onus.Load(onuKey); !ok {
-
logger.Debugw(ctx, "omci-indication-for-a-device-not-in-cache.", log.Fields{"intf-id": omciInd.IntfId, "onu-id": omciInd.OnuId, "device-id": dh.device.Id})
ponPort := plt.IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
@@ -1479,10 +1462,10 @@
deviceID = onuDevice.Id
proxyDeviceID = onuDevice.ProxyAddress.DeviceId
childAdapterEndpoint = onuDevice.AdapterEndpoint
- //if not exist in cache, then add to cache.
+ // if not exist in cache, then add to cache.
dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID, false, onuDevice.AdapterEndpoint))
} else {
- //found in cache
+ // found in cache
logger.Debugw(ctx, "omci-indication-for-a-device-in-cache.", log.Fields{"intf-id": omciInd.IntfId, "onu-id": omciInd.OnuId, "device-id": dh.device.Id})
deviceType = onuInCache.(*OnuDevice).deviceType
deviceID = onuInCache.(*OnuDevice).deviceID
@@ -1572,7 +1555,6 @@
onuSecOmciMsgList := omciMsgs.GetMessages()
for _, onuSecOmciMsg := range onuSecOmciMsgList {
-
var omciMessage *oop.OmciMsg
hexPkt := make([]byte, hex.EncodedLen(len(onuSecOmciMsg)))
hex.Encode(hexPkt, onuSecOmciMsg)
@@ -1683,7 +1665,6 @@
st, _ := status.FromError(err)
if st.Code() == codes.AlreadyExists {
logger.Debugw(ctx, "onu-activation-in-progress", log.Fields{"SerialNumber": serialNumber, "onu-id": onuID, "device-id": dh.device.Id})
-
} else {
return olterrors.NewErrAdapter("onu-activate-failed", log.Fields{"onu": Onu, "device-id": dh.device.Id}, err)
}
@@ -1704,7 +1685,7 @@
}
return true
})
- //Got the onu device from cache return
+ // Got the onu device from cache return
if InCacheOnuDev != nil {
logger.Debugw(ctx, "Got child device from cache", log.Fields{"onudev": InCacheOnuDev.serialNumber})
return InCacheOnuDev
@@ -1714,7 +1695,7 @@
SerialNumber: sn,
ParentPortNo: parentPortNo,
})
- //No device found in core return nil
+ // No device found in core return nil
if onuDevice == nil {
return nil
}
@@ -1733,7 +1714,7 @@
parentPortNo := plt.IntfIDToPortNo(onuDiscInd.GetIntfId(), voltha.Port_PON_OLT)
tpInstExists := false
- //CheckOnuDevExistenceAtOnuDiscovery if true , a check will be made for the existence of the onu device. If the onu device
+ // CheckOnuDevExistenceAtOnuDiscovery if true , a check will be made for the existence of the onu device. If the onu device
// still exists , the onu discovery will be ignored, else a check for active techprofiles for ONU is checked.
if !dh.openOLT.CheckOnuDevExistenceAtOnuDiscovery {
onuDev := dh.getChildDevice(ctx, sn, parentPortNo)
@@ -1771,7 +1752,6 @@
logger.Infow(ctx, "No device present in core , continuing with discovery", log.Fields{"sn": sn})
return false, nil
-
}
// processDiscONULOSClear clears the LOS Alarm if it's needed
@@ -1834,7 +1814,7 @@
return error
}
if tpInstExists {
- //ignore the discovery if tpinstance is present.
+ // ignore the discovery if tpinstance is present.
logger.Debugw(ctx, "ignoring-onu-indication-as-tp-already-exists", log.Fields{"sn": sn})
return nil
}
@@ -1842,7 +1822,6 @@
// if the ONU existed, handle the LOS Alarm
if existing {
-
if inProcess.(bool) {
// if we're currently processing the ONU on a different thread, do nothing
logger.Warnw(ctx, "onu-sn-is-being-processed", log.Fields{"sn": sn})
@@ -1887,7 +1866,6 @@
// we need to create a new ChildDevice
ponintfid := onuDiscInd.GetIntfId()
onuID, error = dh.resourceMgr[ponintfid].GetONUID(ctx)
-
logger.Infow(ctx, "creating-new-onu-got-onu-id", log.Fields{"sn": sn, "onuId": onuID})
if error != nil {
@@ -1917,7 +1895,7 @@
"serial-number": sn}, error)
return error
}
- if error := dh.eventMgr.OnuDiscoveryIndication(ctx, onuDiscInd, dh.device.Id, onuDevice.Id, onuID, sn, time.Now().Unix()); error != nil {
+ if error = dh.eventMgr.OnuDiscoveryIndication(ctx, onuDiscInd, dh.device.Id, onuDevice.Id, onuID, sn, time.Now().Unix()); error != nil {
logger.Error(ctx, "discovery-indication-failed", log.Fields{"err": error})
error = olterrors.NewErrAdapter("discovery-indication-failed", log.Fields{
"onu-id": onuID,
@@ -1937,14 +1915,13 @@
error = dh.setupChildInterAdapterClient(subCtx, onuDevice.AdapterEndpoint)
cancel()
if error != nil {
-
error = olterrors.NewErrCommunication("no-connection-to-child-adapter", log.Fields{"device-id": onuDevice.Id}, error)
return error
}
// we can now use the existing ONU Id
onuID = onuDevice.ProxyAddress.OnuId
- //Insert the ONU into cache to use in OnuIndication.
+ // Insert the ONU into cache to use in OnuIndication.
//TODO: Do we need to remove this from the cache on ONU change, or wait for overwritten on next discovery.
logger.Debugw(ctx, "onu-discovery-indication-key-create",
log.Fields{"onu-id": onuID,
@@ -1964,7 +1941,6 @@
OperStatus: common.OperStatus_DISCOVERED,
ConnStatus: common.ConnectStatus_REACHABLE,
}); error != nil {
-
error = olterrors.NewErrAdapter("failed-to-update-device-state", log.Fields{
"device-id": onuDevice.Id,
"serial-number": sn}, error)
@@ -1973,7 +1949,6 @@
logger.Infow(ctx, "onu-discovered-reachable", log.Fields{"device-id": onuDevice.Id, "sn": sn})
if error = dh.activateONU(ctx, onuDiscInd.IntfId, int64(onuID), onuDiscInd.SerialNumber, sn); error != nil {
-
error = olterrors.NewErrAdapter("onu-activation-failed", log.Fields{
"device-id": onuDevice.Id,
"serial-number": sn}, error)
@@ -1983,7 +1958,6 @@
}
func (dh *DeviceHandler) onuIndication(ctx context.Context, onuInd *oop.OnuIndication) error {
-
ponPort := plt.IntfIDToPortNo(onuInd.GetIntfId(), voltha.Port_PON_OLT)
var onuDevice *voltha.Device
var err error
@@ -1994,17 +1968,15 @@
"device-id": dh.device.Id})
onuKey := dh.formOnuKey(onuInd.GetIntfId(), onuInd.OnuId)
serialNumber := dh.stringifySerialNumber(onuInd.SerialNumber)
-
errFields := log.Fields{"device-id": dh.device.Id}
if onuInCache, ok := dh.onus.Load(onuKey); ok {
-
- //If ONU id is discovered before then use GetDevice to get onuDevice because it is cheaper.
+ // If ONU id is discovered before then use GetDevice to get onuDevice because it is cheaper.
foundInCache = true
errFields["onu-id"] = onuInCache.(*OnuDevice).deviceID
onuDevice, err = dh.getDeviceFromCore(ctx, onuInCache.(*OnuDevice).deviceID)
} else {
- //If ONU not found in adapter cache then we have to use GetChildDevice to get onuDevice
+ // If ONU not found in adapter cache then we have to use GetChildDevice to get onuDevice
if serialNumber != "" {
errFields["serial-number"] = serialNumber
} else {
@@ -2037,9 +2009,7 @@
}
if !foundInCache {
onuKey := dh.formOnuKey(onuInd.GetIntfId(), onuInd.GetOnuId())
-
dh.onus.Store(onuKey, NewOnuDevice(onuDevice.Id, onuDevice.Type, onuDevice.SerialNumber, onuInd.GetOnuId(), onuInd.GetIntfId(), onuDevice.ProxyAddress.DeviceId, false, onuDevice.AdapterEndpoint))
-
}
if onuInd.OperState == "down" && onuInd.FailReason != oop.OnuIndication_ONU_ACTIVATION_FAIL_REASON_NONE {
if err := dh.eventMgr.onuActivationIndication(ctx, onuActivationFailEvent, onuInd, dh.device.Id, time.Now().Unix()); err != nil {
@@ -2192,7 +2162,6 @@
metrics := dh.metrics.GetSubscriberMetrics()
for _, m := range pmConfigs.Metrics {
metrics[m.Name].Enabled = m.Enabled
-
}
}
}
@@ -2209,7 +2178,7 @@
if flows != nil {
for _, flow := range flows.ToRemove.Items {
- intfID := dh.getIntfIDFromFlow(ctx, flow)
+ intfID := dh.getIntfIDFromFlow(flow)
logger.Debugw(ctx, "removing-flow",
log.Fields{"device-id": device.Id,
@@ -2226,7 +2195,7 @@
}
if err != nil {
if werr, ok := err.(olterrors.WrappedError); ok && status.Code(werr.Unwrap()) == codes.NotFound {
- //The flow we want to remove is not there, there is no need to throw an error
+ // The flow we want to remove is not there, there is no need to throw an error
logger.Warnw(ctx, "flow-to-remove-not-found",
log.Fields{
"ponIf": intfID,
@@ -2240,7 +2209,7 @@
}
for _, flow := range flows.ToAdd.Items {
- intfID := dh.getIntfIDFromFlow(ctx, flow)
+ intfID := dh.getIntfIDFromFlow(flow)
logger.Debugw(ctx, "adding-flow",
log.Fields{"device-id": device.Id,
"ponIf": intfID,
@@ -2305,7 +2274,6 @@
// UpdateFlowsIncrementally updates the device flow
func (dh *DeviceHandler) UpdateFlowsIncrementally(ctx context.Context, device *voltha.Device, flows *of.FlowChanges, groups *of.FlowGroupChanges, flowMetadata *of.FlowMetadata) error {
-
var errorsList []error
if dh.getDeviceDeletionInProgressFlag() {
@@ -2350,7 +2318,7 @@
dh.onus = sync.Map{}
dh.lockDevice.RLock()
- //stopping the stats collector
+ // stopping the stats collector
if dh.isCollectorActive {
dh.stopCollector <- true
}
@@ -2358,7 +2326,7 @@
go dh.notifyChildDevices(ctx, "unreachable")
cloned := proto.Clone(device).(*voltha.Device)
- //Update device Admin state
+ // Update device Admin state
dh.device = cloned
// Update the all pon ports state on that device to disable and NNI remains active as NNI remains active in openolt agent.
@@ -2378,7 +2346,7 @@
onuInd := oop.OnuIndication{}
onuInd.OperState = state
- //get the child device for the parent device
+ // get the child device for the parent device
onuDevices, err := dh.getChildDevicesFromCore(ctx, dh.device.Id)
if err != nil {
logger.Errorw(ctx, "failed-to-get-child-devices-information", log.Fields{"device-id": dh.device.Id, "err": err})
@@ -2393,10 +2361,8 @@
logger.Errorw(ctx, "failed-to-send-inter-adapter-message", log.Fields{"OnuInd": onuInd,
"From Adapter": dh.openOLT.config.AdapterEndpoint, "DeviceType": onuDevice.Type, "device-id": onuDevice.Id})
}
-
}
}
-
}
// ReenableDevice re-enables the olt device after disable
@@ -2413,9 +2379,7 @@
}
} else {
return olterrors.NewErrAdapter("olt-reenable-failed", log.Fields{"device-id": dh.device.Id}, errors.New("nil device client"))
-
}
-
logger.Debug(ctx, "olt-reenabled")
// Update the all ports state on that device to enable
@@ -2429,10 +2393,10 @@
}
}
if retError == nil {
- //Update the device oper status as ACTIVE
+ // Update the device oper status as ACTIVE
device.OperStatus = voltha.OperStatus_ACTIVE
} else {
- //Update the device oper status as FAILED
+ // Update the device oper status as FAILED
device.OperStatus = voltha.OperStatus_FAILED
}
dh.device = device
@@ -2510,7 +2474,6 @@
*/
dh.setDeviceDeletionInProgressFlag(true)
-
dh.StopAllFlowRoutines(ctx)
dh.lockDevice.RLock()
@@ -2536,13 +2499,13 @@
}
dh.removeOnuIndicationChannels(ctx)
- //Reset the state
+ // Reset the state
if dh.Client != nil {
- if _, err := dh.Client.Reboot(ctx, new(oop.Empty)); err != nil {
+ if _, err = dh.Client.Reboot(ctx, new(oop.Empty)); err != nil {
go func() {
failureReason := fmt.Sprintf("Failed to reboot during device delete request with error: %s", err.Error())
- if err = dh.eventMgr.oltRebootFailedEvent(ctx, dh.device.Id, failureReason, time.Now().Unix()); err != nil {
- logger.Errorw(ctx, "on-olt-reboot-failed", log.Fields{"device-id": dh.device.Id, "err": err})
+ if err1 := dh.eventMgr.oltRebootFailedEvent(ctx, dh.device.Id, failureReason, time.Now().Unix()); err1 != nil {
+ logger.Errorw(ctx, "on-olt-reboot-failed", log.Fields{"device-id": dh.device.Id, "err": err1})
}
}()
logger.Errorw(ctx, "olt-reboot-failed", log.Fields{"device-id": dh.device.Id, "err": err})
@@ -2641,7 +2604,6 @@
}
} else {
return olterrors.NewErrAdapter("olt-reboot-failed", log.Fields{"device-id": dh.device.Id}, errors.New("nil device client"))
-
}
logger.Debugw(ctx, "rebooted-device-successfully", log.Fields{"device-id": device.Id})
@@ -2832,7 +2794,6 @@
}
func startHeartbeatCheck(ctx context.Context, dh *DeviceHandler) {
-
defer func() {
dh.lockDevice.Lock()
dh.isHeartbeatCheckActive = false
@@ -2887,14 +2848,12 @@
}()
}
dh.lockDevice.RUnlock()
-
} else {
logger.Warn(ctx, "Heartbeat signature changed, OLT is rebooted. Cleaningup resources.")
dh.updateHeartbeatSignature(ctx, heartBeat.HeartbeatSignature)
dh.heartbeatSignature = heartBeat.HeartbeatSignature
go dh.updateStateRebooted(ctx)
}
-
}
cancel()
case <-dh.stopHeartbeatCheck:
@@ -2937,7 +2896,7 @@
}
*/
- //raise olt communication failure event
+ // raise olt communication failure event
raisedTs := time.Now().Unix()
cloned := proto.Clone(device).(*voltha.Device)
cloned.ConnectStatus = voltha.ConnectStatus_UNREACHABLE
@@ -2963,7 +2922,6 @@
}
dh.lockDevice.RUnlock()
dh.transitionMap.Handle(ctx, DeviceInit)
-
}
}
@@ -2979,7 +2937,7 @@
// Immediately return, otherwise accessing a null 'device' struct would cause panic
return
}
- //Starting the cleanup process
+ // Starting the cleanup process
dh.setDeviceDeletionInProgressFlag(true)
logger.Warnw(ctx, "update-state-rebooted", log.Fields{"device-id": dh.device.Id, "connect-status": device.ConnectStatus,
@@ -3031,10 +2989,9 @@
dh.StopAllFlowRoutines(ctx)
- //reset adapter reconcile flag
+ // reset adapter reconcile flag
dh.adapterPreviouslyConnected = false
for {
-
childDevices, err := dh.getChildDevicesFromCore(ctx, dh.device.Id)
if err != nil || childDevices == nil {
logger.Errorw(ctx, "Failed to get child devices from core", log.Fields{"deviceID": dh.device.Id})
@@ -3047,13 +3004,11 @@
logger.Warn(ctx, "Not all child devices are cleared, continuing to wait")
time.Sleep(5 * time.Second)
}
-
}
- //Cleanup completed , reset the flag
+ // Cleanup completed , reset the flag
dh.setDeviceDeletionInProgressFlag(false)
logger.Infow(ctx, "cleanup complete after reboot , moving to init", log.Fields{"deviceID": device.Id})
dh.transitionMap.Handle(ctx, DeviceInit)
-
}
// EnablePort to enable Pon interface
@@ -3186,7 +3141,7 @@
}
onu := &oop.Onu{IntfId: intfID, OnuId: onuID, SerialNumber: sn}
- //clear PON resources associated with ONU
+ // clear PON resources associated with ONU
onuGem, err := dh.resourceMgr[intfID].GetOnuGemInfo(ctx, onuID)
if err != nil || onuGem == nil || onuGem.OnuID != onuID {
logger.Warnw(ctx, "failed-to-get-onu-info-for-pon-port", log.Fields{
@@ -3202,8 +3157,8 @@
for _, gem := range onuGem.GemPorts {
if flowIDs, err := dh.resourceMgr[intfID].GetFlowIDsForGem(ctx, gem); err == nil {
for _, flowID := range flowIDs {
- //multiple gem port can have the same flow id
- //it is better to send only one flowRemove request to the agent
+ // multiple gem port can have the same flow id
+ // it is better to send only one flowRemove request to the agent
var alreadyRemoved bool
for _, removedFlowID := range removedFlows {
if removedFlowID == flowID {
@@ -3232,10 +3187,9 @@
"onu-device": onu,
"onu-gem": onuGem,
"err": err})
- //Not returning error on cleanup.
+ // Not returning error on cleanup.
}
logger.Debugw(ctx, "removed-onu-gem-info", log.Fields{"intf": intfID, "onu-device": onu, "onugem": onuGem})
-
}
dh.resourceMgr[intfID].FreeonuID(ctx, []uint32{onuID})
dh.onus.Delete(onuKey)
@@ -3364,7 +3318,7 @@
return resp, nil
}
-func (dh *DeviceHandler) getIntfIDFromFlow(ctx context.Context, flow *of.OfpFlowStats) uint32 {
+func (dh *DeviceHandler) getIntfIDFromFlow(flow *of.OfpFlowStats) uint32 {
// Default to NNI
var intfID = dh.totalPonPorts
inPort, outPort := getPorts(flow)
@@ -3374,15 +3328,15 @@
return intfID
}
-func (dh *DeviceHandler) getOnuIndicationChannel(ctx context.Context, intfID uint32) chan onuIndicationMsg {
+func (dh *DeviceHandler) getOnuIndicationChannel(intfID uint32) chan onuIndicationMsg {
dh.perPonOnuIndicationChannelLock.Lock()
if ch, ok := dh.perPonOnuIndicationChannel[intfID]; ok {
dh.perPonOnuIndicationChannelLock.Unlock()
return ch.indicationChannel
}
channels := onuIndicationChannels{
- //We create a buffered channel here to avoid calling function to be blocked
- //in case of multiple indications from the ONUs,
+ // We create a buffered channel here to avoid calling function to be blocked
+ // in case of multiple indications from the ONUs,
//especially in the case where indications are buffered in OLT.
indicationChannel: make(chan onuIndicationMsg, 500),
stopChannel: make(chan struct{}),
@@ -3391,7 +3345,6 @@
dh.perPonOnuIndicationChannelLock.Unlock()
go dh.onuIndicationsRoutine(&channels)
return channels.indicationChannel
-
}
func (dh *DeviceHandler) removeOnuIndicationChannels(ctx context.Context) {
@@ -3411,7 +3364,7 @@
}
logger.Debugw(ctx, "put-onu-indication-to-channel", log.Fields{"indication": indication, "intfID": intfID})
// Send the onuIndication on the ONU channel
- dh.getOnuIndicationChannel(ctx, intfID) <- ind
+ dh.getOnuIndicationChannel(intfID) <- ind
}
func (dh *DeviceHandler) onuIndicationsRoutine(onuChannels *onuIndicationChannels) {
@@ -3582,8 +3535,8 @@
logger.Debug(ctx, "stopped all mcast handler routines")
}
+// nolint: unparam
func (dh *DeviceHandler) getOltPortCounters(ctx context.Context, oltPortInfo *extension.GetOltPortCounters) *extension.SingleGetValueResponse {
-
singleValResp := extension.SingleGetValueResponse{
Response: &extension.GetValueResponse{
Response: &extension.GetValueResponse_PortCoutners{
@@ -3592,8 +3545,7 @@
},
}
- errResp := func(status extension.GetValueResponse_Status,
- reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
+ errResp := func(status extension.GetValueResponse_Status, reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
return &extension.SingleGetValueResponse{
Response: &extension.GetValueResponse{
Status: status,
@@ -3604,14 +3556,14 @@
if oltPortInfo.PortType != extension.GetOltPortCounters_Port_ETHERNET_NNI &&
oltPortInfo.PortType != extension.GetOltPortCounters_Port_PON_OLT {
- //send error response
+ // send error response
logger.Debugw(ctx, "getOltPortCounters invalid portType", log.Fields{"oltPortInfo": oltPortInfo.PortType})
return errResp(extension.GetValueResponse_ERROR, extension.GetValueResponse_INVALID_PORT_TYPE)
}
statIndChn := make(chan bool, 1)
dh.portStats.RegisterForStatIndication(ctx, portStatsType, statIndChn, oltPortInfo.PortNo, oltPortInfo.PortType)
defer dh.portStats.DeRegisterFromStatIndication(ctx, portStatsType, statIndChn)
- //request openOlt agent to send the the port statistics indication
+ // request openOlt agent to send the the port statistics indication
go func() {
_, err := dh.Client.CollectStatistics(ctx, new(oop.Empty))
@@ -3621,7 +3573,7 @@
}()
select {
case <-statIndChn:
- //indication received for ports stats
+ // indication received for ports stats
logger.Debugw(ctx, "getOltPortCounters recvd statIndChn", log.Fields{"oltPortInfo": oltPortInfo})
case <-time.After(oltPortInfoTimeout * time.Second):
logger.Debugw(ctx, "getOltPortCounters timeout happened", log.Fields{"oltPortInfo": oltPortInfo})
@@ -3631,24 +3583,23 @@
return errResp(extension.GetValueResponse_ERROR, extension.GetValueResponse_TIMEOUT)
}
if oltPortInfo.PortType == extension.GetOltPortCounters_Port_ETHERNET_NNI {
- //get nni stats
+ // get nni stats
intfID := plt.PortNoToIntfID(oltPortInfo.PortNo, voltha.Port_ETHERNET_NNI)
logger.Debugw(ctx, "getOltPortCounters intfID ", log.Fields{"intfID": intfID})
cmnni := dh.portStats.collectNNIMetrics(intfID)
if cmnni == nil {
- //TODO define the error reason
+ // TODO define the error reason
return errResp(extension.GetValueResponse_ERROR, extension.GetValueResponse_INTERNAL_ERROR)
}
dh.portStats.updateGetOltPortCountersResponse(ctx, &singleValResp, cmnni)
return &singleValResp
-
} else if oltPortInfo.PortType == extension.GetOltPortCounters_Port_PON_OLT {
// get pon stats
intfID := plt.PortNoToIntfID(oltPortInfo.PortNo, voltha.Port_PON_OLT)
if val, ok := dh.activePorts.Load(intfID); ok && val == true {
cmpon := dh.portStats.collectPONMetrics(intfID)
if cmpon == nil {
- //TODO define the error reason
+ // TODO define the error reason
return errResp(extension.GetValueResponse_ERROR, extension.GetValueResponse_INTERNAL_ERROR)
}
dh.portStats.updateGetOltPortCountersResponse(ctx, &singleValResp, cmpon)
@@ -3658,8 +3609,8 @@
return errResp(extension.GetValueResponse_ERROR, extension.GetValueResponse_INTERNAL_ERROR)
}
+//nolint:unparam
func (dh *DeviceHandler) getOltOffloadStats(ctx context.Context, oltPortInfo *extension.GetOffloadedAppsStatisticsRequest) *extension.SingleGetValueResponse {
-
singleValResp := extension.SingleGetValueResponse{
Response: &extension.GetValueResponse{
Status: extension.GetValueResponse_OK,
@@ -3672,8 +3623,8 @@
return &singleValResp
}
+//nolint:unparam
func (dh *DeviceHandler) setOltOffload(ctx context.Context, congig *extension.AppOffloadConfig) *extension.SingleSetValueResponse {
-
singleValResp := extension.SingleSetValueResponse{
Response: &extension.SetValueResponse{
Status: extension.SetValueResponse_OK,
@@ -3683,8 +3634,8 @@
return &singleValResp
}
+//nolint:unparam
func (dh *DeviceHandler) setOnuOffload(ctx context.Context, config *extension.AppOffloadOnuConfig) *extension.SingleSetValueResponse {
-
singleValResp := extension.SingleSetValueResponse{
Response: &extension.SetValueResponse{
Status: extension.SetValueResponse_OK,
@@ -3695,7 +3646,6 @@
}
func (dh *DeviceHandler) getOnuPonCounters(ctx context.Context, onuPonInfo *extension.GetOnuCountersRequest) *extension.SingleGetValueResponse {
-
singleValResp := extension.SingleGetValueResponse{
Response: &extension.GetValueResponse{
Response: &extension.GetValueResponse_OnuPonCounters{
@@ -3704,8 +3654,7 @@
},
}
- errResp := func(status extension.GetValueResponse_Status,
- reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
+ errResp := func(status extension.GetValueResponse_Status, reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
return &extension.SingleGetValueResponse{
Response: &extension.GetValueResponse{
Status: status,
@@ -3728,33 +3677,27 @@
}
dh.portStats.updateGetOnuPonCountersResponse(ctx, &singleValResp, cmnni)
return &singleValResp
-
}
func (dh *DeviceHandler) getOnuInfo(ctx context.Context, intfID uint32, onuID *uint32) (*oop.OnuInfo, error) {
-
Onu := oop.Onu{IntfId: intfID, OnuId: *onuID}
OnuInfo, err := dh.Client.GetOnuInfo(ctx, &Onu)
if err != nil {
return nil, err
}
return OnuInfo, nil
-
}
func (dh *DeviceHandler) getIntfInfo(ctx context.Context, intfID uint32) (*oop.PonIntfInfo, error) {
-
Intf := oop.Interface{IntfId: intfID}
IntfInfo, err := dh.Client.GetPonInterfaceInfo(ctx, &Intf)
if err != nil {
return nil, err
}
return IntfInfo, nil
-
}
func (dh *DeviceHandler) getRxPower(ctx context.Context, rxPowerRequest *extension.GetRxPowerRequest) *extension.SingleGetValueResponse {
-
Onu := oop.Onu{IntfId: rxPowerRequest.IntfId, OnuId: rxPowerRequest.OnuId}
rxPower, err := dh.Client.GetPonRxPower(ctx, &Onu)
if err != nil {
@@ -3778,9 +3721,7 @@
}
func (dh *DeviceHandler) getPONRxPower(ctx context.Context, OltRxPowerRequest *extension.GetOltRxPowerRequest) *extension.SingleGetValueResponse {
-
- errResp := func(status extension.GetValueResponse_Status,
- reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
+ errResp := func(status extension.GetValueResponse_Status, reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
return &extension.SingleGetValueResponse{
Response: &extension.GetValueResponse{
Status: status,
@@ -3816,17 +3757,13 @@
}
if serialNumber != "" {
-
onuDev := dh.getChildDevice(ctx, serialNumber, (uint32)(portNumber))
if onuDev != nil {
-
Onu := oop.Onu{IntfId: uint32(portNumber), OnuId: onuDev.onuID}
rxPower, err := dh.Client.GetPonRxPower(ctx, &Onu)
if err != nil {
-
logger.Errorw(ctx, "error-while-getting-rx-power", log.Fields{"Onu": Onu, "err": err})
return generateSingleGetValueErrorResponse(err)
-
}
rxPowerValue := extension.RxPower{}
@@ -3836,24 +3773,18 @@
rxPowerValue.FailReason = rxPower.GetFailReason().String()
resp.Response.GetOltRxPower().RxPower = append(resp.Response.GetOltRxPower().RxPower, &rxPowerValue)
-
} else {
-
logger.Errorw(ctx, "getPONRxPower invalid Device", log.Fields{"portLabel": portLabel, "serialNumber": serialNumber})
return errResp(extension.GetValueResponse_ERROR, extension.GetValueResponse_INVALID_DEVICE)
}
-
} else {
-
dh.onus.Range(func(Onukey interface{}, onuInCache interface{}) bool {
if onuInCache.(*OnuDevice).intfID == (uint32)(portNumber) {
-
Onu := oop.Onu{IntfId: (uint32)(portNumber), OnuId: onuInCache.(*OnuDevice).onuID}
rxPower, err := dh.Client.GetPonRxPower(ctx, &Onu)
if err != nil {
logger.Errorw(ctx, "error-while-getting-rx-power, however considering to proceed further with other ONUs on PON", log.Fields{"Onu": Onu, "err": err})
} else {
-
rxPowerValue := extension.RxPower{}
rxPowerValue.OnuSn = onuInCache.(*OnuDevice).serialNumber
rxPowerValue.Status = rxPower.GetStatus()
@@ -3862,7 +3793,6 @@
resp.Response.GetOltRxPower().RxPower = append(resp.Response.GetOltRxPower().RxPower, &rxPowerValue)
}
-
}
logger.Infow(ctx, "getPONRxPower response ", log.Fields{"Response": resp})
return true
@@ -3872,9 +3802,9 @@
return &resp
}
+// nolint: unparam
func generateSingleGetValueErrorResponse(err error) *extension.SingleGetValueResponse {
- errResp := func(status extension.GetValueResponse_Status,
- reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
+ errResp := func(status extension.GetValueResponse_Status, reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
return &extension.SingleGetValueResponse{
Response: &extension.GetValueResponse{
Status: status,
@@ -4161,7 +4091,6 @@
}
func (dh *DeviceHandler) getChildAdapterServiceClient(endpoint string) (onu_inter_adapter_service.OnuInterAdapterServiceClient, error) {
-
// First check from cache
dh.lockChildAdapterClients.RLock()
if cgClient, ok := dh.childAdapterClients[endpoint]; ok {