Skip to content

Commit

Permalink
fix(nelm): --status-progress-period=-1 panics
Browse files Browse the repository at this point in the history
Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
  • Loading branch information
ilya-lesikov committed Mar 29, 2024
1 parent b9fbb49 commit aa152f6
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions cmd/werf/converge/converge.go
Expand Up @@ -528,7 +528,13 @@ func run(ctx context.Context, containerBackend container_backend.ContainerBacken

trackReadinessTimeout := *common.NewDuration(time.Duration(cmdData.Timeout) * time.Second)
trackDeletionTimeout := trackReadinessTimeout
showResourceProgressPeriod := time.Duration(*commonCmdData.StatusProgressPeriodSeconds) * time.Second
showResourceProgress := *commonCmdData.StatusProgressPeriodSeconds != -1
showResourceProgressPeriod := time.Duration(
lo.Max([]int64{
*commonCmdData.StatusProgressPeriodSeconds,
int64(1),
}),
) * time.Second
saveDeployReport := common.GetSaveDeployReport(&commonCmdData)
deployReportPath, err := common.GetDeployReportPath(&commonCmdData)
if err != nil {
Expand Down Expand Up @@ -770,23 +776,26 @@ func run(ctx context.Context, containerBackend container_backend.ContainerBacken
log.Default.Info(ctx, "Starting tracking")
stdoutTrackerStopCh := make(chan bool)
stdoutTrackerFinishedCh := make(chan bool)
go func() {
ticker := time.NewTicker(showResourceProgressPeriod)
defer func() {
ticker.Stop()
stdoutTrackerFinishedCh <- true
}()

for {
select {
case <-ticker.C:
printTables(ctx, tablesBuilder)
case <-stdoutTrackerStopCh:
printTables(ctx, tablesBuilder)
return
if showResourceProgress {
go func() {
ticker := time.NewTicker(showResourceProgressPeriod)
defer func() {
ticker.Stop()
stdoutTrackerFinishedCh <- true
}()

for {
select {
case <-ticker.C:
printTables(ctx, tablesBuilder)
case <-stdoutTrackerStopCh:
printTables(ctx, tablesBuilder)
return
}
}
}
}()
}()
}

log.Default.Info(ctx, "Executing deploy plan")
planExecutor := plnexectr.NewPlanExecutor(plan, plnexectr.PlanExecutorOptions{
Expand Down Expand Up @@ -878,8 +887,10 @@ func run(ctx context.Context, containerBackend container_backend.ContainerBacken
}
}

stdoutTrackerStopCh <- true
<-stdoutTrackerFinishedCh
if showResourceProgress {
stdoutTrackerStopCh <- true
<-stdoutTrackerFinishedCh
}

report := reprt.NewReport(
worthyCompletedOps,
Expand Down

0 comments on commit aa152f6

Please sign in to comment.