Update CRD and GRPC.

Signed-off-by: Xun Jiang <jxun@vmware.com>
pull/4818/head
Xun Jiang 2022-04-09 04:45:06 +00:00
parent 368a1ddf3c
commit 4daeec7ab9
7 changed files with 24 additions and 22 deletions

View File

@ -0,0 +1 @@
Add CSI VolumeSnapshot related metrics.

View File

@ -354,6 +354,19 @@ spec:
format: date-time
nullable: true
type: string
csiVolumeSnapshotsAttempted:
description: CsiVolumeSnapshotsAttempted is the total number of attempted
CSI VolumeSnapshots for this backup.
type: integer
csiVolumeSnapshotsCompleted:
description: CsiVolumeSnapshotsCompleted is the total number of successfully
completed CSI VolumeSnapshots for this backup.
type: integer
csiVolumeSnapshotsStorageTotal:
description: CsiVolumeSnapshotsStorageTotal is the total storage size
of created snapshots for this backup.
format: int64
type: integer
errors:
description: Errors is a count of all error messages that were generated
during execution of the backup. The actual errors are in the backup's

File diff suppressed because one or more lines are too long

View File

@ -17,7 +17,6 @@ limitations under the License.
package v1
import (
resource "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
@ -325,7 +324,7 @@ type BackupStatus struct {
// CsiVolumeSnapshotsStorageTotal is the total storage size of created
// snapshots for this backup.
// +optional
CsiVolumeSnapshotsStorageTotal resource.Quantity `json:"csiVolumeSnapshotsStorageTotal,omitempty"`
CsiVolumeSnapshotsStorageTotal int64 `json:"csiVolumeSnapshotsStorageTotal,omitempty"`
}
// BackupProgress stores information about the progress of a Backup's execution.

View File

@ -21,6 +21,7 @@ import (
"sort"
snapshotv1api "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1"
"github.com/vmware-tanzu/velero/internal/hook"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
"github.com/vmware-tanzu/velero/pkg/plugin/framework"

View File

@ -640,7 +640,12 @@ func (c *backupController) runBackup(backup *pkgbackup.Request) error {
for _, vs := range backup.CsiSnapshots {
if *vs.Status.ReadyToUse {
backup.Status.CsiVolumeSnapshotsCompleted++
backup.Status.CsiVolumeSnapshotsStorageTotal.Add(*vs.Status.RestoreSize)
storageSize, ret := vs.Status.RestoreSize.AsInt64()
if !ret {
backupLog.WithError(fmt.Errorf("fail to convert CSI snapshot size: %v to int64", backup.Status.CsiVolumeSnapshotsStorageTotal))
storageSize = 0
}
backup.Status.CsiVolumeSnapshotsStorageTotal += storageSize
}
}
@ -707,12 +712,7 @@ func recordBackupMetrics(log logrus.FieldLogger, backup *velerov1api.Backup, bac
serverMetrics.RegisterCsiSnapshotAttempts(backupScheduleName, backup.Name, backup.Status.CsiVolumeSnapshotsAttempted)
serverMetrics.RegisterCsiSnapshotSuccesses(backupScheduleName, backup.Name, backup.Status.CsiVolumeSnapshotsCompleted)
serverMetrics.RegisterCsiSnapshotFailures(backupScheduleName, backup.Name, backup.Status.CsiVolumeSnapshotsAttempted-backup.Status.CsiVolumeSnapshotsCompleted)
storageSize, ret := backup.Status.CsiVolumeSnapshotsStorageTotal.AsInt64()
if !ret {
log.WithError(fmt.Errorf("fail to convert CSI snapshot size: %v to int64", backup.Status.CsiVolumeSnapshotsStorageTotal))
storageSize = 0
}
serverMetrics.RegisterCsiStorageSizeAdd(backupScheduleName, backup.Name, storageSize)
serverMetrics.RegisterCsiStorageSizeAdd(backupScheduleName, backup.Name, backup.Status.CsiVolumeSnapshotsStorageTotal)
}
if backup.Status.Progress != nil {

View File

@ -419,18 +419,6 @@ func (m *ServerMetrics) InitSchedule(scheduleName string) {
if c, ok := m.metrics[volumeSnapshotFailureTotal].(*prometheus.CounterVec); ok {
c.WithLabelValues(scheduleName).Add(0)
}
if c, ok := m.metrics[csiSnapshotAttemptTotal].(*prometheus.CounterVec); ok {
c.WithLabelValues(scheduleName).Add(0)
}
if c, ok := m.metrics[csiSnapshotSuccessTotal].(*prometheus.CounterVec); ok {
c.WithLabelValues(scheduleName).Add(0)
}
if c, ok := m.metrics[csiSnapshotFailureTotal].(*prometheus.CounterVec); ok {
c.WithLabelValues(scheduleName).Add(0)
}
if c, ok := m.metrics[csiSnapshotStorageTotal].(*prometheus.GaugeVec); ok {
c.WithLabelValues(scheduleName).Add(0)
}
}
// InitSchedule initializes counter metrics for a node.