core: update loadclusterInfo with multus check
if Multus is enabled the clusterinfo should be updated with network as multus as to run the ceph cmds in remote executor Signed-off-by: parth-gr <paarora@redhat.com>
This commit is contained in:
1 parent
ddea97ebde
commit
26584fc6e5
26 files changed
+48
-39
No files matched your search
@@ -86,12 +86,12 @@ type MonScheduleInfo struct {
|
||||
}
|
||||
|
||||
// LoadClusterInfo constructs or loads a clusterinfo and returns it along with the maxMonID
|
||||
func LoadClusterInfo(ctx *clusterd.Context, context context.Context, namespace string) (*cephclient.ClusterInfo, int, *Mapping, error) {
|
||||
return CreateOrLoadClusterInfo(ctx, context, namespace, nil)
|
||||
func LoadClusterInfo(ctx *clusterd.Context, context context.Context, namespace string, cephClusterSpec *cephv1.ClusterSpec) (*cephclient.ClusterInfo, int, *Mapping, error) {
|
||||
return CreateOrLoadClusterInfo(ctx, context, namespace, nil, cephClusterSpec)
|
||||
}
|
||||
|
||||
// CreateOrLoadClusterInfo constructs or loads a clusterinfo and returns it along with the maxMonID
|
||||
func CreateOrLoadClusterInfo(clusterdContext *clusterd.Context, context context.Context, namespace string, ownerInfo *k8sutil.OwnerInfo) (*cephclient.ClusterInfo, int, *Mapping, error) {
|
||||
func CreateOrLoadClusterInfo(clusterdContext *clusterd.Context, context context.Context, namespace string, ownerInfo *k8sutil.OwnerInfo, cephClusterSpec *cephv1.ClusterSpec) (*cephclient.ClusterInfo, int, *Mapping, error) {
|
||||
var clusterInfo *cephclient.ClusterInfo
|
||||
maxMonID := -1
|
||||
monMapping := &Mapping{
|
||||
@@ -148,6 +148,11 @@ func CreateOrLoadClusterInfo(clusterdContext *clusterd.Context, context context.
|
||||
return nil, maxMonID, monMapping, errors.Wrap(err, "failed to get mon config")
|
||||
}
|
||||
|
||||
// update clusterInfo with cephCLusterSpec Network info
|
||||
// it will also update if Multus is enabled, so ceph cmds
|
||||
// can run on remote executor
|
||||
clusterInfo.NetworkSpec = cephClusterSpec.Network
|
||||
|
||||
// If an admin key was provided we don't need to load the other resources
|
||||
// Some people might want to give the admin key
|
||||
// The necessary users/keys/secrets will be created by Rook
|
||||
@@ -357,13 +362,13 @@ func ParseMonEndpoints(input string) map[string]*cephclient.MonInfo {
|
||||
|
||||
// PopulateExternalClusterInfo Add validation in the code to fail if the external cluster has no
|
||||
// OSDs keep waiting
|
||||
func PopulateExternalClusterInfo(context *clusterd.Context, ctx context.Context, namespace string, ownerInfo *k8sutil.OwnerInfo) (*cephclient.ClusterInfo, error) {
|
||||
func PopulateExternalClusterInfo(cephClusterSpec *cephv1.ClusterSpec, context *clusterd.Context, ctx context.Context, namespace string, ownerInfo *k8sutil.OwnerInfo) (*cephclient.ClusterInfo, error) {
|
||||
for {
|
||||
// Checking for the context makes sure we don't loop forever with a canceled context
|
||||
if ctx.Err() != nil {
|
||||
return nil, ctx.Err()
|
||||
}
|
||||
clusterInfo, _, _, err := CreateOrLoadClusterInfo(context, ctx, namespace, nil)
|
||||
clusterInfo, _, _, err := CreateOrLoadClusterInfo(context, ctx, namespace, nil, cephClusterSpec)
|
||||
if err != nil {
|
||||
logger.Warningf("waiting for connection info of the external cluster. retrying in %s.", externalConnectionRetry.String())
|
||||
logger.Debugf("%v", err)
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
"github.com/rook/rook/pkg/operator/test"
|
||||
@@ -54,9 +55,14 @@ func TestCreateClusterSecrets(t *testing.T) {
|
||||
Clientset: clientset,
|
||||
Executor: executor,
|
||||
}
|
||||
provider := "Multus"
|
||||
cephClusterSpec := &cephv1.ClusterSpec{
|
||||
Network: cephv1.NetworkSpec{
|
||||
Provider: provider},
|
||||
}
|
||||
namespace := "ns"
|
||||
ownerInfo := cephclient.NewMinimumOwnerInfoWithOwnerRef()
|
||||
info, maxID, mapping, err := CreateOrLoadClusterInfo(context, ctx, namespace, ownerInfo)
|
||||
info, maxID, mapping, err := CreateOrLoadClusterInfo(context, ctx, namespace, ownerInfo, cephClusterSpec)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, -1, maxID)
|
||||
require.NotNil(t, info)
|
||||
@@ -79,7 +85,7 @@ func TestCreateClusterSecrets(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Check that the cluster info can now be loaded
|
||||
info, _, _, err = CreateOrLoadClusterInfo(context, ctx, namespace, ownerInfo)
|
||||
info, _, _, err = CreateOrLoadClusterInfo(context, ctx, namespace, ownerInfo, cephClusterSpec)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "client.admin", info.CephCred.Username)
|
||||
assert.Equal(t, adminSecret, info.CephCred.Secret)
|
||||
@@ -88,7 +94,7 @@ func TestCreateClusterSecrets(t *testing.T) {
|
||||
secret.Data[adminSecretNameKey] = []byte(adminSecretNameKey)
|
||||
_, err = clientset.CoreV1().Secrets(namespace).Update(ctx, secret, metav1.UpdateOptions{})
|
||||
assert.NoError(t, err)
|
||||
_, _, _, err = CreateOrLoadClusterInfo(context, ctx, namespace, ownerInfo)
|
||||
_, _, _, err = CreateOrLoadClusterInfo(context, ctx, namespace, ownerInfo, cephClusterSpec)
|
||||
assert.Error(t, err)
|
||||
|
||||
// Load the external cluster with the legacy external creds
|
||||
@@ -99,7 +105,7 @@ func TestCreateClusterSecrets(t *testing.T) {
|
||||
}
|
||||
_, err = clientset.CoreV1().Secrets(namespace).Create(ctx, secret, metav1.CreateOptions{})
|
||||
assert.NoError(t, err)
|
||||
info, _, _, err = CreateOrLoadClusterInfo(context, ctx, namespace, ownerInfo)
|
||||
info, _, _, err = CreateOrLoadClusterInfo(context, ctx, namespace, ownerInfo, cephClusterSpec)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "testid", info.CephCred.Username)
|
||||
assert.Equal(t, "testkey", info.CephCred.Secret)
|
||||
|
||||
Reference in new issue
Block a user