Skip to content

Commit

Permalink
add support for PowerScale topology (#116)
Browse files Browse the repository at this point in the history
* add support for PowerScale topology

* Updates actions.yml to run gosec

Co-authored-by: shaynafinocchiaro <66699024+shaynafinocchiaro@users.noreply.github.com>
  • Loading branch information
YianZong and shaynafinocchiaro authored Jun 30, 2022
1 parent af97fbf commit e1a126f
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
uses: actions/checkout@v2
- name: Run Go Security
uses: securego/gosec@master
with:
args: ./...
malware_security_scan:
name: Malware Scanner
runs-on: ubuntu-latest
Expand Down
14 changes: 14 additions & 0 deletions internal/k8s/volume_finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package k8s
import (
"context"
"fmt"
"strings"
"time"

corev1 "k8s.io/api/core/v1"
Expand All @@ -20,6 +21,13 @@ import (
"github.com/sirupsen/logrus"
)

const (
// ProtocolNfs Protocol NFS in lower case
ProtocolNfs = "nfs"
// CsiDriverNamePowerScale CSI PowerScale Name
CsiDriverNamePowerScale = "isilon"
)

// VolumeGetter is an interface for getting a list of persistent volume information
//go:generate mockgen -destination=mocks/volume_getter_mocks.go -package=mocks github.com/dell/karavi-topology/internal/k8s VolumeGetter
type VolumeGetter interface {
Expand Down Expand Up @@ -98,6 +106,12 @@ func (f VolumeFinder) GetPersistentVolumes(ctx context.Context) ([]VolumeInfo, e
info.StorageSystem = volume.Spec.CSI.VolumeAttributes["arrayID"]
}

// set StoregeSystem and Protocol for PowerScale
if strings.Contains(info.Driver, CsiDriverNamePowerScale) {
info.StorageSystem = volume.Spec.CSI.VolumeAttributes["ClusterName"] + ":" + volume.Spec.CSI.VolumeAttributes["AccessZone"]
info.Protocol = ProtocolNfs
}

// powerstore volume do not have storage pool unlike powerflex
if info.StoragePoolName == "" || len(info.StoragePoolName) == 0 {
info.StoragePoolName = "N/A"
Expand Down
51 changes: 50 additions & 1 deletion internal/k8s/volume_finder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,48 @@ func Test_K8sPersistentVolumeFinder(t *testing.T) {
Phase: "Bound",
},
},
{ // powerscale pvc object
ObjectMeta: metav1.ObjectMeta{
Name: "persistent-volume-name-3",
CreationTimestamp: metav1.Time{Time: t1},
},
Spec: corev1.PersistentVolumeSpec{
Capacity: map[corev1.ResourceName]resource.Quantity{
v1.ResourceStorage: resource.MustParse("16Gi"),
},
PersistentVolumeSource: corev1.PersistentVolumeSource{
CSI: &corev1.CSIPersistentVolumeSource{
Driver: "csi-isilon.dellemc.com",
VolumeAttributes: map[string]string{
"Name": "persistent-volume-name-3",
"AccessZone": "System",
"AzServiceIP": "10.0.0.1",
"ClusterName": "pieisi93x",
"ID": "15",
"Path": "/ifs/data/csi/persistent-volume-name-3",
"RootClientEnabled": "false",
},
},
},
ClaimRef: &corev1.ObjectReference{
Name: "pvc-name-3",
Namespace: "namespace-3",
UID: "pvc-uid-3",
},
StorageClassName: "storage-class-name-3",
},
Status: corev1.PersistentVolumeStatus{
Phase: "Bound",
},
},
},
}

api.EXPECT().GetPersistentVolumes().Times(1).Return(volumes, nil)

finder := k8s.VolumeFinder{
API: api,
DriverNames: []string{"csi-vxflexos.dellemc.com", "another-csi-driver.dellemc.com"},
DriverNames: []string{"csi-vxflexos.dellemc.com", "another-csi-driver.dellemc.com", "csi-isilon.dellemc.com"},
Logger: logrus.New(),
}
return finder, check(hasNoError, checkExpectedOutput([]k8s.VolumeInfo{
Expand Down Expand Up @@ -252,6 +286,21 @@ func Test_K8sPersistentVolumeFinder(t *testing.T) {
Protocol: "scsi",
CreatedTime: t1.String(),
},
{
Namespace: "namespace-3",
PersistentVolumeClaim: "pvc-uid-3",
PersistentVolumeStatus: "Bound",
VolumeClaimName: "pvc-name-3",
PersistentVolume: "persistent-volume-name-3",
StorageClass: "storage-class-name-3",
Driver: "csi-isilon.dellemc.com",
ProvisionedSize: "16Gi",
StorageSystemVolumeName: "persistent-volume-name-3",
StoragePoolName: "N/A",
StorageSystem: "pieisi93x:System",
Protocol: "nfs",
CreatedTime: t1.String(),
},
})), ctrl
},
"error calling k8s": func(*testing.T) (k8s.VolumeFinder, []checkFn, *gomock.Controller) {
Expand Down

0 comments on commit e1a126f

Please sign in to comment.