File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ type ConvergeState struct {
1616 Activation string
1717 CRDsEnsured bool
1818
19+ onConvergeStart func ()
20+ onConvergeFinish func ()
21+
1922 phaseMu sync.RWMutex
2023 phase ConvergePhase
2124 firstRunPhase FirstConvergePhase
@@ -29,6 +32,7 @@ const (
2932 WaitBeforeAll ConvergePhase = "WaitBeforeAll"
3033 WaitDeleteAndRunModules ConvergePhase = "WaitDeleteAndRunModules"
3134 WaitAfterAll ConvergePhase = "WaitAfterAll"
35+ Finished ConvergePhase = "Finished"
3236)
3337
3438type FirstConvergePhase int
@@ -47,6 +51,14 @@ func NewConvergeState() *ConvergeState {
4751 }
4852}
4953
54+ func (cs * ConvergeState ) SetOnConvergeStart (callback func ()) {
55+ cs .onConvergeStart = callback
56+ }
57+
58+ func (cs * ConvergeState ) SetOnConvergeFinish (callback func ()) {
59+ cs .onConvergeFinish = callback
60+ }
61+
5062func (cs * ConvergeState ) SetFirstRunPhase (ph FirstConvergePhase ) {
5163 cs .phaseMu .Lock ()
5264 defer cs .phaseMu .Unlock ()
@@ -66,6 +78,14 @@ func (cs *ConvergeState) SetPhase(ph ConvergePhase) {
6678 cs .phaseMu .Lock ()
6779 defer cs .phaseMu .Unlock ()
6880 cs .phase = ph
81+
82+ if ph == RunBeforeAll && cs .onConvergeStart != nil {
83+ cs .onConvergeStart ()
84+ }
85+
86+ if ph == StandBy && cs .onConvergeFinish != nil {
87+ cs .onConvergeFinish ()
88+ }
6989}
7090
7191func (cs * ConvergeState ) GetPhase () ConvergePhase {
Original file line number Diff line number Diff line change @@ -105,6 +105,18 @@ func WithLogger(logger *log.Logger) Option {
105105 }
106106}
107107
108+ func WithOnConvergeStart (callback func ()) Option {
109+ return func (operator * AddonOperator ) {
110+ operator .ConvergeState .SetOnConvergeStart (callback )
111+ }
112+ }
113+
114+ func WithOnConvergeFinish (callback func ()) Option {
115+ return func (operator * AddonOperator ) {
116+ operator .ConvergeState .SetOnConvergeFinish (callback )
117+ }
118+ }
119+
108120func NewAddonOperator (ctx context.Context , opts ... Option ) * AddonOperator {
109121 cctx , cancel := context .WithCancel (ctx )
110122
@@ -657,7 +669,7 @@ func (op *AddonOperator) CreateAndStartQueuesForModuleHooks(moduleName string) {
657669 // log.Debugf("Queue '%s' started for module 'kubernetes' hook %s", hookBinding.Queue, hookName)
658670 // }
659671 // }
660- //}
672+ // }
661673}
662674
663675func (op * AddonOperator ) CreateReloadModulesTasks (moduleNames []string , logLabels map [string ]string , eventDescription string ) []sh_task.Task {
You can’t perform that action at this time.
0 commit comments