From 899b153ee7105d70b4ab75b5edbc1217639949d2 Mon Sep 17 00:00:00 2001 From: strivedi-px Date: Sat, 26 Oct 2024 17:04:41 +0530 Subject: [PATCH] vendor: vendor torpedo change --- go.mod | 2 +- go.sum | 4 +- .../torpedo/drivers/scheduler/k8s/k8s.go | 51 +++++++++++++------ .../torpedo/drivers/scheduler/scheduler.go | 14 ++++- .../drivers/volume/portworx/portworx.go | 1 + .../pure-px/torpedo/drivers/volume/volume.go | 4 +- .../torpedo/pkg/aetosutil/dashboardutil.go | 8 +-- .../pure-px/torpedo/pkg/asyncdr/asyncdr.go | 2 +- .../github.com/pure-px/torpedo/pkg/log/log.go | 3 +- vendor/modules.txt | 2 +- 10 files changed, 64 insertions(+), 27 deletions(-) diff --git a/go.mod b/go.mod index 87316061ff..15448c80c5 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( github.com/portworx/px-object-controller v0.0.0-20220804234424-40d3b8a84987 github.com/portworx/sched-ops v1.20.4-rc1.0.20240731224434-94e4e354c4b2 github.com/prometheus/client_golang v1.17.0 - github.com/pure-px/torpedo v0.0.0-20241023070534-06238143a17a + github.com/pure-px/torpedo v0.0.0-20241029143232-611042c497eb github.com/rancher/norman v0.0.0-20230222213531-275a3e921940 github.com/rancher/rancher/pkg/client v0.0.0-20230203155537-a67566517525 github.com/sirupsen/logrus v1.9.3 diff --git a/go.sum b/go.sum index 055b028fe0..fe9fbecbc8 100644 --- a/go.sum +++ b/go.sum @@ -4259,8 +4259,8 @@ github.com/proullon/ramsql v0.0.0-20211120092837-c8d0a408b939/go.mod h1:jG8oAQG0 github.com/pseudomuto/protoc-gen-doc v1.3.2/go.mod h1:y5+P6n3iGrbKG+9O04V5ld71in3v/bX88wUwgt+U8EA= github.com/pseudomuto/protoc-gen-doc v1.5.1/go.mod h1:XpMKYg6zkcpgfpCfQ8GcWBDRtRxOmMR5w7pz4Xo+dYM= github.com/pseudomuto/protokit v0.2.0/go.mod h1:2PdH30hxVHsup8KpBTOXTBeMVhJZVio3Q8ViKSAXT0Q= -github.com/pure-px/torpedo v0.0.0-20241023070534-06238143a17a h1:+NxH/ETna30GF8pHUJLXe+zFEHMdQSgxZu6aNOauEqo= -github.com/pure-px/torpedo v0.0.0-20241023070534-06238143a17a/go.mod h1:5eXclIRiV4TF1zqZqWmSJC6hPhZFRPhx7LaefJz9zKg= +github.com/pure-px/torpedo v0.0.0-20241029143232-611042c497eb h1:0oC9O+54iFsheWDoy8zJjVLo3QXSycfhQJLl6Wjuzrw= +github.com/pure-px/torpedo v0.0.0-20241029143232-611042c497eb/go.mod h1:5eXclIRiV4TF1zqZqWmSJC6hPhZFRPhx7LaefJz9zKg= github.com/quasilyte/go-ruleguard v0.3.1-0.20210203134552-1b5a410e1cc8/go.mod h1:KsAh3x0e7Fkpgs+Q9pNLS5XpFSvYCEVl5gP9Pp1xp30= github.com/quasilyte/go-ruleguard v0.3.18/go.mod h1:lOIzcYlgxrQ2sGJ735EHXmf/e9MJ516j16K/Ifcttvs= github.com/quasilyte/go-ruleguard/dsl v0.3.0/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= diff --git a/vendor/github.com/pure-px/torpedo/drivers/scheduler/k8s/k8s.go b/vendor/github.com/pure-px/torpedo/drivers/scheduler/k8s/k8s.go index c567289da1..d0703d625b 100644 --- a/vendor/github.com/pure-px/torpedo/drivers/scheduler/k8s/k8s.go +++ b/vendor/github.com/pure-px/torpedo/drivers/scheduler/k8s/k8s.go @@ -8,7 +8,6 @@ import ( "encoding/json" baseErrors "errors" "fmt" - pxutil "github.com/libopenstorage/operator/drivers/storage/portworx/util" "io" "io/ioutil" random "math/rand" @@ -23,6 +22,8 @@ import ( "text/template" "time" + pxutil "github.com/libopenstorage/operator/drivers/storage/portworx/util" + pds "github.com/portworx/pds-api-go-client/pds/v1alpha1" "github.com/pure-px/torpedo/pkg/log" @@ -4376,16 +4377,18 @@ func (k *K8s) appendVolForPVC(vols []*volume.Volume, pvc *v1.PersistentVolumeCla pvcSize, _ := pvcSizeObj.AsInt64() isRaw := pvc.Spec.VolumeMode != nil && *pvc.Spec.VolumeMode == corev1.PersistentVolumeBlock vol := &volume.Volume{ - ID: string(pvc.Spec.VolumeName), - Name: pvc.Name, - Namespace: pvc.Namespace, - Shared: k.isPVCShared(pvc), - Annotations: pvc.Annotations, - Labels: labels, - Size: uint64(pvcSize), - Raw: isRaw, - } - log.Debugf("Adding vol [%s/%s] to volume list", vol.ID, vol.Name) + ID: string(pvc.Spec.VolumeName), + Name: pvc.Name, + VolumeName: pvc.Spec.VolumeName, + Namespace: pvc.Namespace, + Shared: k.isPVCShared(pvc), + Annotations: pvc.Annotations, + Labels: labels, + Size: uint64(pvcSize), + Raw: isRaw, + StorageClass: *pvc.Spec.StorageClassName, + } + log.Infof("Adding vol [%s/%s] to volume list", vol.ID, vol.Name) return append(vols, vol), nil } @@ -7421,6 +7424,11 @@ func (k *K8s) CreateCsiSnapsForVolumes(ctx *scheduler.Context, snapClass string) if err != nil { return nil, err } + provisioner, contains := pvc.Annotations["volume.kubernetes.io/storage-provisioner"] + // snapshots can be taken for CSI volumes as well + if contains && provisioner == "pxd.portworx.com" { + snapshotOkay = true + } if snapshotOkay { snapName := "snap-" + pvc.Name + "-" + strconv.Itoa(int(time.Now().Unix())) log.Debugf("Creating snapshot: [%s] for pvc: %s", snapName, pvc.Name) @@ -8017,6 +8025,11 @@ func (k *K8s) DeleteCsiSnapsForVolumes(ctx *scheduler.Context, retainCount int) if err != nil { return err } + provisioner, contains := pvc.Annotations["volume.kubernetes.io/storage-provisioner"] + // snapshots can be taken for CSI volumes as well + if contains && provisioner == "pxd.portworx.com" { + snapshotOkay = true + } if snapshotOkay { snaplistForDelete, err := k.GetCsiSnapshots(obj.Namespace, pvc.Name) if err != nil { @@ -8246,26 +8259,34 @@ func (k *K8s) restoreCsiSnapshot( // CreateCsiSnapshotClass creates csi volume snapshot class func (k *K8s) CreateCsiSnapshotClass(snapClassName string, deleionPolicy string) (*volsnapv1.VolumeSnapshotClass, error) { + return k.CreateCSISnapshotClass(scheduler.CSISnapshotClassCreateRequest{ + SnapClassName: snapClassName, + DeletionPolicy: deleionPolicy, + }) +} + +func (k *K8s) CreateCSISnapshotClass(snapshotClassCreateRequest scheduler.CSISnapshotClassCreateRequest) (*volsnapv1.VolumeSnapshotClass, error) { var err error var annotation = make(map[string]string) var volumeSnapClass *volsnapv1.VolumeSnapshotClass annotation["snapshot.storage.kubernetes.io/is-default-class"] = "true" v1obj := metav1.ObjectMeta{ - Name: snapClassName, + Name: snapshotClassCreateRequest.SnapClassName, Annotations: annotation, } snapClass := volsnapv1.VolumeSnapshotClass{ ObjectMeta: v1obj, Driver: CsiProvisioner, - DeletionPolicy: volsnapv1.DeletionPolicy(deleionPolicy), + DeletionPolicy: volsnapv1.DeletionPolicy(snapshotClassCreateRequest.DeletionPolicy), + Parameters: snapshotClassCreateRequest.Parameters, } - log.Infof("Creating volume snapshot class: %v", snapClassName) + log.Infof("Creating volume snapshot class: %v", snapshotClassCreateRequest.SnapClassName) if volumeSnapClass, err = k8sExternalsnap.CreateSnapshotClass(&snapClass); err != nil { return nil, &scheduler.ErrFailedToCreateSnapshotClass{ - Name: snapClassName, + Name: snapshotClassCreateRequest.SnapClassName, Cause: err, } } diff --git a/vendor/github.com/pure-px/torpedo/drivers/scheduler/scheduler.go b/vendor/github.com/pure-px/torpedo/drivers/scheduler/scheduler.go index 7c770a508b..2bd2d1bb47 100644 --- a/vendor/github.com/pure-px/torpedo/drivers/scheduler/scheduler.go +++ b/vendor/github.com/pure-px/torpedo/drivers/scheduler/scheduler.go @@ -2,9 +2,10 @@ package scheduler import ( "fmt" - "k8s.io/metrics/pkg/apis/metrics/v1beta1" "time" + "k8s.io/metrics/pkg/apis/metrics/v1beta1" + corev1 "k8s.io/api/core/v1" storageapi "k8s.io/api/storage/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -404,8 +405,12 @@ type Driver interface { DeleteNode(n node.Node) error // CreateCsiSnapshotClass create csi snapshot class + // Deprecated, please use function below CreateCsiSnapshotClass(snapClassName string, deleionPolicy string) (*volsnapv1.VolumeSnapshotClass, error) + // CreateCSISnapshotClass create csi snapshot class + CreateCSISnapshotClass(snapshotClassCreateRequest CSISnapshotClassCreateRequest) (*volsnapv1.VolumeSnapshotClass, error) + // CreateVolumeSnapshotClasses creates a volume snapshot class CreateVolumeSnapshotClasses(snapClassName string, provisioner string, isDefault bool, deletePolicy string) (*volsnapv1.VolumeSnapshotClass, error) @@ -571,3 +576,10 @@ type CSICloneRequest struct { OriginalPVCName string RestoredPVCName string } + +// CSISnapshotClassCreateRequest contains the necessary info to clone from an existing CSI volume +type CSISnapshotClassCreateRequest struct { + SnapClassName string + DeletionPolicy string + Parameters map[string]string +} diff --git a/vendor/github.com/pure-px/torpedo/drivers/volume/portworx/portworx.go b/vendor/github.com/pure-px/torpedo/drivers/volume/portworx/portworx.go index 865eef35e2..fa6d0b440c 100644 --- a/vendor/github.com/pure-px/torpedo/drivers/volume/portworx/portworx.go +++ b/vendor/github.com/pure-px/torpedo/drivers/volume/portworx/portworx.go @@ -2382,6 +2382,7 @@ func (d *portworx) UpdateVolumeSpec(vol *torpedovolume.Volume, volumeSpec *api.V Spec: volumeSpec, }) if err != nil { + log.Errorf("Failed to update volume [%s]: %v", volumeName, err) return nil, true, fmt.Errorf("volume [%s] not updated yet", volumeName) } log.Debugf("Updated volume [%s]", volumeName) diff --git a/vendor/github.com/pure-px/torpedo/drivers/volume/volume.go b/vendor/github.com/pure-px/torpedo/drivers/volume/volume.go index 63a5a1678e..906d7c244f 100644 --- a/vendor/github.com/pure-px/torpedo/drivers/volume/volume.go +++ b/vendor/github.com/pure-px/torpedo/drivers/volume/volume.go @@ -18,7 +18,8 @@ import ( // Volume is a generic struct encapsulating volumes in the cluster type Volume struct { ID string - Name string + Name string // this is PVC Name, nto changing for backward compatibility + VolumeName string // this is the volume name Namespace string Annotations map[string]string Labels map[string]string @@ -26,6 +27,7 @@ type Volume struct { RequestedSize uint64 Shared bool Raw bool + StorageClass string } // Snapshot is a generic struct encapsulating snapshots in the cluster diff --git a/vendor/github.com/pure-px/torpedo/pkg/aetosutil/dashboardutil.go b/vendor/github.com/pure-px/torpedo/pkg/aetosutil/dashboardutil.go index 104ac8e478..0ab65981e3 100644 --- a/vendor/github.com/pure-px/torpedo/pkg/aetosutil/dashboardutil.go +++ b/vendor/github.com/pure-px/torpedo/pkg/aetosutil/dashboardutil.go @@ -187,7 +187,7 @@ func (d *Dashboard) TestSetEnd() { for v, t := range testCasesStack { d.TestcaseID = v d.testCase = t - d.setDashTestCaseId() + d.SetDashTestCaseId() d.TestCaseEnd() } testCasesStack = nil @@ -351,7 +351,7 @@ func (d *Dashboard) TestCaseBegin(testName, description, testRailID string, tags } } d.testCase = testCase - d.setDashTestCaseId() + d.SetDashTestCaseId() d.Infof("Torpedo Command: %s", os.Args) logrus.Infof("Adding testcaseID: %d to stack", d.TestcaseID) testCasesStack[d.TestcaseID] = testCase @@ -360,7 +360,7 @@ func (d *Dashboard) TestCaseBegin(testName, description, testRailID string, tags } // SetDashTestCaseId sets the aetos dashboard testcase id for the current goroutine -func (d *Dashboard) setDashTestCaseId() { +func (d *Dashboard) SetDashTestCaseId() { gid := getGoroutineID() dgid := fmt.Sprintf("d-%d", gid) testInfoMap.Store(dgid, d.TestcaseID) @@ -605,4 +605,4 @@ func (d *Dashboard) UpdateStats(name, product, statType, version string, dashSta } } -} +} \ No newline at end of file diff --git a/vendor/github.com/pure-px/torpedo/pkg/asyncdr/asyncdr.go b/vendor/github.com/pure-px/torpedo/pkg/asyncdr/asyncdr.go index 15eaeaf8c7..374e08d9a1 100644 --- a/vendor/github.com/pure-px/torpedo/pkg/asyncdr/asyncdr.go +++ b/vendor/github.com/pure-px/torpedo/pkg/asyncdr/asyncdr.go @@ -39,7 +39,7 @@ const ( clusterName = "tp-cluster" restoreNamePrefix = "tp-restore" configMapName = "kubeconfigs" - migrationRetryTimeout = 10 * time.Minute + migrationRetryTimeout = 20 * time.Minute migrationRetryInterval = 10 * time.Second // DefaultClusterPairDir default directory where kubeconfig files will be generated diff --git a/vendor/github.com/pure-px/torpedo/pkg/log/log.go b/vendor/github.com/pure-px/torpedo/pkg/log/log.go index 6748576004..4bea77e95b 100644 --- a/vendor/github.com/pure-px/torpedo/pkg/log/log.go +++ b/vendor/github.com/pure-px/torpedo/pkg/log/log.go @@ -443,6 +443,7 @@ func SetTestName(testName string) { testLog := New() loggersMap.Store(testName, testLog) } + dash.SetDashTestCaseId() } @@ -476,4 +477,4 @@ func getGoroutineID() uint64 { func init() { tpLog = GetLogInstance() dash = aetosutil.Get() -} +} \ No newline at end of file diff --git a/vendor/modules.txt b/vendor/modules.txt index 5f6d832b9b..cd214bf22d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1216,7 +1216,7 @@ github.com/prometheus/procfs/internal/util ## explicit; go 1.13 github.com/prometheus/statsd_exporter/pkg/mapper github.com/prometheus/statsd_exporter/pkg/mapper/fsm -# github.com/pure-px/torpedo v0.0.0-20241023070534-06238143a17a +# github.com/pure-px/torpedo v0.0.0-20241029143232-611042c497eb ## explicit; go 1.21.4 github.com/pure-px/torpedo/drivers/api github.com/pure-px/torpedo/drivers/node