Skip to content

Commit

Permalink
Adding some magic
Browse files Browse the repository at this point in the history
  • Loading branch information
ljakimczuk committed Oct 23, 2024
1 parent 02ca2ba commit 343462b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions service/controller/chart/resource/release/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,25 +400,31 @@ func (r *Resource) tryRecoverFromPending(ctx context.Context, cr v1alpha1.Chart,

rel, err := store.Last(rs.Name)
if err != nil {
r.logger.Debugf(ctx, "Encountered error on getting last revision for release %#q", rs.Name)
r.logger.Debugf(ctx, "encountered error on getting last revision for release %#q", rs.Name)
return
}

timeout := getTimeout(cr, rel.Version)

if time.Since(rel.Info.LastDeployed.Time) < (*timeout).Duration {
r.logger.Debugf(ctx, "Timeout has not elapsed yet for release %#q, skipping recevery", rs.Name)
r.logger.Debugf(ctx, "timeout has not elapsed yet for release %#q, skipping recevery", rs.Name)
return
}

rel.SetStatus(release.StatusUnknown, "Chart Operator has been restarted when performing Helm operation")
status := release.StatusUnknown
if rel.Version == 1 {
status = release.StatusFailed
}
rel.SetStatus(status, "chart Operator has been restarted when performing Helm operation")
err = store.Update(rel)
if err != nil {
r.logger.Debugf(ctx, "Encountered error on updating status for release %#q", rs.Name)
r.logger.Debugf(ctx, "encountered error on updating status for release %#q", rs.Name)
return
}

rs.Status = string(release.StatusUnknown)

r.logger.Debugf(ctx, "recovered from `pending` status for release %#q", rs.Name)
}

func getTimeout(cr v1alpha1.Chart, rev int) *metav1.Duration {
Expand Down

0 comments on commit 343462b

Please sign in to comment.