Skip to content

Commit b67f5a8

Browse files
committed
fix race
Signed-off-by: Mikhail Scherba <mikhail.scherba@flant.com>
1 parent fbe2e66 commit b67f5a8

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/dominikbraun/graph v0.23.0
1010
github.com/ettle/strcase v0.2.0
1111
github.com/flant/kube-client v1.2.2
12-
github.com/flant/shell-operator v1.5.4-0.20250218103902-153e6952772d
12+
github.com/flant/shell-operator v1.5.4-0.20250219083821-5782d5984178
1313
github.com/go-chi/chi/v5 v5.2.1
1414
github.com/go-openapi/loads v0.19.5
1515
github.com/go-openapi/spec v0.19.8

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ github.com/flant/kube-client v1.2.2 h1:27LBs+PKJEFnkQXjPU9eIps7a7iyI13AKcSYj897D
138138
github.com/flant/kube-client v1.2.2/go.mod h1:eMa3aJ6V1PRWSQ/RCROkObDpY4S74uM84SJS4G/LINg=
139139
github.com/flant/libjq-go v1.6.3-0.20201126171326-c46a40ff22ee h1:evii83J+/6QGNvyf6tjQ/p27DPY9iftxIBb37ALJRTg=
140140
github.com/flant/libjq-go v1.6.3-0.20201126171326-c46a40ff22ee/go.mod h1:f+REaGl/+pZR97rbTcwHEka/MAipoQQ2Mc0iQUj4ak0=
141-
github.com/flant/shell-operator v1.5.4-0.20250218103902-153e6952772d h1:BKrxOl5I38R4b/u2Kdh+YoiSzrIvi1+tg9HrJOtBaOQ=
142-
github.com/flant/shell-operator v1.5.4-0.20250218103902-153e6952772d/go.mod h1:vfhZxDVSb/v+e8+roBtz+oe8mqahvizfIPCzhFq/7HE=
141+
github.com/flant/shell-operator v1.5.4-0.20250219083821-5782d5984178 h1:jtkt2vpcKjrIt+I0+hOPZr4aFadwvK8Hb/V2nSRuCOI=
142+
github.com/flant/shell-operator v1.5.4-0.20250219083821-5782d5984178/go.mod h1:vfhZxDVSb/v+e8+roBtz+oe8mqahvizfIPCzhFq/7HE=
143143
github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8=
144144
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
145145
github.com/foxcpp/go-mockdns v1.0.0 h1:7jBqxd3WDWwi/6WhDvacvH1XsN3rOLXyHM1uhvIx6FI=

pkg/addon-operator/operator.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ type AddonOperator struct {
8282
// HelmResourcesManager monitors absent resources created for modules.
8383
HelmResourcesManager helm_resources_manager.HelmResourcesManager
8484

85-
// converge state
86-
ConvergeState *converge.ConvergeState
87-
8885
// Initial KubeConfig to bypass initial loading from the ConfigMap.
8986
InitialKubeConfig *config.KubeConfig
9087

@@ -105,6 +102,10 @@ type AddonOperator struct {
105102
discoveredGVKs map[string]struct{}
106103

107104
Logger *log.Logger
105+
106+
l sync.Mutex
107+
// converge state
108+
ConvergeState *converge.ConvergeState
108109
}
109110

110111
type parallelQueueEvent struct {
@@ -2688,6 +2689,7 @@ func (op *AddonOperator) CheckCRDsEnsured(t sh_task.Task) {
26882689
func (op *AddonOperator) CheckConvergeStatus(t sh_task.Task) {
26892690
convergeTasks := ConvergeTasksInQueue(op.engine.TaskQueues.GetMain())
26902691

2692+
op.l.Lock()
26912693
// Converge state is 'Started'. Update StartedAt and
26922694
// Activation if the converge process is just started.
26932695
if convergeTasks > 0 && op.ConvergeState.StartedAt == 0 {
@@ -2707,6 +2709,7 @@ func (op *AddonOperator) CheckConvergeStatus(t sh_task.Task) {
27072709

27082710
// Update field for the first converge.
27092711
op.UpdateFirstConvergeStatus(convergeTasks)
2712+
op.l.Unlock()
27102713

27112714
// Report modules left to process.
27122715
if convergeTasks > 0 && (t.GetType() == task.ModuleRun || t.GetType() == task.ModuleDelete) {

0 commit comments

Comments
 (0)