Merge pull request #12724 from Madhu-1/close-12645

csi: set ceph cluster as ControllerRef for holder ds
This commit is contained in:
Travis Nielsen authored and GitHub committed 2023-08-22 07:41:30 -06:00
commit 9803bd5aa7
4 files changed
+19 -3

No files matched your search

+4
View File
@@ -38,6 +38,7 @@ import (
v1 "k8s.io/api/core/v1"
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
)
@@ -47,6 +48,7 @@ const (
// ReconcileCSI reconciles a ceph-csi driver
type ReconcileCSI struct {
scheme *runtime.Scheme
client client.Client
context *clusterd.Context
opManagerContext context.Context
@@ -70,6 +72,7 @@ func Add(mgr manager.Manager, context *clusterd.Context, opManagerContext contex
// newReconciler returns a new reconcile.Reconciler
func newReconciler(mgr manager.Manager, context *clusterd.Context, opManagerContext context.Context, opConfig opcontroller.OperatorConfig) reconcile.Reconciler {
return &ReconcileCSI{
scheme: mgr.GetScheme(),
client: mgr.GetClient(),
context: context,
opConfig: opConfig,
@@ -207,6 +210,7 @@ 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)
logger.Debugf("cluster %q is running on multus or CSI_ENABLE_HOST_NETWORK is false, deploying the ceph-csi plugin holder", cluster.Name)
+1
View File
@@ -215,6 +215,7 @@ func TestCephCSIController(t *testing.T) {
c.Client = cl
// // Create a ReconcileCSI object with the scheme and fake client.
r := &ReconcileCSI{
scheme: s,
client: cl,
context: c,
opConfig: controller.OperatorConfig{
+10 -2
View File
@@ -802,8 +802,16 @@ func (r *ReconcileCSI) configureHolder(driver driverDetails, c ClusterDetail, tp
return errors.Wrapf(err, "failed to load ceph %q plugin holder template", driver.fullName)
}
// DO NOT set owner reference on ceph plugin holder daemonset, this DS must never restart unless
// the entire node is rebooted
// As the plugin holder daemonset is created in the operator namespace, we
// need to set the owner reference to the cluster namespace only if the
// operator and cluster are created in same namespace so that the
// plugin holder daemonset is deleted when the cluster is deleted.
if r.opConfig.OperatorNamespace == c.cluster.Namespace {
err = c.clusterInfo.OwnerInfo.SetControllerReference(cephPluginHolder)
if err != nil {
return errors.Wrapf(err, "failed to set owner reference to plugin holder %q", driver.fullName)
}
}
holderPluginTolerations := getToleration(r.opConfig.Parameters, driver.toleration, pluginTolerations)
holderPluginNodeAffinity := getNodeAffinity(r.opConfig.Parameters, driver.nodeAffinity, pluginNodeAffinity)
// apply driver's plugin tolerations and node affinity
+4 -1
View File
@@ -24,6 +24,7 @@ import (
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
rookclient "github.com/rook/rook/pkg/client/clientset/versioned/fake"
"github.com/rook/rook/pkg/clusterd"
"github.com/rook/rook/pkg/daemon/ceph/client"
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
"github.com/rook/rook/pkg/operator/k8sutil"
@@ -73,7 +74,9 @@ func TestReconcileCSI_configureHolders(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Namespace: "rook-ceph", Name: "my-cluster"},
Spec: cephv1.ClusterSpec{},
},
clusterInfo: &cephclient.ClusterInfo{Monitors: map[string]*cephclient.MonInfo{"a": {Name: "a", Endpoint: "10.0.0.1:6789"}}},
clusterInfo: &cephclient.ClusterInfo{
Monitors: map[string]*cephclient.MonInfo{"a": {Name: "a", Endpoint: "10.0.0.1:6789"}},
OwnerInfo: client.NewMinimumOwnerInfoWithOwnerRef()},
},
}