Skip to content

Commit 3cdedd7

Browse files
authored
set ModulesInited after first graph calculation (#503)
Signed-off-by: Mikhail Scherba <mikhail.scherba@flant.com>
1 parent dc1785d commit 3cdedd7

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

pkg/module_manager/module_manager.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ type ModuleManager struct {
124124
moduleScheduler *scheduler.Scheduler
125125
}
126126

127+
var once sync.Once
128+
127129
// NewModuleManager returns new MainModuleManager
128130
func NewModuleManager(ctx context.Context, cfg *ModuleManagerConfig) *ModuleManager {
129131
cctx, cancel := context.WithCancel(ctx)
@@ -421,6 +423,7 @@ func (mm *ModuleManager) RefreshEnabledState(logLabels map[string]string) (*Modu
421423
}
422424

423425
logEntry.Infof("Enabled modules: %+v", enabledModules)
426+
once.Do(mm.modules.SetInited)
424427

425428
var (
426429
modulesToEnable []string
@@ -818,16 +821,13 @@ func (mm *ModuleManager) applyEnabledPatch(enabledPatch utils.ValuesPatch, exten
818821
// RecalculateGraph runs corresponding scheduler method that returns true if the graph's state has changed
819822
func (mm *ModuleManager) RecalculateGraph(logLabels map[string]string) bool {
820823
stateChanged, verticesToUpdate := mm.moduleScheduler.RecalculateGraph(logLabels)
821-
if stateChanged {
822-
return true
823-
}
824824
for _, module := range verticesToUpdate {
825825
mm.SendModuleEvent(events.ModuleEvent{
826826
ModuleName: module,
827827
EventType: events.ModuleStateChanged,
828828
})
829829
}
830-
return false
830+
return stateChanged
831831
}
832832

833833
// GlobalSynchronizationNeeded is true if there is at least one global
@@ -1230,7 +1230,6 @@ func (mm *ModuleManager) registerModules(scriptEnabledExtender *script_extender.
12301230
log.Debugf("Found modules: %v", set.NamesInOrder())
12311231

12321232
mm.modules = set
1233-
mm.modules.SetInited()
12341233

12351234
return nil
12361235
}

pkg/module_manager/scheduler/scheduler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ func (s *Scheduler) Filter(extName extenders.ExtenderName, moduleName string, lo
442442
// It returns:
443443
// - true if the state of any vertex has changed (enabled/disabled) or there were any errors during the run;
444444
// - true if some other parameters, apart from state, of a vertex has changed.
445-
func (s *Scheduler) recalculateGraphState(logLabels map[string]string) ( /* Graph's state has changed */ bool /* list of updated vertices */, []string) {
445+
func (s *Scheduler) recalculateGraphState(logLabels map[string]string) ( /* Graph's state has changed */ bool /* list of the vertices, which updateBy status have changed */, []string) {
446446
diff, updByDiff := make(map[string]bool), make([]string, 0)
447447
errList := make([]string, 0)
448448
enabledModules := make([]string, 0)

0 commit comments

Comments
 (0)