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

Bug 2308304: csi: stop deleting csi-operator resources #725

Merged
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
5 changes: 0 additions & 5 deletions pkg/operator/ceph/csi/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ var reconcileSaveCSIDriverOptions = SaveCSIDriverOptions
func (r *ReconcileCSI) reconcile(request reconcile.Request) (reconcile.Result, error) {
// reconcileResult is used to communicate the result of the reconciliation back to the caller
var reconcileResult reconcile.Result
var clusterNamespace string

ownerRef, err := k8sutil.GetDeploymentOwnerReference(r.opManagerContext, r.context.Clientset, os.Getenv(k8sutil.PodNameEnvVar), r.opConfig.OperatorNamespace)
if err != nil {
Expand Down Expand Up @@ -295,7 +294,6 @@ func (r *ReconcileCSI) reconcile(request reconcile.Request) (reconcile.Result, e
return opcontroller.ImmediateRetryResult, errors.Wrapf(err, "failed to load cluster info for cluster %q", cluster.Name)
}
clusterInfo.OwnerInfo = k8sutil.NewOwnerInfo(&cephClusters.Items[i], r.scheme)
clusterNamespace = clusterInfo.Namespace

// is holder enabled for this cluster?
thisHolderEnabled := (!csiHostNetworkEnabled || cluster.Spec.Network.IsMultus()) && !csiDisableHolders
Expand Down Expand Up @@ -331,13 +329,10 @@ func (r *ReconcileCSI) reconcile(request reconcile.Request) (reconcile.Result, e
return opcontroller.ImmediateRetryResult, errors.Wrap(err, "failed to reconcile csi-op config CR")
}
return reconcileResult, nil
} else {
r.deleteCSIOperatorResources(clusterNamespace, false)
}
}

if !EnableCSIOperator() {
r.deleteCSIOperatorResources(clusterNamespace, true)

err = r.validateAndConfigureDrivers(serverVersion, ownerInfo)
if err != nil {
Expand Down
17 changes: 0 additions & 17 deletions pkg/operator/ceph/csi/operator_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,3 @@ func (r *ReconcileCSI) createImageSetConfigmap() (string, error) {

return cm.Name, nil
}

func (r *ReconcileCSI) deleteImageSetConfigMap() error {
cm := &v1.ConfigMap{}
err := r.client.Get(r.opManagerContext, types.NamespacedName{Name: cm.Name, Namespace: r.opConfig.OperatorNamespace}, cm)
if err != nil {
if kerrors.IsNotFound(err) {
return nil
}
}
err = r.client.Delete(r.opManagerContext, cm)
if nil != err {
return errors.Wrapf(err, "failed to delete imageSet configMap %v", cm.Name)
}
logger.Infof("deleted imageSet configMap %q", cm.Name)

return nil
}
43 changes: 0 additions & 43 deletions pkg/operator/ceph/csi/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import (
"k8s.io/apimachinery/pkg/version"
"k8s.io/client-go/kubernetes"

csiopv1a1 "github.com/ceph/ceph-csi-operator/api/v1alpha1"
cephcsi "github.com/ceph/ceph-csi/api/deploy/kubernetes"
)

Expand Down Expand Up @@ -759,48 +758,6 @@ func (r *ReconcileCSI) stopDrivers(ver *version.Info) error {
return nil
}

func (r *ReconcileCSI) deleteCSIOperatorResources(clusterNamespace string, deleteOp bool) {
csiCephConnection := &csiopv1a1.CephConnection{}

err := r.client.DeleteAllOf(r.opManagerContext, csiCephConnection, &client.DeleteAllOfOptions{ListOptions: client.ListOptions{Namespace: clusterNamespace}})
if err != nil && !kerrors.IsNotFound(err) {
logger.Errorf("failed to delete CSI-operator Ceph Connection %q. %v", csiCephConnection.Name, err)
} else {
logger.Infof("deleted CSI-operator Ceph Connection %q", csiCephConnection.Name)
}

csiOpClientProfile := &csiopv1a1.ClientProfile{}
err = r.client.DeleteAllOf(r.opManagerContext, csiOpClientProfile, &client.DeleteAllOfOptions{ListOptions: client.ListOptions{Namespace: clusterNamespace}})
if err != nil && !kerrors.IsNotFound(err) {
logger.Errorf("failed to delete CSI-operator client profile %q. %v", csiOpClientProfile.Name, err)
} else {
logger.Infof("deleted CSI-operator client profile %q", csiOpClientProfile.Name)
}

err = r.deleteImageSetConfigMap()
if err != nil && !kerrors.IsNotFound(err) {
logger.Error("failed to delete imageSetConfigMap", err)
}

if deleteOp {
csiDriver := &csiopv1a1.Driver{}
err = r.client.DeleteAllOf(r.opManagerContext, csiDriver, &client.DeleteAllOfOptions{ListOptions: client.ListOptions{Namespace: r.opConfig.OperatorNamespace}})
if err != nil && !kerrors.IsNotFound(err) {
logger.Errorf("failed to delete CSI-operator driver config %q. %v", csiDriver.Name, err)
} else {
logger.Infof("deleted CSI-operator driver config %q", csiDriver.Name)
}

opConfig := &csiopv1a1.OperatorConfig{}
err = r.client.DeleteAllOf(r.opManagerContext, opConfig, &client.DeleteAllOfOptions{ListOptions: client.ListOptions{Namespace: r.opConfig.OperatorNamespace}})
if err != nil && !kerrors.IsNotFound(err) {
logger.Errorf("failed to delete CSI-operator operator config %q. %v", opConfig.Name, err)
} else {
logger.Infof("deleted CSI-operator operator config %q", opConfig.Name)
}
}
}

func (r *ReconcileCSI) deleteCSIDriverResources(ver *version.Info, daemonset, deployment, service, driverName string) error {
csiDriverobj := v1CsiDriver{}
err := k8sutil.DeleteDaemonset(r.opManagerContext, r.context.Clientset, r.opConfig.OperatorNamespace, daemonset)
Expand Down
Loading