fix concurrency issue (#742)
Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
		
							parent
							
								
									2d9f83c1de
								
							
						
					
					
						commit
						063ba86447
					
				|  | @ -1098,7 +1098,9 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre | |||
| 
 | ||||
| 	releases := releasesNeedCharts(selected) | ||||
| 
 | ||||
| 	temp := make(map[PrepareChartKey]string, len(releases)) | ||||
| 	var prepareChartInfoMutex sync.Mutex | ||||
| 
 | ||||
| 	prepareChartInfo := make(map[PrepareChartKey]string, len(releases)) | ||||
| 
 | ||||
| 	errs := []error{} | ||||
| 
 | ||||
|  | @ -1302,11 +1304,15 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre | |||
| 
 | ||||
| 					return | ||||
| 				} | ||||
| 				temp[PrepareChartKey{ | ||||
| 					Namespace:   downloadRes.releaseNamespace, | ||||
| 					KubeContext: downloadRes.releaseContext, | ||||
| 					Name:        downloadRes.releaseName, | ||||
| 				}] = downloadRes.chartPath | ||||
| 				func() { | ||||
| 					prepareChartInfoMutex.Lock() | ||||
| 					defer prepareChartInfoMutex.Unlock() | ||||
| 					prepareChartInfo[PrepareChartKey{ | ||||
| 						Namespace:   downloadRes.releaseNamespace, | ||||
| 						KubeContext: downloadRes.releaseContext, | ||||
| 						Name:        downloadRes.releaseName, | ||||
| 					}] = downloadRes.chartPath | ||||
| 				}() | ||||
| 
 | ||||
| 				if downloadRes.buildDeps { | ||||
| 					builds = append(builds, downloadRes) | ||||
|  | @ -1325,7 +1331,7 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre | |||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	return temp, nil | ||||
| 	return prepareChartInfo, nil | ||||
| } | ||||
| 
 | ||||
| // nolint: unparam
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue