Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPVE-677: fix: allow deleting all storageclasses / vgs in case one is already gone #414

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -81,7 +83,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