[VOL-3786] Support configuration of mib data sync audit via helm charts
Change-Id: I1a4e5abfc9023b3b364849a0ac734e802e51edc8
diff --git a/VERSION b/VERSION
index 7c48a4c..6085e94 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.2.1-dev161
+1.2.1
diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go
index 5e76275..628c689 100644
--- a/internal/pkg/config/config.go
+++ b/internal/pkg/config/config.go
@@ -61,7 +61,8 @@
defaultTraceAgentAddress = "127.0.0.1:6831"
defaultLogCorrelationEnabled = true
- defaultMetricsEnabled = false
+ defaultMetricsEnabled = false
+ defaultMibAuditInterval = 0
)
// AdapterFlags represents the set of configurations used by the read-write adaptercore service
@@ -96,6 +97,7 @@
LogCorrelationEnabled bool
OnuVendorIds string
MetricsEnabled bool
+ MibAuditInterval time.Duration
}
// NewAdapterFlags returns a new RWCore config
@@ -130,6 +132,7 @@
LogCorrelationEnabled: defaultLogCorrelationEnabled,
OnuVendorIds: defaultOnuVendorIds,
MetricsEnabled: defaultMetricsEnabled,
+ MibAuditInterval: defaultMibAuditInterval,
}
return &adapterFlags
}
@@ -222,6 +225,9 @@
help = fmt.Sprintf("Whether to enable metrics collection")
flag.BoolVar(&(so.MetricsEnabled), "metrics_enabled", defaultMetricsEnabled, help)
+ help = fmt.Sprintf("Mib Audit Interval in seconds - the value zero will disable Mib Audit")
+ flag.DurationVar(&(so.MibAuditInterval), "mib_audit_interval", defaultMibAuditInterval, help)
+
flag.Parse()
containerName := getContainerInfo()
if len(containerName) > 0 {
diff --git a/internal/pkg/onuadaptercore/mib_sync.go b/internal/pkg/onuadaptercore/mib_sync.go
index 9e1a6a5..c3e194e 100644
--- a/internal/pkg/onuadaptercore/mib_sync.go
+++ b/internal/pkg/onuadaptercore/mib_sync.go
@@ -234,10 +234,10 @@
func (oo *OnuDeviceEntry) enterInSyncState(ctx context.Context, e *fsm.Event) {
oo.sOnuPersistentData.PersMibLastDbSync = uint32(time.Now().Unix())
- if oo.mibAuditDelay > 0 {
- logger.Debugw(ctx, "MibSync FSM", log.Fields{"trigger next Audit in State": e.FSM.Current(), "oo.mibAuditDelay": oo.mibAuditDelay, "device-id": oo.deviceID})
+ if oo.mibAuditInterval > 0 {
+ logger.Debugw(ctx, "MibSync FSM", log.Fields{"trigger next Audit in State": e.FSM.Current(), "oo.mibAuditInterval": oo.mibAuditInterval, "device-id": oo.deviceID})
go func() {
- time.Sleep(time.Duration(oo.mibAuditDelay) * time.Second)
+ time.Sleep(oo.mibAuditInterval)
if err := oo.pMibUploadFsm.pFsm.Event(ulEvAuditMib); err != nil {
logger.Debugw(ctx, "MibSyncFsm: Can't go to state auditing", log.Fields{"device-id": oo.deviceID, "err": err})
}
diff --git a/internal/pkg/onuadaptercore/onu_device_entry.go b/internal/pkg/onuadaptercore/onu_device_entry.go
index 37d16fe..b65b055 100644
--- a/internal/pkg/onuadaptercore/onu_device_entry.go
+++ b/internal/pkg/onuadaptercore/onu_device_entry.go
@@ -156,7 +156,7 @@
type activityDescr struct {
databaseClass func(context.Context) error
//advertiseEvents bool
- auditDelay uint16
+ auditInterval time.Duration
//tasks map[string]func() error
}
@@ -215,17 +215,17 @@
}
type onuPersistentData struct {
- PersOnuID uint32 `json:"onu_id"`
- PersIntfID uint32 `json:"intf_id"`
- PersSnr string `json:"serial_number"`
- PersAdminState string `json:"admin_state"`
- PersOperState string `json:"oper_state"`
- PersUniUnlockDone bool `json:"uni_unlock_done"`
- PersUniDisableDone bool `json:"uni_disable_done"`
- PersMibAuditDelay uint16 `json:"mib_audit_delay"`
- PersMibLastDbSync uint32 `json:"mib_last_db_sync"`
- PersMibDataSyncAdpt uint8 `json:"mib_data_sync_adpt"`
- PersUniConfig []uniPersConfig `json:"uni_config"`
+ PersOnuID uint32 `json:"onu_id"`
+ PersIntfID uint32 `json:"intf_id"`
+ PersSnr string `json:"serial_number"`
+ PersAdminState string `json:"admin_state"`
+ PersOperState string `json:"oper_state"`
+ PersUniUnlockDone bool `json:"uni_unlock_done"`
+ PersUniDisableDone bool `json:"uni_disable_done"`
+ PersMibAuditInterval time.Duration `json:"mib_audit_interval"`
+ PersMibLastDbSync uint32 `json:"mib_last_db_sync"`
+ PersMibDataSyncAdpt uint8 `json:"mib_data_sync_adpt"`
+ PersUniConfig []uniPersConfig `json:"uni_config"`
}
// OnuDeviceEntry - ONU device info and FSM events.
@@ -256,7 +256,7 @@
supportedFsms OmciDeviceFsms
devState OnuDeviceEvent
// Audit and MDS
- mibAuditDelay uint16
+ mibAuditInterval time.Duration
// TODO: periodical mib resync will be implemented with story VOL-3792
//mibNextDbResync uint32
@@ -300,7 +300,7 @@
//mibSyncFsm, // Implements the MIB synchronization state machine
onuDeviceEntry.mibDbVolatileDict, // Implements volatile ME MIB database
//true, // Advertise events on OpenOMCI event bus
- 0, // Time to wait between MIB audits. 0 to disable audits.
+ dh.pOpenOnuAc.mibAuditInterval, // Time to wait between MIB audits. 0 to disable audits.
// map[string]func() error{
// "mib-upload": onuDeviceEntry.MibUploadTask,
// "mib-template": onuDeviceEntry.MibTemplateTask,
@@ -316,15 +316,15 @@
logger.Debug(ctx, "access2mibDbClass")
go onuDeviceEntry.mibDbClass(ctx)
if !dh.reconciling {
- onuDeviceEntry.mibAuditDelay = onuDeviceEntry.supportedFsms["mib-synchronizer"].auditDelay
- onuDeviceEntry.sOnuPersistentData.PersMibAuditDelay = onuDeviceEntry.mibAuditDelay
+ onuDeviceEntry.mibAuditInterval = onuDeviceEntry.supportedFsms["mib-synchronizer"].auditInterval
+ onuDeviceEntry.sOnuPersistentData.PersMibAuditInterval = onuDeviceEntry.mibAuditInterval
} else {
- logger.Debugw(ctx, "reconciling - take audit delay from persistent data", log.Fields{"device-id": dh.deviceID})
- // TODO: This is a preparation for VOL-3786 to preserve config history in case of
+ logger.Debugw(ctx, "reconciling - take audit interval from persistent data", log.Fields{"device-id": dh.deviceID})
+ // TODO: This is a preparation for VOL-VOL-3811 to preserve config history in case of
// vendor- or deviceID-specific configurations via voltctl-commands
- onuDeviceEntry.mibAuditDelay = onuDeviceEntry.sOnuPersistentData.PersMibAuditDelay
+ onuDeviceEntry.mibAuditInterval = onuDeviceEntry.sOnuPersistentData.PersMibAuditInterval
}
- logger.Debugw(ctx, "MibAudit is set to", log.Fields{"Delay": onuDeviceEntry.mibAuditDelay})
+ logger.Debugw(ctx, "MibAudit is set to", log.Fields{"Interval": onuDeviceEntry.mibAuditInterval})
// TODO: periodical mib resync will be implemented with story VOL-3792
//onuDeviceEntry.mibNextDbResync = 0
@@ -562,7 +562,7 @@
logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
return fmt.Errorf(fmt.Sprintf("onuKVStore-not-set-abort-%s", oo.deviceID))
}
- oo.sOnuPersistentData = onuPersistentData{0, 0, "", "", "", false, false, oo.mibAuditDelay, 0, 0, make([]uniPersConfig, 0)}
+ oo.sOnuPersistentData = onuPersistentData{0, 0, "", "", "", false, false, oo.mibAuditInterval, 0, 0, make([]uniPersConfig, 0)}
Value, err := oo.onuKVStore.Get(ctx, oo.onuKVStorePath)
if err == nil {
if Value != nil {
@@ -608,8 +608,8 @@
func (oo *OnuDeviceEntry) deletePersistentData(ctx context.Context, aProcessingStep uint8) {
logger.Debugw(ctx, "delete and clear internal persistency data", log.Fields{"device-id": oo.deviceID})
- oo.sOnuPersistentData.PersUniConfig = nil //releasing all UniConfig entries to garbage collector
- oo.sOnuPersistentData = onuPersistentData{0, 0, "", "", "", false, false, oo.mibAuditDelay, 0, 0, make([]uniPersConfig, 0)} //default entry
+ oo.sOnuPersistentData.PersUniConfig = nil //releasing all UniConfig entries to garbage collector
+ oo.sOnuPersistentData = onuPersistentData{0, 0, "", "", "", false, false, oo.mibAuditInterval, 0, 0, make([]uniPersConfig, 0)} //default entry
logger.Debugw(ctx, "delete ONU-data from KVStore", log.Fields{"device-id": oo.deviceID})
err := oo.onuKVStore.Delete(ctx, oo.onuKVStorePath)
diff --git a/internal/pkg/onuadaptercore/openonu.go b/internal/pkg/onuadaptercore/openonu.go
index 1eeac1a..7bc9936 100644
--- a/internal/pkg/onuadaptercore/openonu.go
+++ b/internal/pkg/onuadaptercore/openonu.go
@@ -68,6 +68,7 @@
maxTimeoutInterAdapterComm time.Duration
pDownloadManager *adapterDownloadManager
metricsEnabled bool
+ mibAuditInterval time.Duration
}
//NewOpenONUAC returns a new instance of OpenONU_AC
@@ -98,14 +99,14 @@
openOnuAc.maxTimeoutInterAdapterComm = cfg.MaxTimeoutInterAdapterComm
//openOnuAc.GrpcTimeoutInterval = cfg.GrpcTimeoutInterval
openOnuAc.metricsEnabled = cfg.MetricsEnabled
+ openOnuAc.mibAuditInterval = cfg.MibAuditInterval
openOnuAc.pSupportedFsms = &OmciDeviceFsms{
"mib-synchronizer": {
//mibSyncFsm, // Implements the MIB synchronization state machine
mibDbVolatileDictImpl, // Implements volatile ME MIB database
//true, // Advertise events on OpenOMCI event bus
- //TODO: audit delay should come from command parameters configured via helm charts (covered by VOL-3786)
- cMibAuditDelayImpl, // Time to wait between MIB audits. 0 to disable audits.
+ openOnuAc.mibAuditInterval, // Time to wait between MIB audits. 0 to disable audits.
// map[string]func() error{
// "mib-upload": onuDeviceEntry.MibUploadTask,
// "mib-template": onuDeviceEntry.MibTemplateTask,
diff --git a/internal/pkg/onuadaptercore/openonuimpl.go b/internal/pkg/onuadaptercore/openonuimpl.go
index 6250a03..1230a01 100644
--- a/internal/pkg/onuadaptercore/openonuimpl.go
+++ b/internal/pkg/onuadaptercore/openonuimpl.go
@@ -86,10 +86,6 @@
}
*/
-// mib audit is deactivated by default - story planned to make it configurable:
-// TODO: VOL-3786 - Support configuration of mib data sync audit via helm charts and voltctl commands
-const cMibAuditDelayImpl = 0
-
//suppose global methods per adapter ...
func mibDbVolatileDictImpl(ctx context.Context) error {
logger.Debug(ctx, "MibVolatileDict-called")