Skip to content

Commit 6262677

Browse files
jentingroboquat
authored andcommitted
[ws-manager] Only calculate the restore success/failure counter if it's restoring from the Backup or VolumeSnapshot
Signed-off-by: JenTing Hsiao <[email protected]>
1 parent 7bf63df commit 6262677

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

components/ws-manager/pkg/manager/monitor.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -786,22 +786,28 @@ func (m *Monitor) initializeWorkspaceContent(ctx context.Context, pod *corev1.Po
786786
hist.Observe(time.Since(t).Seconds())
787787
}
788788

789+
_, isBackup := initializer.Spec.(*csapi.WorkspaceInitializer_Backup)
790+
789791
if err != nil {
790-
c, cErr := m.manager.metrics.totalRestoreFailureCounterVec.GetMetricWithLabelValues(wsType, wsClass)
791-
if cErr != nil {
792-
log.WithError(cErr).WithField("type", wsType).Warn("cannot get counter for workspace restore failure counter")
793-
} else {
794-
c.Inc()
792+
if isBackup {
793+
c, cErr := m.manager.metrics.totalRestoreFailureCounterVec.GetMetricWithLabelValues(wsType, wsClass)
794+
if cErr != nil {
795+
log.WithError(cErr).WithField("type", wsType).Warn("cannot get counter for workspace restore failure counter")
796+
} else {
797+
c.Inc()
798+
}
795799
}
796800

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

800-
c, cErr := m.manager.metrics.totalRestoreSuccessCounterVec.GetMetricWithLabelValues(wsType, wsClass)
801-
if cErr != nil {
802-
log.WithError(cErr).WithField("type", wsType).Warn("cannot get counter for workspace restore success counter")
803-
} else {
804-
c.Inc()
804+
if isBackup {
805+
c, cErr := m.manager.metrics.totalRestoreSuccessCounterVec.GetMetricWithLabelValues(wsType, wsClass)
806+
if cErr != nil {
807+
log.WithError(cErr).WithField("type", wsType).Warn("cannot get counter for workspace restore success counter")
808+
} else {
809+
c.Inc()
810+
}
805811
}
806812
return nil
807813
}

0 commit comments

Comments
 (0)