libopenstorage / openstorage

A multi-host clustered implementation of the open storage specification
Apache License 2.0
526 stars 118 forks source link

gRPC backupClient.EnumerateWithFilters to support date ranges #1955

Open dvasilen opened 3 years ago

dvasilen commented 3 years ago

Is this a BUG REPORT or FEATURE REQUEST?:

Feature Request

What happened:

We have rather large number of PX volumes (about 20K) and associated cloud snapshots. We have to generate weekly reports for the status of newly performed cloud snapshots. The PX volumes are created on demand. We do not use PX schedules to backup volumes and only back them up as needed (if a volume was updated). The gRPC backupClient.EnumerateWithFilters call works but it takes hours to get all the snapshots and select ones which are in the date range.

What you expected to happen:

Given the date range we need some way to quickly select cloud snapshots.

How to reproduce it (as minimally and precisely as possible):

    // Get the first batch and maybe that is it
    enumerateResponse, err = backupClient.EnumerateWithFilters(context.Background(),
        &api.SdkCloudBackupEnumerateWithFiltersRequest{
            CredentialId: credentialId,
        })

    if err != nil {
        gerr, _ := status.FromError(err)
        return fmt.Errorf("Error Code[%d] Message[%s]\n", gerr.Code(), gerr.Message())
    }

    logger.Info("Received the first backup batch")

    for _, info := range enumerateResponse.Backups {
        backup := &BackupInfo{SdkCloudBackupInfo: info}
        if dateRange.In(backup.Timestamp) {
            logger.Info("Adding backup %s for the further processing", backup.Timestamp.String())
            backupInfos = append(backupInfos, backup)
        } else {
            logger.Info("The backup %s is not in the date range", backup.Timestamp.String())
        }
    }

    // Continue, if we have more items to fetch...
    for len(enumerateResponse.ContinuationToken) > 0 {
        logger.Info("Retrieving the next chunk using continuation token %s", enumerateResponse.ContinuationToken)
        enumerateResponse, err = backupClient.EnumerateWithFilters(context.Background(),
            &api.SdkCloudBackupEnumerateWithFiltersRequest{
                CredentialId: credentialId,
            })

        if err != nil {
            gerr, _ := status.FromError(err)
            return fmt.Errorf("Error Code[%d] Message[%s]\n", gerr.Code(), gerr.Message())
        }

        for _, info := range enumerateResponse.Backups {
            backup := &BackupInfo{SdkCloudBackupInfo: info}
            if dateRange.In(backup.Timestamp) {
                logger.Info("Adding backup %s for the further processing", backup.Timestamp.String())
                backupInfos = append(backupInfos, backup)
            } else {
                logger.Info("The backup %s is not in the date range", backup.Timestamp.String())
            }
        }
    }

    logger.Info("Collected %d the backups of interest", len(backupInfos))

Anything else we need to know?:

Environment:

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8" REDHAT_BUGZILLA_PRODUCT_VERSION=8.4 REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux" REDHAT_SUPPORT_PRODUCT_VERSION="8.4"

- Kernel (e.g. `uname -a`)

Linux XXX 4.15.0-159-generic #167-Ubuntu SMP Tue Sep 21 08:55:05 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux


- Install tools: https://docs.portworx.com/portworx-install-with-kubernetes/cloud/ibm/
- Others:
dvasilen commented 3 years ago

/cc @lpabon