Merge pull request #7618 from alrs/ceph-cluster-imports
ceph: pkg/operator/ceph/cluster double imports
This commit is contained in:
18 files changed
+107
-127
No files matched your search
@@ -27,7 +27,6 @@ import (
|
||||
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
optest "github.com/rook/rook/pkg/operator/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -127,7 +126,7 @@ func TestCephStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNewCephStatusChecker(t *testing.T) {
|
||||
clusterInfo := client.AdminClusterInfo("ns")
|
||||
clusterInfo := cephclient.AdminClusterInfo("ns")
|
||||
c := &clusterd.Context{}
|
||||
time10s, err := time.ParseDuration("10s")
|
||||
assert.NoError(t, err)
|
||||
@@ -158,7 +157,7 @@ func TestNewCephStatusChecker(t *testing.T) {
|
||||
func TestForceDeleteStuckRookPodsOnNotReadyNodes(t *testing.T) {
|
||||
ctx := context.TODO()
|
||||
clientset := optest.New(t, 1)
|
||||
clusterInfo := client.NewClusterInfo("test", "test")
|
||||
clusterInfo := cephclient.NewClusterInfo("test", "test")
|
||||
clusterName := clusterInfo.NamespacedName()
|
||||
|
||||
context := &clusterd.Context{
|
||||
@@ -229,7 +228,7 @@ func TestForceDeleteStuckRookPodsOnNotReadyNodes(t *testing.T) {
|
||||
func TestGetRookPodsOnNode(t *testing.T) {
|
||||
ctx := context.TODO()
|
||||
clientset := optest.New(t, 1)
|
||||
clusterInfo := client.NewClusterInfo("test", "test")
|
||||
clusterInfo := cephclient.NewClusterInfo("test", "test")
|
||||
clusterName := clusterInfo.NamespacedName()
|
||||
context := &clusterd.Context{
|
||||
Clientset: clientset,
|
||||
|
||||
@@ -38,7 +38,6 @@ import (
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/osd"
|
||||
"github.com/rook/rook/pkg/operator/ceph/config"
|
||||
"github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
"github.com/rook/rook/pkg/operator/ceph/csi"
|
||||
cephver "github.com/rook/rook/pkg/operator/ceph/version"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
@@ -98,7 +97,7 @@ func (c *cluster) doOrchestration(rookImage string, cephVersion cephver.CephVers
|
||||
}
|
||||
|
||||
// Start the mon pods
|
||||
opcontroller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionProgressing, v1.ConditionTrue, cephv1.ClusterProgressingReason, "Configuring Ceph Mons")
|
||||
controller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionProgressing, v1.ConditionTrue, cephv1.ClusterProgressingReason, "Configuring Ceph Mons")
|
||||
clusterInfo, err := c.mons.Start(c.ClusterInfo, rookImage, cephVersion, *c.Spec)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to start ceph monitors")
|
||||
@@ -134,7 +133,7 @@ func (c *cluster) doOrchestration(rookImage string, cephVersion cephver.CephVers
|
||||
}
|
||||
|
||||
// Start Ceph manager
|
||||
opcontroller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionProgressing, v1.ConditionTrue, cephv1.ClusterProgressingReason, "Configuring Ceph Mgr(s)")
|
||||
controller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionProgressing, v1.ConditionTrue, cephv1.ClusterProgressingReason, "Configuring Ceph Mgr(s)")
|
||||
mgrs := mgr.New(c.context, c.ClusterInfo, *spec, rookImage)
|
||||
err = mgrs.Start()
|
||||
if err != nil {
|
||||
@@ -142,7 +141,7 @@ func (c *cluster) doOrchestration(rookImage string, cephVersion cephver.CephVers
|
||||
}
|
||||
|
||||
// Start the OSDs
|
||||
opcontroller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionProgressing, v1.ConditionTrue, cephv1.ClusterProgressingReason, "Configuring Ceph OSDs")
|
||||
controller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionProgressing, v1.ConditionTrue, cephv1.ClusterProgressingReason, "Configuring Ceph OSDs")
|
||||
osds := osd.New(c.context, c.ClusterInfo, *spec, rookImage)
|
||||
err = osds.Start()
|
||||
if err != nil {
|
||||
@@ -195,7 +194,7 @@ func (c *ClusterController) initializeCluster(cluster *cluster, clusterObj *ceph
|
||||
if cluster.Spec.External.Enable {
|
||||
err := c.configureExternalCephCluster(cluster)
|
||||
if err != nil {
|
||||
opcontroller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionProgressing, v1.ConditionFalse, cephv1.ClusterProgressingReason, err.Error())
|
||||
controller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionProgressing, v1.ConditionFalse, cephv1.ClusterProgressingReason, err.Error())
|
||||
return errors.Wrap(err, "failed to configure external ceph cluster")
|
||||
}
|
||||
} else {
|
||||
@@ -210,7 +209,7 @@ func (c *ClusterController) initializeCluster(cluster *cluster, clusterObj *ceph
|
||||
|
||||
err = c.configureLocalCephCluster(cluster)
|
||||
if err != nil {
|
||||
opcontroller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionProgressing, v1.ConditionFalse, cephv1.ClusterProgressingReason, err.Error())
|
||||
controller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionProgressing, v1.ConditionFalse, cephv1.ClusterProgressingReason, err.Error())
|
||||
return errors.Wrap(err, "failed to configure local ceph cluster")
|
||||
}
|
||||
}
|
||||
@@ -235,7 +234,7 @@ func (c *ClusterController) configureLocalCephCluster(cluster *cluster) error {
|
||||
cluster.context.Client = c.client
|
||||
|
||||
// Run image validation job
|
||||
opcontroller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionProgressing, v1.ConditionTrue, cephv1.ClusterProgressingReason, "Detecting Ceph version")
|
||||
controller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionProgressing, v1.ConditionTrue, cephv1.ClusterProgressingReason, "Detecting Ceph version")
|
||||
cephVersion, isUpgrade, err := c.detectAndValidateCephVersion(cluster)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed the ceph version check")
|
||||
@@ -243,7 +242,7 @@ func (c *ClusterController) configureLocalCephCluster(cluster *cluster) error {
|
||||
|
||||
// Set the value of isUpgrade based on the image discovery done by detectAndValidateCephVersion()
|
||||
cluster.isUpgrade = isUpgrade
|
||||
opcontroller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionProgressing, v1.ConditionTrue, cephv1.ClusterProgressingReason, "Configuring the Ceph cluster")
|
||||
controller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionProgressing, v1.ConditionTrue, cephv1.ClusterProgressingReason, "Configuring the Ceph cluster")
|
||||
|
||||
// Run the orchestration
|
||||
err = cluster.doOrchestration(c.rookImage, *cephVersion, cluster.Spec)
|
||||
@@ -252,7 +251,7 @@ func (c *ClusterController) configureLocalCephCluster(cluster *cluster) error {
|
||||
}
|
||||
|
||||
// Set the condition to the cluster object
|
||||
opcontroller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionReady, v1.ConditionTrue, cephv1.ClusterCreatedReason, "Cluster created successfully")
|
||||
controller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionReady, v1.ConditionTrue, cephv1.ClusterCreatedReason, "Cluster created successfully")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -31,13 +31,11 @@ import (
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/osd/kms"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/osd"
|
||||
controllerutil "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
"github.com/rook/rook/pkg/operator/ceph/csi"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
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"
|
||||
@@ -354,7 +352,7 @@ func (c *ClusterController) onAdd(clusterObj *cephv1.CephCluster, ownerInfo *k8s
|
||||
}
|
||||
|
||||
func (c *ClusterController) requestClusterDelete(cluster *cephv1.CephCluster) (reconcile.Result, bool) {
|
||||
opcontroller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionDeleting, v1.ConditionTrue, cephv1.ClusterDeletingReason, "Cluster is deleting")
|
||||
opcontroller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionDeleting, corev1.ConditionTrue, cephv1.ClusterDeletingReason, "Cluster is deleting")
|
||||
|
||||
if existing, ok := c.clusterMap[cluster.Namespace]; ok && existing.namespacedName.Name != cluster.Name {
|
||||
logger.Errorf("skipping deletion of cluster cr %q in namespace %q. cluster CR %q already exists in this namespace. only one cluster cr per namespace is supported.",
|
||||
@@ -385,7 +383,7 @@ func (c *ClusterController) requestClusterDelete(cluster *cephv1.CephCluster) (r
|
||||
} else {
|
||||
err := c.checkIfVolumesExist(cluster)
|
||||
if err != nil {
|
||||
opcontroller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionDeleting, v1.ConditionFalse, "ClusterDeleting", err.Error())
|
||||
opcontroller.UpdateCondition(c.context, c.namespacedName, cephv1.ConditionDeleting, corev1.ConditionFalse, "ClusterDeleting", err.Error())
|
||||
logger.Errorf("failed to check if volumes exist. %v", err)
|
||||
return opcontroller.WaitForRequeueIfFinalizerBlocked, false
|
||||
}
|
||||
@@ -421,7 +419,7 @@ func (c *ClusterController) checkIfVolumesExist(cluster *cephv1.CephCluster) err
|
||||
return err
|
||||
}
|
||||
}
|
||||
if !controllerutil.FlexDriverEnabled(c.context) {
|
||||
if !opcontroller.FlexDriverEnabled(c.context) {
|
||||
logger.Debugf("Flex driver disabled, skipping check for volume attachments for cluster %q", cluster.Namespace)
|
||||
return nil
|
||||
}
|
||||
|
||||
Executable → Regular
File mode changed.
@@ -23,7 +23,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephver "github.com/rook/rook/pkg/operator/ceph/version"
|
||||
"github.com/rook/rook/pkg/operator/test"
|
||||
@@ -54,7 +53,7 @@ func TestGetOrGeneratePassword(t *testing.T) {
|
||||
ctx := context.TODO()
|
||||
clientset := test.New(t, 3)
|
||||
ownerInfo := cephclient.NewMinimumOwnerInfoWithOwnerRef()
|
||||
clusterInfo := &client.ClusterInfo{Namespace: "myns", OwnerInfo: ownerInfo}
|
||||
clusterInfo := &cephclient.ClusterInfo{Namespace: "myns", OwnerInfo: ownerInfo}
|
||||
c := &Cluster{context: &clusterd.Context{Clientset: clientset}, clusterInfo: clusterInfo}
|
||||
_, err := c.context.Clientset.CoreV1().Secrets(clusterInfo.Namespace).Get(ctx, dashboardPasswordName, metav1.GetOptions{})
|
||||
assert.True(t, kerrors.IsNotFound(err))
|
||||
|
||||
@@ -29,7 +29,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/mon"
|
||||
"github.com/rook/rook/pkg/operator/ceph/config"
|
||||
@@ -325,7 +324,7 @@ func startModuleConfiguration(description string, configureModules func() error)
|
||||
|
||||
// Ceph docs about the prometheus module: http://docs.ceph.com/docs/master/mgr/prometheus/
|
||||
func (c *Cluster) enablePrometheusModule() error {
|
||||
if err := client.MgrEnableModule(c.context, c.clusterInfo, PrometheusModuleName, true); err != nil {
|
||||
if err := cephclient.MgrEnableModule(c.context, c.clusterInfo, PrometheusModuleName, true); err != nil {
|
||||
return errors.Wrap(err, "failed to enable mgr prometheus module")
|
||||
}
|
||||
return nil
|
||||
@@ -333,7 +332,7 @@ func (c *Cluster) enablePrometheusModule() error {
|
||||
|
||||
// Ceph docs about the crash module: https://docs.ceph.com/docs/master/mgr/crash/
|
||||
func (c *Cluster) enableCrashModule() error {
|
||||
if err := client.MgrEnableModule(c.context, c.clusterInfo, crashModuleName, true); err != nil {
|
||||
if err := cephclient.MgrEnableModule(c.context, c.clusterInfo, crashModuleName, true); err != nil {
|
||||
return errors.Wrap(err, "failed to enable mgr crash module")
|
||||
}
|
||||
return nil
|
||||
@@ -343,13 +342,13 @@ func (c *Cluster) enableBalancerModule() error {
|
||||
// The order MATTERS, always configure this module first, then turn it on
|
||||
|
||||
// This sets min compat client to luminous and the balancer module mode
|
||||
err := client.ConfigureBalancerModule(c.context, c.clusterInfo, balancerModuleMode)
|
||||
err := cephclient.ConfigureBalancerModule(c.context, c.clusterInfo, balancerModuleMode)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to configure module %q", balancerModuleName)
|
||||
}
|
||||
|
||||
// This turns "on" the balancer
|
||||
err = client.MgrEnableModule(c.context, c.clusterInfo, balancerModuleName, false)
|
||||
err = cephclient.MgrEnableModule(c.context, c.clusterInfo, balancerModuleName, false)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to turn on mgr %q module", balancerModuleName)
|
||||
}
|
||||
@@ -374,13 +373,13 @@ func (c *Cluster) configureMgrModules() error {
|
||||
if module.Enabled {
|
||||
if module.Name == balancerModuleName {
|
||||
// Configure balancer module mode
|
||||
err := client.ConfigureBalancerModule(c.context, c.clusterInfo, balancerModuleMode)
|
||||
err := cephclient.ConfigureBalancerModule(c.context, c.clusterInfo, balancerModuleMode)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to configure module %q", module.Name)
|
||||
}
|
||||
}
|
||||
|
||||
if err := client.MgrEnableModule(c.context, c.clusterInfo, module.Name, false); err != nil {
|
||||
if err := cephclient.MgrEnableModule(c.context, c.clusterInfo, module.Name, false); err != nil {
|
||||
return errors.Wrapf(err, "failed to enable mgr module %q", module.Name)
|
||||
}
|
||||
|
||||
@@ -402,7 +401,7 @@ func (c *Cluster) configureMgrModules() error {
|
||||
}
|
||||
|
||||
} else {
|
||||
if err := client.MgrDisableModule(c.context, c.clusterInfo, module.Name); err != nil {
|
||||
if err := cephclient.MgrDisableModule(c.context, c.clusterInfo, module.Name); err != nil {
|
||||
return errors.Wrapf(err, "failed to disable mgr module %q", module.Name)
|
||||
}
|
||||
}
|
||||
|
||||
Executable → Regular
+2
-4
@@ -36,9 +36,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tevino/abool"
|
||||
apps "k8s.io/api/apps/v1"
|
||||
v1 "k8s.io/api/apps/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
@@ -51,7 +49,7 @@ func TestStartMgr(t *testing.T) {
|
||||
return "{\"key\":\"mysecurekey\"}", nil
|
||||
},
|
||||
}
|
||||
waitForDeploymentToStart = func(clusterdContext *clusterd.Context, deployment *v1.Deployment) error {
|
||||
waitForDeploymentToStart = func(clusterdContext *clusterd.Context, deployment *apps.Deployment) error {
|
||||
logger.Infof("simulated mgr deployment starting")
|
||||
return nil
|
||||
}
|
||||
@@ -217,7 +215,7 @@ func TestMgrSidecarReconcile(t *testing.T) {
|
||||
assert.True(t, calledMgrStat)
|
||||
assert.False(t, calledMgrDump)
|
||||
_, err = c.context.Clientset.CoreV1().Services(c.clusterInfo.Namespace).Get(context.TODO(), "rook-ceph-mgr", metav1.GetOptions{})
|
||||
assert.True(t, kerrors.IsNotFound(err))
|
||||
assert.True(t, errors.IsNotFound(err))
|
||||
|
||||
// nothing is updated when the requested mgr is not the active mgr
|
||||
activeMgr = "b"
|
||||
|
||||
@@ -23,10 +23,8 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
rookcephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
rookv1 "github.com/rook/rook/pkg/apis/rook.io/v1"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/mon"
|
||||
opmon "github.com/rook/rook/pkg/operator/ceph/cluster/mon"
|
||||
"github.com/rook/rook/pkg/operator/ceph/config"
|
||||
"github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
@@ -185,7 +183,7 @@ func (c *Cluster) makeMgrDaemonContainer(mgrConfig *mgrConfig) v1.Container {
|
||||
}
|
||||
|
||||
// If the liveness probe is enabled
|
||||
container = config.ConfigureLivenessProbe(rookcephv1.KeyMgr, container, c.spec.HealthCheck)
|
||||
container = config.ConfigureLivenessProbe(cephv1.KeyMgr, container, c.spec.HealthCheck)
|
||||
|
||||
// If host networking is enabled, we don't need a bind addr that is different from the public addr
|
||||
if !c.spec.Network.IsHost() {
|
||||
@@ -204,11 +202,11 @@ func (c *Cluster) makeMgrSidecarContainer(mgrConfig *mgrConfig) v1.Container {
|
||||
{Name: "ROOK_CLUSTER_NAME", Value: string(c.clusterInfo.NamespacedName().Name)},
|
||||
k8sutil.PodIPEnvVar(k8sutil.PrivateIPEnvVar),
|
||||
k8sutil.PodIPEnvVar(k8sutil.PublicIPEnvVar),
|
||||
opmon.PodNamespaceEnvVar(c.clusterInfo.Namespace),
|
||||
opmon.EndpointEnvVar(),
|
||||
opmon.SecretEnvVar(),
|
||||
opmon.CephUsernameEnvVar(),
|
||||
opmon.CephSecretEnvVar(),
|
||||
mon.PodNamespaceEnvVar(c.clusterInfo.Namespace),
|
||||
mon.EndpointEnvVar(),
|
||||
mon.SecretEnvVar(),
|
||||
mon.CephUsernameEnvVar(),
|
||||
mon.CephSecretEnvVar(),
|
||||
k8sutil.ConfigOverrideEnvVar(),
|
||||
{Name: "ROOK_FSID", ValueFrom: &v1.EnvVarSource{
|
||||
SecretKeyRef: &v1.SecretKeySelector{
|
||||
@@ -332,7 +330,7 @@ func (c *Cluster) cephMgrOrchestratorModuleEnvs() []v1.EnvVar {
|
||||
operatorNamespace := os.Getenv(k8sutil.PodNamespaceEnvVar)
|
||||
envVars := []v1.EnvVar{
|
||||
{Name: "ROOK_OPERATOR_NAMESPACE", Value: operatorNamespace},
|
||||
{Name: "ROOK_CEPH_CLUSTER_CRD_VERSION", Value: rookcephv1.Version},
|
||||
{Name: "ROOK_CEPH_CLUSTER_CRD_VERSION", Value: cephv1.Version},
|
||||
{Name: "ROOK_CEPH_CLUSTER_CRD_NAME", Value: c.clusterInfo.NamespacedName().Name},
|
||||
k8sutil.PodIPEnvVar(podIPEnvVar),
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
"github.com/rook/rook/pkg/operator/ceph/csi"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
@@ -119,10 +118,10 @@ func CreateOrLoadClusterInfo(clusterdContext *clusterd.Context, namespace string
|
||||
clusterInfo.CephCred.Username = string(cephUsername)
|
||||
clusterInfo.CephCred.Secret = string(secrets.Data[cephUserSecretKey])
|
||||
} else if adminSecretKey, ok := secrets.Data[adminSecretNameKey]; ok {
|
||||
clusterInfo.CephCred.Username = client.AdminUsername
|
||||
clusterInfo.CephCred.Username = cephclient.AdminUsername
|
||||
clusterInfo.CephCred.Secret = string(adminSecretKey)
|
||||
|
||||
secrets.Data[cephUsernameKey] = []byte(client.AdminUsername)
|
||||
secrets.Data[cephUsernameKey] = []byte(cephclient.AdminUsername)
|
||||
secrets.Data[cephUserSecretKey] = adminSecretKey
|
||||
if _, err = clusterdContext.Clientset.CoreV1().Secrets(namespace).Update(ctx, secrets, metav1.UpdateOptions{}); err != nil {
|
||||
return nil, maxMonID, monMapping, errors.Wrap(err, "failed to update mon secrets")
|
||||
@@ -143,7 +142,7 @@ func CreateOrLoadClusterInfo(clusterdContext *clusterd.Context, namespace string
|
||||
// Some people might want to give the admin key
|
||||
// The necessary users/keys/secrets will be created by Rook
|
||||
// This is also done to allow backward compatibility
|
||||
if clusterInfo.CephCred.Username == client.AdminUsername && clusterInfo.CephCred.Secret != adminSecretNameKey {
|
||||
if clusterInfo.CephCred.Username == cephclient.AdminUsername && clusterInfo.CephCred.Secret != adminSecretNameKey {
|
||||
return clusterInfo, maxMonID, monMapping, nil
|
||||
}
|
||||
|
||||
@@ -318,7 +317,7 @@ func createNamedClusterInfo(context *clusterd.Context, namespace string) (*cephc
|
||||
"--cap", "osd", "'allow *'",
|
||||
"--cap", "mgr", "'allow *'",
|
||||
"--cap", "mds", "'allow'"}
|
||||
adminSecret, err := genSecret(context.Executor, dir, client.AdminUsername, args)
|
||||
adminSecret, err := genSecret(context.Executor, dir, cephclient.AdminUsername, args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -328,7 +327,7 @@ func createNamedClusterInfo(context *clusterd.Context, namespace string) (*cephc
|
||||
MonitorSecret: monSecret,
|
||||
Namespace: namespace,
|
||||
CephCred: cephclient.CephCred{
|
||||
Username: client.AdminUsername,
|
||||
Username: cephclient.AdminUsername,
|
||||
Secret: adminSecret,
|
||||
},
|
||||
}, nil
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephutil "github.com/rook/rook/pkg/daemon/ceph/util"
|
||||
"github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
@@ -111,7 +110,7 @@ func (c *Cluster) checkHealth() error {
|
||||
|
||||
// For an external connection we use a special function to get the status
|
||||
if c.spec.External.Enable {
|
||||
quorumStatus, err := client.GetMonQuorumStatus(c.context, c.ClusterInfo)
|
||||
quorumStatus, err := cephclient.GetMonQuorumStatus(c.context, c.ClusterInfo)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get external mon quorum status")
|
||||
}
|
||||
@@ -121,7 +120,7 @@ func (c *Cluster) checkHealth() error {
|
||||
|
||||
// connect to the mons
|
||||
// get the status and check for quorum
|
||||
quorumStatus, err := client.GetMonQuorumStatus(c.context, c.ClusterInfo)
|
||||
quorumStatus, err := cephclient.GetMonQuorumStatus(c.context, c.ClusterInfo)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get mon quorum status")
|
||||
}
|
||||
@@ -469,7 +468,7 @@ func (c *Cluster) removeMon(daemonName string) error {
|
||||
func (c *Cluster) removeMonitorFromQuorum(name string) error {
|
||||
logger.Debugf("removing monitor %s", name)
|
||||
args := []string{"mon", "remove", name}
|
||||
if _, err := client.NewCephCommand(c.context, c.ClusterInfo, args).Run(); err != nil {
|
||||
if _, err := cephclient.NewCephCommand(c.context, c.ClusterInfo, args).Run(); err != nil {
|
||||
return errors.Wrapf(err, "mon %s remove failed", name)
|
||||
}
|
||||
|
||||
@@ -477,7 +476,7 @@ func (c *Cluster) removeMonitorFromQuorum(name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cluster) handleExternalMonStatus(status client.MonStatusResponse) error {
|
||||
func (c *Cluster) handleExternalMonStatus(status cephclient.MonStatusResponse) error {
|
||||
// We don't need to validate Ceph version if no image is present
|
||||
if c.spec.CephVersion.Image != "" {
|
||||
_, err := controller.ValidateCephVersionsBetweenLocalAndExternalClusters(c.context, c.ClusterInfo)
|
||||
@@ -501,7 +500,7 @@ func (c *Cluster) handleExternalMonStatus(status client.MonStatusResponse) error
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cluster) addOrRemoveExternalMonitor(status client.MonStatusResponse) (bool, error) {
|
||||
func (c *Cluster) addOrRemoveExternalMonitor(status cephclient.MonStatusResponse) (bool, error) {
|
||||
var changed bool
|
||||
oldClusterInfoMonitors := map[string]*cephclient.MonInfo{}
|
||||
// clearing the content of clusterinfo monitors
|
||||
|
||||
@@ -28,7 +28,6 @@ import (
|
||||
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
clienttest "github.com/rook/rook/pkg/daemon/ceph/client/test"
|
||||
"github.com/rook/rook/pkg/operator/ceph/config"
|
||||
@@ -325,9 +324,9 @@ func TestAddOrRemoveExternalMonitor(t *testing.T) {
|
||||
var err error
|
||||
|
||||
// populate fake monmap
|
||||
fakeResp := client.MonStatusResponse{Quorum: []int{0}}
|
||||
fakeResp := cephclient.MonStatusResponse{Quorum: []int{0}}
|
||||
|
||||
fakeResp.MonMap.Mons = []client.MonMapEntry{
|
||||
fakeResp.MonMap.Mons = []cephclient.MonMapEntry{
|
||||
{
|
||||
Name: "a",
|
||||
},
|
||||
@@ -335,7 +334,7 @@ func TestAddOrRemoveExternalMonitor(t *testing.T) {
|
||||
fakeResp.MonMap.Mons[0].PublicAddr = "172.17.0.4:3300"
|
||||
|
||||
// populate fake ClusterInfo
|
||||
c := &Cluster{ClusterInfo: &client.ClusterInfo{}}
|
||||
c := &Cluster{ClusterInfo: &cephclient.ClusterInfo{}}
|
||||
c.ClusterInfo = clienttest.CreateTestClusterInfo(1)
|
||||
|
||||
//
|
||||
@@ -365,7 +364,7 @@ func TestAddOrRemoveExternalMonitor(t *testing.T) {
|
||||
//
|
||||
// Now let's add a new mon in the external cluster
|
||||
// ClusterInfo should be updated with this new monitor
|
||||
fakeResp.MonMap.Mons = []client.MonMapEntry{
|
||||
fakeResp.MonMap.Mons = []cephclient.MonMapEntry{
|
||||
{
|
||||
Name: "a",
|
||||
},
|
||||
|
||||
@@ -35,7 +35,6 @@ import (
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
rookv1 "github.com/rook/rook/pkg/apis/rook.io/v1"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephutil "github.com/rook/rook/pkg/daemon/ceph/util"
|
||||
"github.com/rook/rook/pkg/operator/ceph/config"
|
||||
@@ -316,12 +315,12 @@ func (c *Cluster) configureStretchCluster(mons []*monConfig) error {
|
||||
}
|
||||
|
||||
// Enable the mon connectivity strategy
|
||||
if err := client.EnableStretchElectionStrategy(c.context, c.ClusterInfo); err != nil {
|
||||
if err := cephclient.EnableStretchElectionStrategy(c.context, c.ClusterInfo); err != nil {
|
||||
return errors.Wrap(err, "failed to enable stretch cluster")
|
||||
}
|
||||
|
||||
// Create the default crush rule for stretch clusters, that by default will also apply to all pools
|
||||
if err := client.CreateDefaultStretchCrushRule(c.context, c.ClusterInfo, &c.spec, c.stretchFailureDomainName()); err != nil {
|
||||
if err := cephclient.CreateDefaultStretchCrushRule(c.context, c.ClusterInfo, &c.spec, c.stretchFailureDomainName()); err != nil {
|
||||
return errors.Wrap(err, "failed to create default stretch rule")
|
||||
}
|
||||
|
||||
@@ -348,7 +347,7 @@ func (c *Cluster) assignStretchMonsToZones(mons []*monConfig) error {
|
||||
arbiterZone := c.getArbiterZone()
|
||||
|
||||
// Get the mon dump to see if the zones are already applied to the mons
|
||||
monDump, err := client.GetMonDump(c.context, c.ClusterInfo)
|
||||
monDump, err := cephclient.GetMonDump(c.context, c.ClusterInfo)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to detect if stretch mons are already assigned to zones")
|
||||
}
|
||||
@@ -376,7 +375,7 @@ func (c *Cluster) assignStretchMonsToZones(mons []*monConfig) error {
|
||||
continue
|
||||
}
|
||||
logger.Infof("setting mon %q to stretch %s=%s", mon.DaemonName, domainName, mon.Zone)
|
||||
if err := client.SetMonStretchZone(c.context, c.ClusterInfo, mon.DaemonName, domainName, mon.Zone); err != nil {
|
||||
if err := cephclient.SetMonStretchZone(c.context, c.ClusterInfo, mon.DaemonName, domainName, mon.Zone); err != nil {
|
||||
return errors.Wrapf(err, "failed to set mon %q zone", mon.DaemonName)
|
||||
}
|
||||
}
|
||||
@@ -388,7 +387,7 @@ func (c *Cluster) ConfigureArbiter() error {
|
||||
return errors.New("arbiter not specified for the stretch cluster")
|
||||
}
|
||||
|
||||
monDump, err := client.GetMonDump(c.context, c.ClusterInfo)
|
||||
monDump, err := cephclient.GetMonDump(c.context, c.ClusterInfo)
|
||||
if err != nil {
|
||||
logger.Warningf("attempting to enable arbiter after failed to detect if already enabled. %v", err)
|
||||
} else if monDump.StretchMode {
|
||||
@@ -411,7 +410,7 @@ func (c *Cluster) ConfigureArbiter() error {
|
||||
}
|
||||
|
||||
// Set the mon tiebreaker
|
||||
if err := client.SetMonStretchTiebreaker(c.context, c.ClusterInfo, c.arbiterMon, failureDomain); err != nil {
|
||||
if err := cephclient.SetMonStretchTiebreaker(c.context, c.ClusterInfo, c.arbiterMon, failureDomain); err != nil {
|
||||
return errors.Wrap(err, "failed to set mon tiebreaker")
|
||||
}
|
||||
|
||||
@@ -434,7 +433,7 @@ func (c *Cluster) readyToConfigureArbiter(checkOSDPods bool) (bool, error) {
|
||||
}
|
||||
}
|
||||
|
||||
crushMap, err := client.GetCrushMap(c.context, c.ClusterInfo)
|
||||
crushMap, err := cephclient.GetCrushMap(c.context, c.ClusterInfo)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "failed to get crush map")
|
||||
}
|
||||
@@ -1025,7 +1024,7 @@ func (c *Cluster) startDeployments(mons []*monConfig, requireAllInQuorum bool) e
|
||||
// Final verification that **all** mons are in quorum
|
||||
// Do not proceed if one monitor is still syncing
|
||||
// Only do this when monitors versions are different so we don't block the orchestration if a mon is down.
|
||||
versions, err := client.GetAllCephDaemonVersions(c.context, c.ClusterInfo)
|
||||
versions, err := cephclient.GetAllCephDaemonVersions(c.context, c.ClusterInfo)
|
||||
if err != nil {
|
||||
logger.Warningf("failed to get ceph daemons versions; this likely means there is no cluster yet. %v", err)
|
||||
} else {
|
||||
@@ -1368,7 +1367,7 @@ func waitForQuorumWithMons(context *clusterd.Context, clusterInfo *cephclient.Cl
|
||||
|
||||
// get the quorum_status response that contains info about all monitors in the mon map and
|
||||
// their quorum status
|
||||
monQuorumStatusResp, err := client.GetMonQuorumStatus(context, clusterInfo)
|
||||
monQuorumStatusResp, err := cephclient.GetMonQuorumStatus(context, clusterInfo)
|
||||
if err != nil {
|
||||
logger.Debugf("failed to get quorum_status. %v", err)
|
||||
continue
|
||||
@@ -1399,7 +1398,7 @@ func waitForQuorumWithMons(context *clusterd.Context, clusterInfo *cephclient.Cl
|
||||
return nil
|
||||
}
|
||||
|
||||
func logQuorumMembers(monQuorumStatusResp client.MonStatusResponse) {
|
||||
func logQuorumMembers(monQuorumStatusResp cephclient.MonStatusResponse) {
|
||||
var monsInQuorum []string
|
||||
for _, m := range monQuorumStatusResp.MonMap.Mons {
|
||||
if monFoundInQuorum(m.Name, monQuorumStatusResp) {
|
||||
@@ -1409,9 +1408,9 @@ func logQuorumMembers(monQuorumStatusResp client.MonStatusResponse) {
|
||||
logger.Infof("Monitors in quorum: %v", monsInQuorum)
|
||||
}
|
||||
|
||||
func monFoundInQuorum(name string, monQuorumStatusResp client.MonStatusResponse) bool {
|
||||
func monFoundInQuorum(name string, monQuorumStatusResp cephclient.MonStatusResponse) bool {
|
||||
// first get the initial monitors corresponding mon map entry
|
||||
var monMapEntry *client.MonMapEntry
|
||||
var monMapEntry *cephclient.MonMapEntry
|
||||
for i := range monQuorumStatusResp.MonMap.Mons {
|
||||
if name == monQuorumStatusResp.MonMap.Mons[i].Name {
|
||||
monMapEntry = &monQuorumStatusResp.MonMap.Mons[i]
|
||||
|
||||
@@ -33,7 +33,6 @@ import (
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
rookv1 "github.com/rook/rook/pkg/apis/rook.io/v1"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
clienttest "github.com/rook/rook/pkg/daemon/ceph/client/test"
|
||||
"github.com/rook/rook/pkg/operator/ceph/config"
|
||||
@@ -325,7 +324,7 @@ func TestMaxMonID(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMonInQuorum(t *testing.T) {
|
||||
entry := client.MonMapEntry{Name: "foo", Rank: 23}
|
||||
entry := cephclient.MonMapEntry{Name: "foo", Rank: 23}
|
||||
quorum := []int{}
|
||||
// Nothing in quorum
|
||||
assert.False(t, monInQuorum(entry, quorum))
|
||||
@@ -366,7 +365,7 @@ func TestWaitForQuorum(t *testing.T) {
|
||||
namespace := "ns"
|
||||
quorumChecks := 0
|
||||
quorumResponse := func() (string, error) {
|
||||
mons := map[string]*client.MonInfo{
|
||||
mons := map[string]*cephclient.MonInfo{
|
||||
"a": {},
|
||||
}
|
||||
quorumChecks++
|
||||
@@ -381,17 +380,17 @@ func TestWaitForQuorum(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
requireAllInQuorum := false
|
||||
expectedMons := []string{"a"}
|
||||
clusterInfo := &client.ClusterInfo{Namespace: namespace}
|
||||
clusterInfo := &cephclient.ClusterInfo{Namespace: namespace}
|
||||
err = waitForQuorumWithMons(context, clusterInfo, expectedMons, 0, requireAllInQuorum)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestMonFoundInQuorum(t *testing.T) {
|
||||
response := client.MonStatusResponse{}
|
||||
response := cephclient.MonStatusResponse{}
|
||||
|
||||
// "a" is in quorum
|
||||
response.Quorum = []int{0}
|
||||
response.MonMap.Mons = []client.MonMapEntry{
|
||||
response.MonMap.Mons = []cephclient.MonMapEntry{
|
||||
{Name: "a", Rank: 0},
|
||||
{Name: "b", Rank: 1},
|
||||
{Name: "c", Rank: 2},
|
||||
|
||||
@@ -30,7 +30,6 @@ import (
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
apps "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
@@ -104,7 +103,7 @@ func (c *Cluster) makeDeployment(monConfig *monConfig, canary bool) (*apps.Deplo
|
||||
Selector: &metav1.LabelSelector{
|
||||
MatchLabels: c.getLabels(monConfig, canary, false),
|
||||
},
|
||||
Template: v1.PodTemplateSpec{
|
||||
Template: corev1.PodTemplateSpec{
|
||||
ObjectMeta: pod.ObjectMeta,
|
||||
Spec: pod.Spec,
|
||||
},
|
||||
@@ -117,18 +116,18 @@ func (c *Cluster) makeDeployment(monConfig *monConfig, canary bool) (*apps.Deplo
|
||||
return d, nil
|
||||
}
|
||||
|
||||
func (c *Cluster) makeDeploymentPVC(m *monConfig, canary bool) (*v1.PersistentVolumeClaim, error) {
|
||||
func (c *Cluster) makeDeploymentPVC(m *monConfig, canary bool) (*corev1.PersistentVolumeClaim, error) {
|
||||
template := c.monVolumeClaimTemplate(m)
|
||||
volumeMode := v1.PersistentVolumeFilesystem
|
||||
pvc := &v1.PersistentVolumeClaim{
|
||||
volumeMode := corev1.PersistentVolumeFilesystem
|
||||
pvc := &corev1.PersistentVolumeClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: m.ResourceName,
|
||||
Namespace: c.Namespace,
|
||||
Labels: c.getLabels(m, canary, true),
|
||||
},
|
||||
Spec: v1.PersistentVolumeClaimSpec{
|
||||
AccessModes: []v1.PersistentVolumeAccessMode{
|
||||
v1.ReadWriteOnce,
|
||||
Spec: corev1.PersistentVolumeClaimSpec{
|
||||
AccessModes: []corev1.PersistentVolumeAccessMode{
|
||||
corev1.ReadWriteOnce,
|
||||
},
|
||||
Resources: template.Spec.Resources,
|
||||
StorageClassName: template.Spec.StorageClassName,
|
||||
@@ -144,12 +143,12 @@ func (c *Cluster) makeDeploymentPVC(m *monConfig, canary bool) (*v1.PersistentVo
|
||||
}
|
||||
|
||||
// k8s uses limit as the resource request fallback
|
||||
if _, ok := pvc.Spec.Resources.Limits[v1.ResourceStorage]; ok {
|
||||
if _, ok := pvc.Spec.Resources.Limits[corev1.ResourceStorage]; ok {
|
||||
return pvc, nil
|
||||
}
|
||||
|
||||
// specific request in the crd
|
||||
if _, ok := pvc.Spec.Resources.Requests[v1.ResourceStorage]; ok {
|
||||
if _, ok := pvc.Spec.Resources.Requests[corev1.ResourceStorage]; ok {
|
||||
return pvc, nil
|
||||
}
|
||||
|
||||
@@ -159,24 +158,24 @@ func (c *Cluster) makeDeploymentPVC(m *monConfig, canary bool) (*v1.PersistentVo
|
||||
}
|
||||
|
||||
if pvc.Spec.Resources.Requests == nil {
|
||||
pvc.Spec.Resources.Requests = v1.ResourceList{}
|
||||
pvc.Spec.Resources.Requests = corev1.ResourceList{}
|
||||
}
|
||||
pvc.Spec.Resources.Requests[v1.ResourceStorage] = req
|
||||
pvc.Spec.Resources.Requests[corev1.ResourceStorage] = req
|
||||
|
||||
return pvc, nil
|
||||
}
|
||||
|
||||
func (c *Cluster) makeMonPod(monConfig *monConfig, canary bool) (*v1.Pod, error) {
|
||||
func (c *Cluster) makeMonPod(monConfig *monConfig, canary bool) (*corev1.Pod, error) {
|
||||
logger.Debugf("monConfig: %+v", monConfig)
|
||||
podSpec := v1.PodSpec{
|
||||
InitContainers: []v1.Container{
|
||||
podSpec := corev1.PodSpec{
|
||||
InitContainers: []corev1.Container{
|
||||
c.makeChownInitContainer(monConfig),
|
||||
c.makeMonFSInitContainer(monConfig),
|
||||
},
|
||||
Containers: []v1.Container{
|
||||
Containers: []corev1.Container{
|
||||
c.makeMonDaemonContainer(monConfig),
|
||||
},
|
||||
RestartPolicy: v1.RestartPolicyAlways,
|
||||
RestartPolicy: corev1.RestartPolicyAlways,
|
||||
// we decide later whether to use a PVC volume or host volumes for mons, so only populate
|
||||
// the base volumes at this point.
|
||||
Volumes: controller.DaemonVolumesBase(monConfig.DataPathMap, keyringStoreName),
|
||||
@@ -196,7 +195,7 @@ func (c *Cluster) makeMonPod(monConfig *monConfig, canary bool) (*v1.Pod, error)
|
||||
k8sutil.AddUnreachableNodeToleration(&podSpec)
|
||||
}
|
||||
|
||||
pod := &v1.Pod{
|
||||
pod := &corev1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: monConfig.ResourceName,
|
||||
Namespace: c.Namespace,
|
||||
@@ -208,7 +207,7 @@ func (c *Cluster) makeMonPod(monConfig *monConfig, canary bool) (*v1.Pod, error)
|
||||
cephv1.GetMonLabels(c.spec.Labels).ApplyToObjectMeta(&pod.ObjectMeta)
|
||||
|
||||
if c.spec.Network.IsHost() {
|
||||
pod.Spec.DNSPolicy = v1.DNSClusterFirstWithHostNet
|
||||
pod.Spec.DNSPolicy = corev1.DNSClusterFirstWithHostNet
|
||||
} else if c.spec.Network.NetworkSpec.IsMultus() {
|
||||
if err := k8sutil.ApplyMultus(c.spec.Network.NetworkSpec, &pod.ObjectMeta); err != nil {
|
||||
return nil, err
|
||||
@@ -220,7 +219,7 @@ func (c *Cluster) makeMonPod(monConfig *monConfig, canary bool) (*v1.Pod, error)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to generate mon %q node affinity", monConfig.DaemonName)
|
||||
}
|
||||
pod.Spec.Affinity = &v1.Affinity{NodeAffinity: nodeAffinity}
|
||||
pod.Spec.Affinity = &corev1.Affinity{NodeAffinity: nodeAffinity}
|
||||
}
|
||||
|
||||
return pod, nil
|
||||
@@ -232,7 +231,7 @@ func (c *Cluster) makeMonPod(monConfig *monConfig, canary bool) (*v1.Pod, error)
|
||||
|
||||
// Init and daemon containers require the same context, so we call it 'pod' context
|
||||
|
||||
func (c *Cluster) makeChownInitContainer(monConfig *monConfig) v1.Container {
|
||||
func (c *Cluster) makeChownInitContainer(monConfig *monConfig) corev1.Container {
|
||||
return controller.ChownCephDataDirsInitContainer(
|
||||
*monConfig.DataPathMap,
|
||||
c.spec.CephVersion.Image,
|
||||
@@ -242,8 +241,8 @@ func (c *Cluster) makeChownInitContainer(monConfig *monConfig) v1.Container {
|
||||
)
|
||||
}
|
||||
|
||||
func (c *Cluster) makeMonFSInitContainer(monConfig *monConfig) v1.Container {
|
||||
return v1.Container{
|
||||
func (c *Cluster) makeMonFSInitContainer(monConfig *monConfig) corev1.Container {
|
||||
return corev1.Container{
|
||||
Name: "init-mon-fs",
|
||||
Command: []string{
|
||||
cephMonCommand,
|
||||
@@ -264,7 +263,7 @@ func (c *Cluster) makeMonFSInitContainer(monConfig *monConfig) v1.Container {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cluster) makeMonDaemonContainer(monConfig *monConfig) v1.Container {
|
||||
func (c *Cluster) makeMonDaemonContainer(monConfig *monConfig) corev1.Container {
|
||||
podIPEnvVar := "ROOK_POD_IP"
|
||||
publicAddr := monConfig.PublicIP
|
||||
|
||||
@@ -276,7 +275,7 @@ func (c *Cluster) makeMonDaemonContainer(monConfig *monConfig) v1.Container {
|
||||
publicAddr = fmt.Sprintf("%s:%d", publicAddr, monConfig.Port)
|
||||
}
|
||||
|
||||
container := v1.Container{
|
||||
container := corev1.Container{
|
||||
Name: "mon",
|
||||
Command: []string{
|
||||
cephMonCommand,
|
||||
@@ -298,11 +297,11 @@ func (c *Cluster) makeMonDaemonContainer(monConfig *monConfig) v1.Container {
|
||||
Image: c.spec.CephVersion.Image,
|
||||
VolumeMounts: controller.DaemonVolumeMounts(monConfig.DataPathMap, keyringStoreName),
|
||||
SecurityContext: controller.PodSecurityContext(),
|
||||
Ports: []v1.ContainerPort{
|
||||
Ports: []corev1.ContainerPort{
|
||||
{
|
||||
Name: "tcp-msgr1",
|
||||
ContainerPort: monConfig.Port,
|
||||
Protocol: v1.ProtocolTCP,
|
||||
Protocol: corev1.ProtocolTCP,
|
||||
},
|
||||
},
|
||||
Env: append(
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
rookv1 "github.com/rook/rook/pkg/apis/rook.io/v1"
|
||||
kms "github.com/rook/rook/pkg/daemon/ceph/osd/kms"
|
||||
osdconfig "github.com/rook/rook/pkg/operator/ceph/cluster/osd/config"
|
||||
"github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
"github.com/rook/rook/pkg/util"
|
||||
@@ -158,7 +157,7 @@ func (c *Cluster) startProvisioningOverPVCs(config *provisionConfig, errs *provi
|
||||
awaitingStatusConfigMaps := util.NewSet()
|
||||
for _, volume := range c.ValidStorage.VolumeSources {
|
||||
// Check whether we need to cancel the orchestration
|
||||
if err := controller.CheckForCancelledOrchestration(c.context); err != nil {
|
||||
if err := opcontroller.CheckForCancelledOrchestration(c.context); err != nil {
|
||||
return awaitingStatusConfigMaps, err
|
||||
}
|
||||
|
||||
@@ -315,7 +314,7 @@ func (c *Cluster) startProvisioningOverNodes(config *provisionConfig, errs *prov
|
||||
awaitingStatusConfigMaps := util.NewSet()
|
||||
for _, node := range c.ValidStorage.Nodes {
|
||||
// Check whether we need to cancel the orchestration
|
||||
if err := controller.CheckForCancelledOrchestration(c.context); err != nil {
|
||||
if err := opcontroller.CheckForCancelledOrchestration(c.context); err != nil {
|
||||
return awaitingStatusConfigMaps, err
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
testexec "github.com/rook/rook/pkg/operator/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
@@ -54,7 +53,7 @@ func testPrepareDeviceSets(t *testing.T, setTemplateName bool) {
|
||||
Name: "mydata",
|
||||
Count: 1,
|
||||
Portable: true,
|
||||
VolumeClaimTemplates: []v1.PersistentVolumeClaim{claim},
|
||||
VolumeClaimTemplates: []corev1.PersistentVolumeClaim{claim},
|
||||
SchedulerName: "custom-scheduler",
|
||||
}
|
||||
spec := cephv1.ClusterSpec{
|
||||
@@ -99,7 +98,7 @@ func TestPrepareDeviceSetWithHolesInPVCs(t *testing.T) {
|
||||
Name: "mydata",
|
||||
Count: 1,
|
||||
Portable: true,
|
||||
VolumeClaimTemplates: []v1.PersistentVolumeClaim{testVolumeClaim("data"), testVolumeClaim("metadata"), testVolumeClaim("wal")},
|
||||
VolumeClaimTemplates: []corev1.PersistentVolumeClaim{testVolumeClaim("data"), testVolumeClaim("metadata"), testVolumeClaim("wal")},
|
||||
SchedulerName: "custom-scheduler",
|
||||
}
|
||||
spec := cephv1.ClusterSpec{
|
||||
@@ -226,9 +225,9 @@ func assertPVCExists(t *testing.T, clientset kubernetes.Interface, namespace, na
|
||||
assert.NotNil(t, pvc)
|
||||
}
|
||||
|
||||
func testVolumeClaim(name string) v1.PersistentVolumeClaim {
|
||||
func testVolumeClaim(name string) corev1.PersistentVolumeClaim {
|
||||
storageClass := "mysource"
|
||||
claim := v1.PersistentVolumeClaim{Spec: v1.PersistentVolumeClaimSpec{
|
||||
claim := corev1.PersistentVolumeClaim{Spec: corev1.PersistentVolumeClaimSpec{
|
||||
StorageClassName: &storageClass,
|
||||
}}
|
||||
claim.Name = name
|
||||
@@ -244,29 +243,29 @@ func TestUpdatePVCSize(t *testing.T) {
|
||||
context: context,
|
||||
clusterInfo: client.AdminClusterInfo("testns"),
|
||||
}
|
||||
current := &v1.PersistentVolumeClaim{}
|
||||
desired := &v1.PersistentVolumeClaim{}
|
||||
current.Spec.Resources.Requests = v1.ResourceList{}
|
||||
desired.Spec.Resources.Requests = v1.ResourceList{}
|
||||
current.Spec.Resources.Requests[v1.ResourceStorage] = resource.MustParse("5Gi")
|
||||
current := &corev1.PersistentVolumeClaim{}
|
||||
desired := &corev1.PersistentVolumeClaim{}
|
||||
current.Spec.Resources.Requests = corev1.ResourceList{}
|
||||
desired.Spec.Resources.Requests = corev1.ResourceList{}
|
||||
current.Spec.Resources.Requests[corev1.ResourceStorage] = resource.MustParse("5Gi")
|
||||
|
||||
// Nothing happens if no size is set on the new PVC
|
||||
cluster.updatePVCIfChanged(desired, current)
|
||||
result, ok := current.Spec.Resources.Requests[v1.ResourceStorage]
|
||||
result, ok := current.Spec.Resources.Requests[corev1.ResourceStorage]
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, "5Gi", result.String())
|
||||
|
||||
// Nothing happens if the size shrinks
|
||||
desired.Spec.Resources.Requests[v1.ResourceStorage] = resource.MustParse("4Gi")
|
||||
desired.Spec.Resources.Requests[corev1.ResourceStorage] = resource.MustParse("4Gi")
|
||||
cluster.updatePVCIfChanged(desired, current)
|
||||
result, ok = current.Spec.Resources.Requests[v1.ResourceStorage]
|
||||
result, ok = current.Spec.Resources.Requests[corev1.ResourceStorage]
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, "5Gi", result.String())
|
||||
|
||||
// The size is updated when it increases
|
||||
desired.Spec.Resources.Requests[v1.ResourceStorage] = resource.MustParse("6Gi")
|
||||
desired.Spec.Resources.Requests[corev1.ResourceStorage] = resource.MustParse("6Gi")
|
||||
cluster.updatePVCIfChanged(desired, current)
|
||||
result, ok = current.Spec.Resources.Requests[v1.ResourceStorage]
|
||||
result, ok = current.Spec.Resources.Requests[corev1.ResourceStorage]
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, "6Gi", result.String())
|
||||
}
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
rookv1 "github.com/rook/rook/pkg/apis/rook.io/v1"
|
||||
fakeclient "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"
|
||||
cephclientfake "github.com/rook/rook/pkg/daemon/ceph/client/fake"
|
||||
discoverDaemon "github.com/rook/rook/pkg/daemon/discover"
|
||||
@@ -296,7 +295,7 @@ func TestAddRemoveNode(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
|
||||
removeIfOutAndSafeToRemove := true
|
||||
healthMon := NewOSDHealthMonitor(context, client.AdminClusterInfo(namespace), removeIfOutAndSafeToRemove, cephv1.CephClusterHealthCheckSpec{})
|
||||
healthMon := NewOSDHealthMonitor(context, cephclient.AdminClusterInfo(namespace), removeIfOutAndSafeToRemove, cephv1.CephClusterHealthCheckSpec{})
|
||||
healthMon.checkOSDHealth()
|
||||
_, err = clientset.AppsV1().Deployments(namespace).Get(ctx, deploymentName(1), metav1.GetOptions{})
|
||||
assert.True(t, k8serrors.IsNotFound(err))
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
daemonclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/mon"
|
||||
"github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
@@ -207,7 +206,7 @@ func (c *cluster) validateCephVersion(version *cephver.CephVersion) error {
|
||||
}
|
||||
|
||||
// Get cluster running versions
|
||||
versions, err := client.GetAllCephDaemonVersions(c.context, c.ClusterInfo)
|
||||
versions, err := daemonclient.GetAllCephDaemonVersions(c.context, c.ClusterInfo)
|
||||
if err != nil {
|
||||
logger.Errorf("failed to get ceph daemons versions, this typically happens during the first cluster initialization. %v", err)
|
||||
return nil
|
||||
@@ -226,7 +225,7 @@ func (c *cluster) validateCephVersion(version *cephver.CephVersion) error {
|
||||
if differentImages {
|
||||
// If the image version changed let's make sure we can safely upgrade
|
||||
// check ceph's status, if not healthy we fail
|
||||
cephHealthy := client.IsCephHealthy(c.context, c.ClusterInfo)
|
||||
cephHealthy := daemonclient.IsCephHealthy(c.context, c.ClusterInfo)
|
||||
if !cephHealthy {
|
||||
if c.Spec.SkipUpgradeChecks {
|
||||
logger.Warning("ceph is not healthy but SkipUpgradeChecks is set, forcing upgrade.")
|
||||
|
||||
Reference in new issue
Block a user