Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions pkg/addon-operator/converge/converge.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ type ConvergeState struct {
Activation string
CRDsEnsured bool

onConvergeStart func()
onConvergeFinish func()

phaseMu sync.RWMutex
phase ConvergePhase
firstRunPhase FirstConvergePhase
Expand Down Expand Up @@ -47,6 +50,14 @@ func NewConvergeState() *ConvergeState {
}
}

func (cs *ConvergeState) SetOnConvergeStart(callback func()) {
cs.onConvergeStart = callback
}

func (cs *ConvergeState) SetOnConvergeFinish(callback func()) {
cs.onConvergeFinish = callback
}

func (cs *ConvergeState) SetFirstRunPhase(ph FirstConvergePhase) {
cs.phaseMu.Lock()
defer cs.phaseMu.Unlock()
Expand All @@ -66,6 +77,14 @@ func (cs *ConvergeState) SetPhase(ph ConvergePhase) {
cs.phaseMu.Lock()
defer cs.phaseMu.Unlock()
cs.phase = ph

if ph == RunBeforeAll && cs.onConvergeStart != nil {
cs.onConvergeStart()
}

if ph == StandBy && cs.onConvergeFinish != nil {
cs.onConvergeFinish()
}
}

func (cs *ConvergeState) GetPhase() ConvergePhase {
Expand Down
14 changes: 13 additions & 1 deletion pkg/addon-operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ func WithLogger(logger *log.Logger) Option {
}
}

func WithOnConvergeStart(callback func()) Option {
return func(operator *AddonOperator) {
operator.ConvergeState.SetOnConvergeStart(callback)
}
}

func WithOnConvergeFinish(callback func()) Option {
return func(operator *AddonOperator) {
operator.ConvergeState.SetOnConvergeFinish(callback)
}
}

func NewAddonOperator(ctx context.Context, opts ...Option) *AddonOperator {
cctx, cancel := context.WithCancel(ctx)

Expand Down Expand Up @@ -657,7 +669,7 @@ func (op *AddonOperator) CreateAndStartQueuesForModuleHooks(moduleName string) {
// log.Debugf("Queue '%s' started for module 'kubernetes' hook %s", hookBinding.Queue, hookName)
// }
// }
//}
// }
}

func (op *AddonOperator) CreateReloadModulesTasks(moduleNames []string, logLabels map[string]string, eventDescription string) []sh_task.Task {
Expand Down
Loading