Skip to content

Commit

Permalink
Merge pull request #414 from jakobmoellerdev/OCPVE-677-multi-not-foun…
Browse files Browse the repository at this point in the history
…d-fix

OCPVE-677: fix: allow deleting all storageclasses / vgs in case one is already gone
  • Loading branch information
openshift-merge-robot authored Sep 11, 2023
2 parents 1ba3a1c + 2b1d98c commit 554d501
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
7 changes: 6 additions & 1 deletion controllers/lvm_volumegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"fmt"

lvmv1alpha1 "github.com/openshift/lvm-operator/api/v1alpha1"

"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
cutil "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
Expand Down Expand Up @@ -90,7 +92,10 @@ func (c lvmVG) ensureDeleted(r *LVMClusterReconciler, ctx context.Context, lvmCl
logger := logger.WithValues("LVMVolumeGroup", volumeGroup.GetName())

if err := r.Client.Get(ctx, vgName, volumeGroup); err != nil {
return client.IgnoreNotFound(err)
if errors.IsNotFound(err) {
continue
}
return err
}

// if not marked for deletion, mark now.
Expand Down
5 changes: 4 additions & 1 deletion controllers/scc.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ func (c openshiftSccs) ensureDeleted(r *LVMClusterReconciler, ctx context.Contex
name := types.NamespacedName{Name: scName}
logger := logger.WithValues("SecurityContextConstraint", scName)
if err := r.Client.Get(ctx, name, scc); err != nil {
return client.IgnoreNotFound(err)
if errors.IsNotFound(err) {
continue
}
return err
}

if !scc.GetDeletionTimestamp().IsZero() {
Expand Down
7 changes: 5 additions & 2 deletions controllers/topolvm_snapshotclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import (
"fmt"

snapapi "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1"
"k8s.io/apimachinery/pkg/api/errors"

lvmv1alpha1 "github.com/openshift/lvm-operator/api/v1alpha1"
"github.com/openshift/lvm-operator/pkg/labels"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
cutil "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/log"
)
Expand Down Expand Up @@ -76,7 +76,10 @@ func (s topolvmVolumeSnapshotClass) ensureDeleted(r *LVMClusterReconciler, ctx c

vsc := &snapapi.VolumeSnapshotClass{}
if err := r.Client.Get(ctx, types.NamespacedName{Name: vscName}, vsc); err != nil {
return client.IgnoreNotFound(err)
if errors.IsNotFound(err) {
continue
}
return err
}

if !vsc.GetDeletionTimestamp().IsZero() {
Expand Down
7 changes: 5 additions & 2 deletions controllers/topolvm_storageclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
"github.com/openshift/lvm-operator/pkg/labels"

storagev1 "k8s.io/api/storage/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
cutil "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/log"
)
Expand Down Expand Up @@ -76,7 +76,10 @@ func (s topolvmStorageClass) ensureDeleted(r *LVMClusterReconciler, ctx context.

sc := &storagev1.StorageClass{}
if err := r.Client.Get(ctx, types.NamespacedName{Name: scName}, sc); err != nil {
return client.IgnoreNotFound(err)
if errors.IsNotFound(err) {
continue
}
return err
}

if !sc.GetDeletionTimestamp().IsZero() {
Expand Down

0 comments on commit 554d501

Please sign in to comment.