Merge pull request #7605 from alrs/more-ceph-imports
ceph: fix multiple imports
This commit is contained in:
9 files changed
+28
-39
No files matched your search
@@ -36,7 +36,6 @@ import (
|
||||
"github.com/coreos/pkg/capnslog"
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
ceph "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"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
@@ -235,14 +234,14 @@ func (r *ReconcileCephClient) createOrUpdateClient(cephClient *cephv1.CephClient
|
||||
clientEntity, caps := genClientEntity(cephClient)
|
||||
|
||||
// Check if client was created manually, create if necessary or update caps and create secret
|
||||
key, err := ceph.AuthGetKey(r.context, r.clusterInfo, clientEntity)
|
||||
key, err := cephclient.AuthGetKey(r.context, r.clusterInfo, clientEntity)
|
||||
if err != nil {
|
||||
key, err = ceph.AuthGetOrCreateKey(r.context, r.clusterInfo, clientEntity, caps)
|
||||
key, err = cephclient.AuthGetOrCreateKey(r.context, r.clusterInfo, clientEntity, caps)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to create client %q", cephClient.Name)
|
||||
}
|
||||
} else {
|
||||
err = ceph.AuthUpdateCaps(r.context, r.clusterInfo, clientEntity, caps)
|
||||
err = cephclient.AuthUpdateCaps(r.context, r.clusterInfo, clientEntity, caps)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "client %q exists, failed to update client caps", cephClient.Name)
|
||||
}
|
||||
@@ -292,7 +291,7 @@ func (r *ReconcileCephClient) createOrUpdateClient(cephClient *cephv1.CephClient
|
||||
// Delete the client
|
||||
func (r *ReconcileCephClient) deleteClient(cephClient *cephv1.CephClient) error {
|
||||
logger.Infof("deleting client object %q", cephClient.Name)
|
||||
if err := ceph.AuthDelete(r.context, r.clusterInfo, generateClientName(cephClient.Name)); err != nil {
|
||||
if err := cephclient.AuthDelete(r.context, r.clusterInfo, generateClientName(cephClient.Name)); err != nil {
|
||||
return errors.Wrapf(err, "failed to delete client %q", cephClient.Name)
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
|
||||
"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/k8sutil"
|
||||
testop "github.com/rook/rook/pkg/operator/test"
|
||||
@@ -51,7 +50,7 @@ func TestGenerateKey(t *testing.T) {
|
||||
}
|
||||
ns := "rook-ceph"
|
||||
ownerInfo := k8sutil.OwnerInfo{}
|
||||
s := GetSecretStore(ctx, &client.ClusterInfo{Namespace: ns}, &ownerInfo)
|
||||
s := GetSecretStore(ctx, &cephclient.ClusterInfo{Namespace: ns}, &ownerInfo)
|
||||
|
||||
generateKey = "generatedsecretkey"
|
||||
failGenerateKey = false
|
||||
@@ -80,7 +79,7 @@ func TestKeyringStore(t *testing.T) {
|
||||
}
|
||||
ownerInfo := cephclient.NewMinimumOwnerInfoWithOwnerRef()
|
||||
ns := "rook-ceph"
|
||||
k := GetSecretStore(ctx, &client.ClusterInfo{Namespace: ns}, ownerInfo)
|
||||
k := GetSecretStore(ctx, &cephclient.ClusterInfo{Namespace: ns}, ownerInfo)
|
||||
|
||||
assertKeyringData := func(keyringName, expectedKeyring string) {
|
||||
s, e := clientset.CoreV1().Secrets(ns).Get(ctxt, keyringName, metav1.GetOptions{})
|
||||
@@ -125,7 +124,7 @@ func TestResourceVolumeAndMount(t *testing.T) {
|
||||
Clientset: clientset,
|
||||
}
|
||||
ownerInfo := cephclient.NewMinimumOwnerInfoWithOwnerRef()
|
||||
k := GetSecretStore(ctx, &client.ClusterInfo{Namespace: "ns"}, ownerInfo)
|
||||
k := GetSecretStore(ctx, &cephclient.ClusterInfo{Namespace: "ns"}, ownerInfo)
|
||||
err := k.CreateOrUpdate("test-resource", "qwertyuiop")
|
||||
assert.NoError(t, err)
|
||||
err = k.CreateOrUpdate("second-resource", "asdfgyhujkl")
|
||||
|
||||
@@ -22,9 +22,7 @@ import (
|
||||
"testing"
|
||||
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
"github.com/rook/rook/pkg/operator/ceph/config"
|
||||
opconfig "github.com/rook/rook/pkg/operator/ceph/config"
|
||||
"github.com/rook/rook/pkg/operator/ceph/version"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
@@ -110,24 +108,24 @@ func TestCheckPodMemory(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBuildAdminSocketCommand(t *testing.T) {
|
||||
c := getDaemonConfig(config.OsdType, "")
|
||||
c := getDaemonConfig(opconfig.OsdType, "")
|
||||
|
||||
command := c.buildAdminSocketCommand()
|
||||
assert.Equal(t, "status", command)
|
||||
|
||||
c.daemonType = config.MonType
|
||||
c.daemonType = opconfig.MonType
|
||||
command = c.buildAdminSocketCommand()
|
||||
assert.Equal(t, "mon_status", command)
|
||||
}
|
||||
|
||||
func TestBuildSocketName(t *testing.T) {
|
||||
daemonID := "0"
|
||||
c := getDaemonConfig(config.OsdType, daemonID)
|
||||
c := getDaemonConfig(opconfig.OsdType, daemonID)
|
||||
|
||||
socketName := c.buildSocketName()
|
||||
assert.Equal(t, "ceph-osd.0.asok", socketName)
|
||||
|
||||
c.daemonType = config.MonType
|
||||
c.daemonType = opconfig.MonType
|
||||
c.daemonID = "a"
|
||||
socketName = c.buildSocketName()
|
||||
assert.Equal(t, "ceph-mon.a.asok", socketName)
|
||||
@@ -135,7 +133,7 @@ func TestBuildSocketName(t *testing.T) {
|
||||
|
||||
func TestBuildSocketPath(t *testing.T) {
|
||||
daemonID := "0"
|
||||
c := getDaemonConfig(config.OsdType, daemonID)
|
||||
c := getDaemonConfig(opconfig.OsdType, daemonID)
|
||||
|
||||
socketPath := c.buildSocketPath()
|
||||
assert.Equal(t, "/run/ceph/ceph-osd.0.asok", socketPath)
|
||||
@@ -143,7 +141,7 @@ func TestBuildSocketPath(t *testing.T) {
|
||||
|
||||
func TestGenerateLivenessProbeExecDaemon(t *testing.T) {
|
||||
daemonID := "0"
|
||||
probe := GenerateLivenessProbeExecDaemon(config.OsdType, daemonID)
|
||||
probe := GenerateLivenessProbeExecDaemon(opconfig.OsdType, daemonID)
|
||||
expectedCommand := []string{"env",
|
||||
"-i",
|
||||
"sh",
|
||||
@@ -156,21 +154,21 @@ func TestGenerateLivenessProbeExecDaemon(t *testing.T) {
|
||||
assert.Equal(t, initialDelaySecondsOSDDaemon, probe.InitialDelaySeconds)
|
||||
|
||||
// test with a mon so the delay should be 10
|
||||
probe = GenerateLivenessProbeExecDaemon(config.MonType, "a")
|
||||
probe = GenerateLivenessProbeExecDaemon(opconfig.MonType, "a")
|
||||
assert.Equal(t, initialDelaySecondsNonOSDDaemon, probe.InitialDelaySeconds)
|
||||
}
|
||||
|
||||
func TestDaemonFlags(t *testing.T) {
|
||||
testcases := []struct {
|
||||
label string
|
||||
clusterInfo *client.ClusterInfo
|
||||
clusterInfo *cephclient.ClusterInfo
|
||||
clusterSpec *cephv1.ClusterSpec
|
||||
daemonID string
|
||||
expected []string
|
||||
}{
|
||||
{
|
||||
label: "case 1: IPv6 enabled",
|
||||
clusterInfo: &client.ClusterInfo{
|
||||
clusterInfo: &cephclient.ClusterInfo{
|
||||
FSID: "id",
|
||||
},
|
||||
clusterSpec: &cephv1.ClusterSpec{
|
||||
@@ -186,7 +184,7 @@ func TestDaemonFlags(t *testing.T) {
|
||||
},
|
||||
{
|
||||
label: "case 2: IPv6 disabled",
|
||||
clusterInfo: &client.ClusterInfo{
|
||||
clusterInfo: &cephclient.ClusterInfo{
|
||||
FSID: "id",
|
||||
},
|
||||
clusterSpec: &cephv1.ClusterSpec{},
|
||||
|
||||
@@ -23,13 +23,11 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
cephClient "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/osd"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
@@ -56,7 +54,7 @@ const (
|
||||
|
||||
func (r *ReconcileClusterDisruption) createPDB(pdb *policyv1beta1.PodDisruptionBudget) error {
|
||||
err := r.client.Create(context.TODO(), pdb)
|
||||
if err != nil && !kerrors.IsAlreadyExists(err) {
|
||||
if err != nil && !apierrors.IsAlreadyExists(err) {
|
||||
return errors.Wrapf(err, "failed to create pdb %q", pdb.Name)
|
||||
}
|
||||
return nil
|
||||
@@ -64,7 +62,7 @@ func (r *ReconcileClusterDisruption) createPDB(pdb *policyv1beta1.PodDisruptionB
|
||||
|
||||
func (r *ReconcileClusterDisruption) deletePDB(pdb *policyv1beta1.PodDisruptionBudget) error {
|
||||
err := r.client.Delete(context.TODO(), pdb)
|
||||
if err != nil && !kerrors.IsNotFound(err) {
|
||||
if err != nil && !apierrors.IsNotFound(err) {
|
||||
return errors.Wrapf(err, "failed to delete pdb %q", pdb.Name)
|
||||
}
|
||||
return nil
|
||||
@@ -198,7 +196,7 @@ func (r *ReconcileClusterDisruption) initializePDBState(request reconcile.Reques
|
||||
}
|
||||
err := r.client.Get(context.TODO(), pdbStateMapRequest, pdbStateMap)
|
||||
|
||||
if kerrors.IsNotFound(err) {
|
||||
if apierrors.IsNotFound(err) {
|
||||
// create configmap to track the draining failure domain
|
||||
pdbStateMap.Data = map[string]string{drainingFailureDomainKey: ""}
|
||||
err := r.client.Create(context.TODO(), pdbStateMap)
|
||||
@@ -377,7 +375,7 @@ func (r *ReconcileClusterDisruption) updateNoout(clusterInfo *cephclient.Cluster
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *ReconcileClusterDisruption) getOSDFailureDomains(clusterInfo *cephClient.ClusterInfo, request reconcile.Request, poolFailureDomain string) ([]string, []string, error) {
|
||||
func (r *ReconcileClusterDisruption) getOSDFailureDomains(clusterInfo *cephclient.ClusterInfo, request reconcile.Request, poolFailureDomain string) ([]string, []string, error) {
|
||||
osdDeploymentList := &appsv1.DeploymentList{}
|
||||
namespaceListOpts := client.InNamespace(request.Namespace)
|
||||
topologyLocationLabel := fmt.Sprintf(osd.TopologyLocationLabel, poolFailureDomain)
|
||||
|
||||
@@ -32,7 +32,6 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
policyv1beta1 "k8s.io/api/policy/v1beta1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
@@ -64,7 +63,7 @@ func fakeOSDDeployment(id, readyReplicas int) appsv1.Deployment {
|
||||
},
|
||||
},
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Template: v1.PodTemplateSpec{
|
||||
Template: corev1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"topology-location-zone": fmt.Sprintf("zone-%d", id),
|
||||
|
||||
@@ -25,7 +25,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"
|
||||
opmon "github.com/rook/rook/pkg/operator/ceph/cluster/mon"
|
||||
"github.com/rook/rook/pkg/operator/ceph/config"
|
||||
@@ -275,7 +274,7 @@ func validateGanesha(context *clusterd.Context, clusterInfo *cephclient.ClusterI
|
||||
}
|
||||
|
||||
// The existence of the pool provided in n.Spec.RADOS.Pool is necessary otherwise addRADOSConfigFile() will fail
|
||||
_, err := client.GetPoolDetails(context, clusterInfo, n.Spec.RADOS.Pool)
|
||||
_, err := cephclient.GetPoolDetails(context, clusterInfo, n.Spec.RADOS.Pool)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "pool %q not found", n.Spec.RADOS.Pool)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
"github.com/rook/rook/pkg/operator/ceph/config"
|
||||
cephver "github.com/rook/rook/pkg/operator/ceph/version"
|
||||
"github.com/rook/rook/pkg/operator/test"
|
||||
optest "github.com/rook/rook/pkg/operator/test"
|
||||
exectest "github.com/rook/rook/pkg/util/exec/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -65,7 +64,7 @@ func TestDeploymentSpec(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
clientset := test.New(t, 1)
|
||||
clientset := optest.New(t, 1)
|
||||
c := &clusterd.Context{
|
||||
Executor: &exectest.MockExecutor{},
|
||||
RookClientset: rookclient.NewSimpleClientset(),
|
||||
|
||||
@@ -18,7 +18,6 @@ limitations under the License.
|
||||
package pool
|
||||
|
||||
import (
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -41,7 +40,7 @@ func ValidatePool(context *clusterd.Context, clusterInfo *cephclient.ClusterInfo
|
||||
}
|
||||
|
||||
// ValidatePoolSpec validates the Ceph block pool spec CR
|
||||
func ValidatePoolSpec(context *clusterd.Context, clusterInfo *client.ClusterInfo, clusterSpec *cephv1.ClusterSpec, p *cephv1.PoolSpec) error {
|
||||
func ValidatePoolSpec(context *clusterd.Context, clusterInfo *cephclient.ClusterInfo, clusterSpec *cephv1.ClusterSpec, p *cephv1.PoolSpec) error {
|
||||
if p.IsReplicated() && p.IsErasureCoded() {
|
||||
return errors.New("both replication and erasure code settings cannot be specified")
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/agent/flexvolume"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
ceph "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
@@ -97,7 +96,7 @@ func (p *RookVolumeProvisioner) Provision(_ context.Context, options controller.
|
||||
return nil, controller.ProvisioningFinished, err
|
||||
}
|
||||
|
||||
clusterInfo := client.AdminClusterInfo(cfg.clusterNamespace)
|
||||
clusterInfo := ceph.AdminClusterInfo(cfg.clusterNamespace)
|
||||
blockImage, err := p.createVolume(clusterInfo, imageName, cfg.blockPool, cfg.dataBlockPool, requestBytes)
|
||||
if err != nil {
|
||||
return nil, controller.ProvisioningFinished, err
|
||||
@@ -159,7 +158,7 @@ func (p *RookVolumeProvisioner) Provision(_ context.Context, options controller.
|
||||
}
|
||||
|
||||
// createVolume creates a rook block volume.
|
||||
func (p *RookVolumeProvisioner) createVolume(clusterInfo *client.ClusterInfo, image, pool, dataPool string, size int64) (*ceph.CephBlockImage, error) {
|
||||
func (p *RookVolumeProvisioner) createVolume(clusterInfo *ceph.ClusterInfo, image, pool, dataPool string, size int64) (*ceph.CephBlockImage, error) {
|
||||
if image == "" || pool == "" || clusterInfo.Namespace == "" || size == 0 {
|
||||
return nil, errors.Errorf("image missing required fields (image=%s, pool=%s, clusterNamespace=%s, size=%d)", image, pool, clusterInfo.Namespace, size)
|
||||
}
|
||||
@@ -196,7 +195,7 @@ func (p *RookVolumeProvisioner) Delete(_ context.Context, volume *v1.PersistentV
|
||||
if clusterns == "" {
|
||||
return errors.Errorf("failed to delete rook block image %s/%s: no clusterNamespace or (deprecated) clusterName option given", pool, volume.Name)
|
||||
}
|
||||
clusterInfo := client.AdminClusterInfo(clusterns)
|
||||
clusterInfo := ceph.AdminClusterInfo(clusterns)
|
||||
err := ceph.DeleteImage(p.context, clusterInfo, name, pool)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to delete rook block image %s/%s", pool, volume.Name)
|
||||
|
||||
Reference in new issue
Block a user