Skip to content

Commit

Permalink
[ws-manager] Only calculate the restore success/failure counter if it…
Browse files Browse the repository at this point in the history
…'s restoring from the Backup or VolumeSnapshot

Signed-off-by: JenTing Hsiao <[email protected]>
  • Loading branch information
jenting authored and roboquat committed Jun 14, 2022
1 parent 7bf63df commit 6262677
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions components/ws-manager/pkg/manager/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,22 +786,28 @@ func (m *Monitor) initializeWorkspaceContent(ctx context.Context, pod *corev1.Po
hist.Observe(time.Since(t).Seconds())
}

_, isBackup := initializer.Spec.(*csapi.WorkspaceInitializer_Backup)

if err != nil {
c, cErr := m.manager.metrics.totalRestoreFailureCounterVec.GetMetricWithLabelValues(wsType, wsClass)
if cErr != nil {
log.WithError(cErr).WithField("type", wsType).Warn("cannot get counter for workspace restore failure counter")
} else {
c.Inc()
if isBackup {
c, cErr := m.manager.metrics.totalRestoreFailureCounterVec.GetMetricWithLabelValues(wsType, wsClass)
if cErr != nil {
log.WithError(cErr).WithField("type", wsType).Warn("cannot get counter for workspace restore failure counter")
} else {
c.Inc()
}
}

return xerrors.Errorf("cannot initialize workspace: %w", err)
}

c, cErr := m.manager.metrics.totalRestoreSuccessCounterVec.GetMetricWithLabelValues(wsType, wsClass)
if cErr != nil {
log.WithError(cErr).WithField("type", wsType).Warn("cannot get counter for workspace restore success counter")
} else {
c.Inc()
if isBackup {
c, cErr := m.manager.metrics.totalRestoreSuccessCounterVec.GetMetricWithLabelValues(wsType, wsClass)
if cErr != nil {
log.WithError(cErr).WithField("type", wsType).Warn("cannot get counter for workspace restore success counter")
} else {
c.Inc()
}
}
return nil
}
Expand Down

0 comments on commit 6262677

Please sign in to comment.