From cb2a5439df7b6f4604b3237bec459b2de9585d09 Mon Sep 17 00:00:00 2001 From: sivakumar subraani Date: Mon, 12 Aug 2024 16:48:01 +0000 Subject: [PATCH] pb-4394: vendor latest stork change from master branch --- go.mod | 2 +- go.sum | 4 +-- .../stork/drivers/volume/kdmp/kdmp.go | 26 +++++++++++++++---- .../stork/drivers/volume/portworx/portworx.go | 2 +- .../libopenstorage/stork/pkg/rule/rule.go | 4 +++ .../stork/pkg/snapshotter/snapshotter_csi.go | 2 +- .../libopenstorage/stork/pkg/utils/utils.go | 24 +++++++++++++++++ vendor/modules.txt | 2 +- 8 files changed, 55 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index f7a316e0..0393a55e 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/hashicorp/go-version v1.6.0 github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0 github.com/kubernetes-incubator/external-storage v0.20.4-openstorage-rc7 - github.com/libopenstorage/stork v1.4.1-0.20240627120023-8294d8315c46 + github.com/libopenstorage/stork v1.4.1-0.20240812120411-1e85db1ccb81 github.com/portworx/pxc v0.33.0 github.com/portworx/sched-ops v1.20.4-rc1.0.20240514213912-ff0ae32b859a github.com/sirupsen/logrus v1.9.3 diff --git a/go.sum b/go.sum index 9fe72b6a..2cc72874 100644 --- a/go.sum +++ b/go.sum @@ -3394,8 +3394,8 @@ github.com/libopenstorage/stork v1.4.1-0.20230502135851-9cacb19e1df5/go.mod h1:R github.com/libopenstorage/stork v1.4.1-0.20230519043154-cbc10dffaf19/go.mod h1:Xm4DHoViynFXMQKBXGj3IkA77LY2RBFkNtv6vbo3wNw= github.com/libopenstorage/stork v1.4.1-0.20230601053837-5dd68f026569/go.mod h1:+mKPMCPNhS/XOF2RPcNFijkr67CCCWp0o8OXVG6xxAk= github.com/libopenstorage/stork v1.4.1-0.20230610103146-72cf75320066/go.mod h1:Yst+fnOYjWk6SA5pXZBKm19wtiinjxQ/vgYTXI3k80Q= -github.com/libopenstorage/stork v1.4.1-0.20240627120023-8294d8315c46 h1:1riZcFUNvv0xUeaQj39J8CYDeM7LvA1xqFZZuftjNTk= -github.com/libopenstorage/stork v1.4.1-0.20240627120023-8294d8315c46/go.mod h1:4n6M9LolJA2u4uB8Cd3YvQFhe0jYEweHLW/EZvECCyE= +github.com/libopenstorage/stork v1.4.1-0.20240812120411-1e85db1ccb81 h1:NOD9DKkLkMax9/Dt/MSqjQxyvIJp54QQ2nhMzC7WDWs= +github.com/libopenstorage/stork v1.4.1-0.20240812120411-1e85db1ccb81/go.mod h1:kVkZgWst16fhzMTgKCMbvat+NS/ABtJPr74PR7X1PFs= github.com/libopenstorage/systemutils v0.0.0-20160208220149-44ac83be3ce1/go.mod h1:xwNGC7xiz/BQ/wbMkvHujL8Gjgseg+x41xMek7sKRRQ= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= diff --git a/vendor/github.com/libopenstorage/stork/drivers/volume/kdmp/kdmp.go b/vendor/github.com/libopenstorage/stork/drivers/volume/kdmp/kdmp.go index 9bb9313d..4e9bc07f 100644 --- a/vendor/github.com/libopenstorage/stork/drivers/volume/kdmp/kdmp.go +++ b/vendor/github.com/libopenstorage/stork/drivers/volume/kdmp/kdmp.go @@ -44,6 +44,8 @@ const ( volumeinitialDelay = 2 * time.Second volumeFactor = 1.5 volumeSteps = 20 + // By default, will increase the pvc size by 10% of snapshot size, if snapshot size is greater than pvc size + defaultPvcSizeIncreasePercentage = 10 // StorkAPIVersion current api version supported by stork StorkAPIVersion = "stork.libopenstorage.org/v1alpha1" // KdmpAPIVersion current api version supported by KDMP @@ -749,12 +751,26 @@ func (k *kdmp) StartRestore( pvc.Name = bkpvInfo.PersistentVolumeClaim pvc.Namespace = restoreNamespace } - // Check if the snapshot size is larger than the pvc size. - // Update the pvc size to that of the snapshot size if so. + // Below two cases, we will change the PVC original size. + // case1: If the snapshot size is greater than the PVC size. In some of the filesystem + // provisioned PVC, the content of the PVC is allowed to grow beyond the PVC size. + // case2: If the snapshot size + 10% of the snapshot size goes beyind the PVC size. + // We also allow the customer to configure the sizePercentage to configured, if the 10% does not + // satisfy their storage provisioner. + // KDMP_RESTORE_PVC_SIZE_PERCENTAGE parameter need to be added to the kdmp-config configmap in kube-system namespace. + sizePercentage := utils.GetRestorePvcSizePercentage() + if sizePercentage == 0 { + sizePercentage = defaultPvcSizeIncreasePercentage + } + logrus.Infof("StartRestore: sizePercentage is - %v", sizePercentage) + totalSize := int64(bkpvInfo.TotalSize) + newPvcQuantity := resource.NewQuantity( + totalSize+((int64(sizePercentage)*int64(bkpvInfo.TotalSize))/int64(100)), + resource.BinarySI, + ) pvcQuantity := pvc.Spec.Resources.Requests[v1.ResourceStorage] - if pvcQuantity.CmpInt64(int64(bkpvInfo.TotalSize)) == -1 { - newPvcQuantity := resource.NewQuantity(int64(bkpvInfo.TotalSize), resource.BinarySI) - logrus.Debugf("setting size of pvc %s/%s same as snapshot size %s", pvc.Namespace, pvc.Name, newPvcQuantity.String()) + if (pvcQuantity.Cmp(*newPvcQuantity)) == -1 { + logrus.Debugf("StartRestore: setting size of pvc %s/%s to accommodate snapshot size with buffer %s", pvc.Namespace, pvc.Name, newPvcQuantity.String()) pvc.Spec.Resources.Requests[v1.ResourceStorage] = *newPvcQuantity } volumeInfo.PersistentVolumeClaim = bkpvInfo.PersistentVolumeClaim diff --git a/vendor/github.com/libopenstorage/stork/drivers/volume/portworx/portworx.go b/vendor/github.com/libopenstorage/stork/drivers/volume/portworx/portworx.go index b985d7b7..db15434d 100644 --- a/vendor/github.com/libopenstorage/stork/drivers/volume/portworx/portworx.go +++ b/vendor/github.com/libopenstorage/stork/drivers/volume/portworx/portworx.go @@ -912,7 +912,7 @@ func (p *portworx) GetPodVolumes(podSpec *v1.PodSpec, namespace string, includeP } // If a volume is pending and WFFC, it doesn't exist in Portworx. // No need of querying it. - if !isPendingWFFC { + if volumeName != "" && !isPendingWFFC { volumeNameList = append(volumeNameList, volumeName) } } diff --git a/vendor/github.com/libopenstorage/stork/pkg/rule/rule.go b/vendor/github.com/libopenstorage/stork/pkg/rule/rule.go index 68eed72b..1a0f304f 100644 --- a/vendor/github.com/libopenstorage/stork/pkg/rule/rule.go +++ b/vendor/github.com/libopenstorage/stork/pkg/rule/rule.go @@ -256,6 +256,10 @@ func ExecuteRule( logrus.Infof("Ignoring completed pod for running rule %v", pod.Name) continue } + if !core.Instance().IsPodRunning(pod) { + logrus.Debugf("skipping executing rule on pod %v: Pod not in running state", pod.GetName()) + continue + } logrus.Debugf("Including pod to run rule %v", pod.Name) pods = append(pods, pod) } diff --git a/vendor/github.com/libopenstorage/stork/pkg/snapshotter/snapshotter_csi.go b/vendor/github.com/libopenstorage/stork/pkg/snapshotter/snapshotter_csi.go index 0c0f2c88..62082a0e 100644 --- a/vendor/github.com/libopenstorage/stork/pkg/snapshotter/snapshotter_csi.go +++ b/vendor/github.com/libopenstorage/stork/pkg/snapshotter/snapshotter_csi.go @@ -741,7 +741,7 @@ func (c *csiDriver) RestoreStatus(pvcName, namespace string) (RestoreInfo, error } // Lets use SNAPSHOT_TIMEOUT for restoreTimeout as well. restoreTimeout, err := getSnapshotTimeout() - if err == nil { + if err != nil { logrus.Warnf("failed to obtain timeout value for snapshot %s: %v, falling back on default snapshot timeout value %s", vsName, err, defaultSnapshotTimeout.String()) restoreTimeout = defaultSnapshotTimeout } diff --git a/vendor/github.com/libopenstorage/stork/pkg/utils/utils.go b/vendor/github.com/libopenstorage/stork/pkg/utils/utils.go index 52ab0b53..adc4dcab 100644 --- a/vendor/github.com/libopenstorage/stork/pkg/utils/utils.go +++ b/vendor/github.com/libopenstorage/stork/pkg/utils/utils.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "os" + "strconv" "strings" "time" @@ -37,6 +38,8 @@ const ( // PXIncrementalCountAnnotation is the annotation used to set cloud backup incremental count // for volume PXIncrementalCountAnnotation = "portworx.io/cloudsnap-incremental-count" + // kdmpRestorePvcSizePercentageKey - KDMP restore PVC size increase percentage + kdmpRestorePvcSizePercentageKey = "KDMP_RESTORE_PVC_SIZE_PERCENTAGE" // trimCRDGroupNameKey - groups name containing the string from this configmap field will be trimmed trimCRDGroupNameKey = "TRIM_CRD_GROUP_NAME" // QuitRestoreCrTimestampUpdate is sent in the channel to informs the go routine to stop any further update @@ -170,6 +173,27 @@ func GetTrimmedGroupName(group string) string { return group } +// GetRestorePvcSizePercentage - get the percentage of size that need to increased during the kdmp restore PVC creation. +// In the case failure, returning zero to assume default 10% value. +func GetRestorePvcSizePercentage() int { + fn := "GetRestorePvcSizePercentage" + kdmpData, err := core.Instance().GetConfigMap(drivers.KdmpConfigmapName, drivers.KdmpConfigmapNamespace) + if err != nil { + logrus.Debugf("%v: error in reading configMap [%v/%v]", + fn, drivers.KdmpConfigmapName, drivers.KdmpConfigmapNamespace) + return 0 + } + if len(kdmpData.Data[kdmpRestorePvcSizePercentageKey]) != 0 { + sizePercentage, err := strconv.Atoi(kdmpData.Data[kdmpRestorePvcSizePercentageKey]) + if err != nil { + logrus.Debugf("%v: error in converting kdmpRestorePvcSizePercentage to integer: %v", fn, err) + return 0 + } + return sizePercentage + } + return 0 +} + // GetStorageClassNameForPVC - Get the storageClass name from the PVC spec func GetStorageClassNameForPVC(pvc *v1.PersistentVolumeClaim) (string, error) { var scName string diff --git a/vendor/modules.txt b/vendor/modules.txt index 72478c6b..ed917b69 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -505,7 +505,7 @@ github.com/libopenstorage/openstorage-sdk-clients/sdk/golang github.com/libopenstorage/secrets github.com/libopenstorage/secrets/aws/credentials github.com/libopenstorage/secrets/k8s -# github.com/libopenstorage/stork v1.4.1-0.20240627120023-8294d8315c46 +# github.com/libopenstorage/stork v1.4.1-0.20240812120411-1e85db1ccb81 ## explicit; go 1.21 github.com/libopenstorage/stork/drivers github.com/libopenstorage/stork/drivers/volume