From 6262677b6e5a82192abe6b5a65953fa124390971 Mon Sep 17 00:00:00 2001 From: JenTing Hsiao Date: Tue, 14 Jun 2022 05:57:59 +0000 Subject: [PATCH] [ws-manager] Only calculate the restore success/failure counter if it's restoring from the Backup or VolumeSnapshot Signed-off-by: JenTing Hsiao --- components/ws-manager/pkg/manager/monitor.go | 26 ++++++++++++-------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/components/ws-manager/pkg/manager/monitor.go b/components/ws-manager/pkg/manager/monitor.go index c3a4d7fcf91faa..d7a5bc035d5120 100644 --- a/components/ws-manager/pkg/manager/monitor.go +++ b/components/ws-manager/pkg/manager/monitor.go @@ -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 }