fix: prevent concurrent jobs map writes by adding synchronization

This fix prevents undefined behavior and runtime crashes in multithreaded
use cases.
This commit is contained in:
2024-12-13 20:11:58 +03:30
parent 02d8f0b02e
commit 9f36dca7c9
3 changed files with 52 additions and 7 deletions

View File

@@ -42,7 +42,7 @@ func (crd *Crd) Patch(jobUid types.UID, patchData map[string]interface{}) error
if err != nil {
pkg.Logger.Error("[crd] [status] error in structure unstructured patched", zap.Error(err))
}
jobs[jobUid] = newJob
jobs.Store(jobUid, newJob)
if err != nil {
pkg.Logger.Error("[crd] [status] ", zap.Error(err))
return err