Skip to content

Commit

Permalink
Update dell-csi-extensions version (#65)
Browse files Browse the repository at this point in the history
* update dell-csi-extensions version

* update go action

* update format

* fix linting issue

* fix linting issue

* add code owners
  • Loading branch information
xuluna authored Feb 26, 2024
1 parent c1c00a1 commit bdcaa40
Show file tree
Hide file tree
Showing 16 changed files with 110 additions and 119 deletions.
6 changes: 5 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
# Jooseppi Luna (jooseppi-luna)
# Matt Schmaelzle (mjsdell)
# Surya Prakash Gupta (suryagupta4)
# Alik Saring (alikdell)
# Aaron Tye (atye)
# Shayna Finocchiaro (shaynafinocchiaro)
# Luna Xu (xuluna)

# for all files:
* @abhi16394 @adarsh-dell @AkshaySainiDell @bharathsreekanth @gallacher @JacobGros @jooseppi-luna @mjsdell @harishp8889 @suryagupta4
* @abhi16394 @adarsh-dell @AkshaySainiDell @bharathsreekanth @gallacher @JacobGros @jooseppi-luna @mjsdell @harishp8889 @suryagupta4 @alikdell @atye @shaynafinocchiaro @xuluna
6 changes: 3 additions & 3 deletions .github/workflows/actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run the formatter, linter, and vetter
uses: dell/common-github-actions/go-code-formatter-linter-vetter@main
with:
Expand All @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run Go Security
uses: securego/gosec@master
with:
Expand All @@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run malware scan
uses: dell/common-github-actions/malware-scanner@main
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/linters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ jobs:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
cache: false
- name: Checkout the code
uses: actions/checkout@v3.2.0
uses: actions/checkout@v4.1.0
- name: Vendor packages
run: |
go mod vendor
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
version: v1.53
version: latest
skip-cache: true
4 changes: 2 additions & 2 deletions api/v1/dellcsivolumegroupsnapshot_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ type DellCsiVolumeGroupSnapshotSpec struct {
type MemberReclaimPolicy string

const (
//MemberReclaimDelete to delete VG
// MemberReclaimDelete to delete VG
MemberReclaimDelete = "Delete"
//MemberReclaimRetain to retail VG
// MemberReclaimRetain to retail VG
MemberReclaimRetain = "Retain"
)

Expand Down
60 changes: 28 additions & 32 deletions controllers/dellcsivolumegroupsnapshot_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) Reconcile(ctx context.Context, re
var volIDPvcNameMap map[string]string
var volErr error
if vg.Spec.PvcList != nil {
srcVolIDs, volIDPvcNameMap, volErr = r.getSourceVolIdsFromPvcName(ctx, vg.Spec.PvcList, ns)
srcVolIDs, volIDPvcNameMap, volErr = r.getSourceVolIDsFromPvcName(ctx, vg.Spec.PvcList, ns)
} else if vg.Spec.PvcLabel != "" {
srcVolIDs, volIDPvcNameMap, volErr = r.getSourceVolIdsFromLabel(ctx, vg.Spec.PvcLabel, ns)
srcVolIDs, volIDPvcNameMap, volErr = r.getSourceVolIDsFromLabel(ctx, vg.Spec.PvcLabel, ns)
} else {
// snapshot pvcs under given namespace
srcVolIDs, volIDPvcNameMap, volErr = r.getSourceVolIdsFromNs(ctx, ns)
srcVolIDs, volIDPvcNameMap, volErr = r.getSourceVolIDsFromNs(ctx, ns)
}

if volErr != nil {
Expand All @@ -180,7 +180,7 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) Reconcile(ctx context.Context, re
sort.Strings(srcVolIDs)
// make grpc call to driver
otherParams := make(map[string]string)
//remove systemID
// remove systemID
gid := vg.Status.SnapshotGroupID
tokens := strings.Split(gid, "-")
index := len(tokens)
Expand Down Expand Up @@ -256,8 +256,8 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) processResponse(ctx context.Conte
volIDPvcNameMap map[string]string,
vg *vgsv1.DellCsiVolumeGroupSnapshot,
sc *s1.VolumeSnapshotClass,
groupName string) (ctrl.Result, error) {

groupName string,
) (ctrl.Result, error) {
log.Info("VG Snapshotter reconcile VG-response ", "SnapshotGroupID ", res.SnapshotGroupID)

snapshots := res.Snapshots
Expand Down Expand Up @@ -419,8 +419,8 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) bindContentToSnapshot(
contentName string,
vgNamespace string,
vgName string,
failedMap map[string]string) error {

_ map[string]string,
) error {
vs := new(s1.VolumeSnapshot)
nameSpacedName := t1.NamespacedName{
Namespace: vgNamespace,
Expand All @@ -444,7 +444,8 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) bindContentToSnapshot(
// handles vg deletion
func (r *DellCsiVolumeGroupSnapshotReconciler) deleteVg(
ctx context.Context,
vg *vgsv1.DellCsiVolumeGroupSnapshot) error {
vg *vgsv1.DellCsiVolumeGroupSnapshot,
) error {
log.Info("VG Snapshotter deletion triggered")

// get deletion policy from volumesnapshotclass
Expand Down Expand Up @@ -507,8 +508,8 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) createVolumeSnapshot(
vg *vgsv1.DellCsiVolumeGroupSnapshot,
s *csiext.Snapshot,
sc *s1.VolumeSnapshotClass,
failedMap map[string]string) (bool, string, error) {

failedMap map[string]string,
) (bool, string, error) {
volsnap := new(s1.VolumeSnapshot)
nameSpacedName := t1.NamespacedName{
Namespace: vg.Namespace,
Expand Down Expand Up @@ -540,7 +541,7 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) createVolumeSnapshot(
}

updateSnapIDForContent := false
var vgName = vg.Name
vgName := vg.Name
var contentNameExists string
var contentErr error
if volumeSnapshotExists {
Expand Down Expand Up @@ -583,8 +584,8 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) updateVolumeSnapshotContentStatus
updateSnapIDForContent bool,
s *csiext.Snapshot,
vgName string,
failedMap map[string]string) error {

failedMap map[string]string,
) error {
vc := &s1.VolumeSnapshotContent{}
nameSpacedName := t1.NamespacedName{
Namespace: "",
Expand Down Expand Up @@ -635,8 +636,8 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) checkExistingVolsnapcontent(
ctx context.Context,
volsnap *s1.VolumeSnapshot,
vg *vgsv1.DellCsiVolumeGroupSnapshot,
snapID string) (string, bool, error) {

snapID string,
) (string, bool, error) {
vcList := &s1.VolumeSnapshotContentList{}
err := r.List(ctx, vcList, &client.ListOptions{})
if err != nil || len(vcList.Items) < 1 {
Expand Down Expand Up @@ -664,7 +665,8 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) validateExistingVolSnapcontent(
vc s1.VolumeSnapshotContent,
volsnap *s1.VolumeSnapshot,
vg *vgsv1.DellCsiVolumeGroupSnapshot,
snapID string) (bool, error) {
snapID string,
) (bool, error) {
var existVolumeSnapshotContentError bool
updateSnapIDForContent := false
var contentErr error
Expand Down Expand Up @@ -704,8 +706,8 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) checkExistingVolSnapshot(
ctx context.Context,
volsnap *s1.VolumeSnapshot,
vg *vgsv1.DellCsiVolumeGroupSnapshot,
snapID string) (bool, error) {

snapID string,
) (bool, error) {
log.Info("VG Snapshotter", "volumesnapshot exists skip create name=", volsnap.Name)
var existVolumeSnapshotError bool
var snapErr error
Expand Down Expand Up @@ -759,12 +761,12 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) checkExistingVolSnapshot(
return existVolumeSnapshotError, contentErr
}
return false, nil

}

// get a list of source volume Ids, a map from these Ids to corresponding pvc names based on the given pvc label
func (r *DellCsiVolumeGroupSnapshotReconciler) getSourceVolIdsFromLabel(ctx context.Context,
label string, ns string) ([]string, map[string]string, error) {
func (r *DellCsiVolumeGroupSnapshotReconciler) getSourceVolIDsFromLabel(ctx context.Context,
label string, ns string,
) ([]string, map[string]string, error) {
pvclabel := label
pvcList := &v1.PersistentVolumeClaimList{}
log.Info("VG Snapshotter find matching pvc ", "label", label)
Expand All @@ -791,7 +793,7 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) getSourceVolIdsFromLabel(ctx cont
}

// get a list of source volume Ids, a map from these Ids to corresponding pvc names based on a list of pvc names
func (r *DellCsiVolumeGroupSnapshotReconciler) getSourceVolIdsFromPvcName(ctx context.Context, pvcNames []string, ns string) ([]string, map[string]string, error) {
func (r *DellCsiVolumeGroupSnapshotReconciler) getSourceVolIDsFromPvcName(ctx context.Context, pvcNames []string, ns string) ([]string, map[string]string, error) {
duplicateMap := make(map[string]bool)
pvcList := make([]v1.PersistentVolumeClaim, 0)
for _, pvcName := range pvcNames {
Expand All @@ -800,9 +802,8 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) getSourceVolIdsFromPvcName(ctx co
if present {
log.Info("VG Snapshotter vg finds duplicate PVC names ", "pvc name", pvcName)
continue
} else {
duplicateMap[pvcName] = true
}
duplicateMap[pvcName] = true

// find pvc for the given pvc Name
pvc := &v1.PersistentVolumeClaim{}
Expand All @@ -821,7 +822,7 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) getSourceVolIdsFromPvcName(ctx co
return r.mapVolIDToPvcName(ctx, pvcList)
}

func (r *DellCsiVolumeGroupSnapshotReconciler) getSourceVolIdsFromNs(ctx context.Context, ns string) ([]string, map[string]string, error) {
func (r *DellCsiVolumeGroupSnapshotReconciler) getSourceVolIDsFromNs(ctx context.Context, ns string) ([]string, map[string]string, error) {
pvcList := &v1.PersistentVolumeClaimList{}
log.Info("VG Snapshotter find matching pvc", "namespace", ns)

Expand Down Expand Up @@ -1011,7 +1012,7 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) ignoreUpdatePredicate() predicate
}
}

func (r *DellCsiVolumeGroupSnapshotReconciler) handleSnapUpdate(oldObj interface{}, obj interface{}) {
func (r *DellCsiVolumeGroupSnapshotReconciler) handleSnapUpdate(_ interface{}, obj interface{}) {
nsnapshot, _ := obj.(*s1.VolumeSnapshot)

// vgs-helm-test-1-pvol1
Expand Down Expand Up @@ -1046,7 +1047,6 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) handleSnapUpdate(oldObj interface
}

func (r *DellCsiVolumeGroupSnapshotReconciler) handleSnapCreate(obj interface{}) {

snapshot, ok := obj.(*s1.VolumeSnapshot)
if !ok {
err := fmt.Errorf("VG Snapshotter watcher volumesnapshot watch fails to convert obj to volumeSnapshot")
Expand Down Expand Up @@ -1081,7 +1081,6 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) handleSnapCreate(obj interface{})
}

func (r *DellCsiVolumeGroupSnapshotReconciler) snapWatch() error {

var clientset sclient.Interface
config, err := rest.InClusterConfig()
if err != nil {
Expand All @@ -1107,7 +1106,6 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) snapWatch() error {
}

func (r *DellCsiVolumeGroupSnapshotReconciler) snapContentWatch() error {

var clientset sclient.Interface
config, err := rest.InClusterConfig()
if err != nil {
Expand Down Expand Up @@ -1136,7 +1134,6 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) snapContentWatch() error {

// HandleSnapContentDelete updates VG status based on changes to volumesnapshotcontent
func (r *DellCsiVolumeGroupSnapshotReconciler) HandleSnapContentDelete(obj interface{}) {

content, ok := obj.(*s1.VolumeSnapshotContent)
if !ok {
err := fmt.Errorf("VG Snapshotter watcher volumesnapshotcontent watch fails to convert obj to vscontent")
Expand All @@ -1157,7 +1154,6 @@ func (r *DellCsiVolumeGroupSnapshotReconciler) HandleSnapContentDelete(obj inter
Name: snapName,
Namespace: ns,
}, snap)

if err != nil {
// Snap already deleted. Need to add label like "snapshotGroup=vgs-helm-test" to content also
log.Error(err, "VG Snapshotter watcher snapshotcontent watch can't find its bound snapshot %s")
Expand Down
10 changes: 3 additions & 7 deletions controllers/dellcsivolumegroupsnapshot_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ func (suite *VGSControllerTestSuite) TestHandleSnapContentDelete() {
Name: vgName,
}, newVg)
assert.Equal(suite.T(), "DellCsiVolumeGroupSnapshot.volumegroup.storage.dell.com \"vg-snap\" not found", err.Error())

}

// test a successful reconcile with setup
Expand Down Expand Up @@ -470,7 +469,6 @@ func (suite *VGSControllerTestSuite) TestGetSourceVolIDsFromNsEmptyPvcUnderNs()

// test bad reference
func (suite *VGSControllerTestSuite) TestReconcileBadRef() {

key := fake_client.StorageKey{
Name: fakePvcName1,
Namespace: "fake-ns",
Expand All @@ -482,7 +480,6 @@ func (suite *VGSControllerTestSuite) TestReconcileBadRef() {
suite.makeFakePV(ctx, fakePvName1, srcVolID)
suite.makeFakePVC(ctx, label, fakePvcName1, suite.mockUtils.Specs.Namespace, fakePvName1)
suite.runGetReference(suite.mockUtils.FakeClient.Objects[key], "no kind is registered for the type")

}

func (suite *VGSControllerTestSuite) TestGetRefToRef() {
Expand All @@ -495,7 +492,6 @@ func (suite *VGSControllerTestSuite) TestGetRefToRef() {

ref := suite.runGetReference(suite.mockUtils.FakeClient.Objects[key], "")
suite.runGetReference(ref, "")

}

func (suite *VGSControllerTestSuite) TestGetRefToUnknownObj() {
Expand Down Expand Up @@ -622,7 +618,7 @@ func (suite *VGSControllerTestSuite) createReconcilerAndReq(localVgName string)
return
}

func (suite *VGSControllerTestSuite) runFakeVGManagerSetup(localVgName, expectedErr string) {
func (suite *VGSControllerTestSuite) runFakeVGManagerSetup(_, expectedErr string) {
vgReconcile, req := suite.createReconcilerAndReq(vgName)

mgr, _ := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Expand Down Expand Up @@ -653,7 +649,6 @@ func (suite *VGSControllerTestSuite) runFakeVGManagerSetup(localVgName, expected
}

func (suite *VGSControllerTestSuite) deleteVGForReUse(localVgName string, induceError string) {

// find existing vg , get volsnap , get volsnapcotent

vg := &vgsv1.DellCsiVolumeGroupSnapshot{}
Expand All @@ -680,6 +675,7 @@ func (suite *VGSControllerTestSuite) deleteVGForReUse(localVgName string, induce
vc := &s1.VolumeSnapshotContent{}
for _, c := range vcList.Items {
fmt.Printf("fake client found content ReadyToUse %#v \n", c)
c := c
vc = &c
}
*vc.Spec.Source.SnapshotHandle = "badid"
Expand Down Expand Up @@ -710,7 +706,7 @@ func (suite *VGSControllerTestSuite) deleteVGForReUse(localVgName string, induce
suite.makeFakeVG(ctx, label, "reuse-vg-snap", suite.mockUtils.Specs.Namespace, "Retain", nil)
}

func (suite *VGSControllerTestSuite) runFakeVGManager(localVgName, namespace, expectedErr string) {
func (suite *VGSControllerTestSuite) runFakeVGManager(localVgName, _, expectedErr string) {
vgReconcile, req := suite.createReconcilerAndReq(localVgName)

// invoke controller Reconcile to test. typically k8s would call this when resource is changed
Expand Down
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module github.com/dell/csi-volumegroup-snapshotter

go 1.22

toolchain go1.22.0

require (
github.com/dell/dell-csi-extensions/common v1.3.0
github.com/dell/dell-csi-extensions/volumeGroupSnapshot v1.4.0
github.com/dell/dell-csi-extensions/common v1.4.0
github.com/dell/dell-csi-extensions/volumeGroupSnapshot v1.5.0
github.com/go-chi/chi v1.5.4
github.com/go-logr/logr v1.2.0
github.com/google/uuid v1.3.0
Expand Down Expand Up @@ -57,7 +58,7 @@ require (
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230815205213-6bfd019c3878 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20220521103104-8f96da9f5d5e // indirect
Expand Down
Loading

0 comments on commit bdcaa40

Please sign in to comment.