Skip to content
Draft
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: 5 additions & 0 deletions .evergreen-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,11 @@ tasks:
commands:
- func: e2e_test

- name: e2e_multi_cluster_new_replica_set_scale_up
tags: [ "patch-run" ]
commands:
- func: e2e_test

- name: e2e_multi_cluster_scale_up_cluster
tags: [ "patch-run" ]
commands:
Expand Down
1 change: 1 addition & 0 deletions .evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,7 @@ task_groups:
- e2e_multi_cluster_mtls_test
- e2e_multi_cluster_replica_set_deletion
- e2e_multi_cluster_replica_set_scale_up
- e2e_multi_cluster_new_replica_set_scale_up
- e2e_multi_cluster_scale_up_cluster
- e2e_multi_cluster_scale_up_cluster_new_cluster
- e2e_multi_cluster_replica_set_scale_down
Expand Down
13 changes: 13 additions & 0 deletions api/v1/mdb/mongodb_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,8 @@ type MongoDbSpec struct {
// +kubebuilder:pruning:PreserveUnknownFields
// +optional
MemberConfig []automationconfig.MemberOptions `json:"memberConfig,omitempty"`

ClusterSpecList ClusterSpecList `json:"clusterSpecList,omitempty"`
}

func (m *MongoDbSpec) GetExternalDomain() *string {
Expand All @@ -452,6 +454,17 @@ func (m *MongoDbSpec) GetExternalDomain() *string {
return nil
}

// GetExternalDomainForMemberCluster returns the external domain for a specific member cluster. Falls back to the global
// external domain if not found.
func (m *MongoDbSpec) GetExternalDomainForMemberCluster(clusterName string) *string {
if cfg := m.ClusterSpecList.GetExternalAccessConfigurationForMemberCluster(clusterName); cfg != nil {
if externalDomain := cfg.ExternalDomain; externalDomain != nil {
return externalDomain
}
}
return m.GetExternalDomain()
}

func (m *MongoDbSpec) GetHorizonConfig() []MongoDBHorizonConfig {
return m.Connectivity.ReplicaSetHorizons
}
Expand Down
2 changes: 1 addition & 1 deletion api/v1/mdb/mongodb_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func additionalMongodConfig(ms MongoDbSpec) v1.ValidationResult {
}

func replicasetMemberIsSpecified(ms MongoDbSpec) v1.ValidationResult {
if ms.ResourceType == ReplicaSet && ms.Members == 0 {
if ms.ResourceType == ReplicaSet && !ms.IsMultiCluster() && ms.Members == 0 {
return v1.ValidationError("'spec.members' must be specified if type of MongoDB is %s", ms.ResourceType)
}
return v1.ValidationSuccess()
Expand Down
36 changes: 36 additions & 0 deletions api/v1/mdb/mongodbbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ func NewDefaultReplicaSetBuilder() *MongoDBBuilder {
return defaultMongoDB(ReplicaSet)
}

func NewDefaultMultiReplicaSetBuilder() *MongoDBBuilder {
b := defaultMongoDB(ReplicaSet).
SetMultiClusterTopology()

// Set test OpsManager config and credentials (matching multi-cluster test fixtures)
b.mdb.Spec.OpsManagerConfig = &PrivateCloudConfig{
ConfigMapRef: ConfigMapRef{Name: "my-project"},
}
b.mdb.Spec.Credentials = "my-credentials"

return b
}

func NewDefaultShardedClusterBuilder() *MongoDBBuilder {
return defaultMongoDB(ShardedCluster).
SetShardCountSpec(3).
Expand Down Expand Up @@ -264,6 +277,29 @@ func (b *MongoDBBuilder) AddDummyOpsManagerConfig() *MongoDBBuilder {
return b
}

func (b *MongoDBBuilder) SetDefaultClusterSpecList() *MongoDBBuilder {
b.mdb.Spec.ClusterSpecList = ClusterSpecList{
{
ClusterName: "test-cluster-0",
Members: 1,
},
{
ClusterName: "test-cluster-1",
Members: 1,
},
{
ClusterName: "test-cluster-2",
Members: 1,
},
}
return b
}

func (b *MongoDBBuilder) SetClusterSpecList(clusterSpecList ClusterSpecList) *MongoDBBuilder {
b.mdb.Spec.ClusterSpecList = clusterSpecList
return b
}

func (b *MongoDBBuilder) SetAllClusterSpecLists(clusterSpecList ClusterSpecList) *MongoDBBuilder {
b.mdb.Spec.ShardSpec.ClusterSpecList = clusterSpecList
b.mdb.Spec.ConfigSrvSpec.ClusterSpecList = clusterSpecList
Expand Down
7 changes: 7 additions & 0 deletions api/v1/mdb/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

140 changes: 140 additions & 0 deletions config/crd/bases/mongodb.com_mongodb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,146 @@ spec:
clusterDomain:
format: hostname
type: string
clusterSpecList:
items:
description: |-
ClusterSpecItem is the mongodb multi-cluster spec that is specific to a
particular Kubernetes cluster, this maps to the statefulset created in each cluster
properties:
clusterName:
description: |-
ClusterName is name of the cluster where the MongoDB Statefulset will be scheduled, the
name should have a one on one mapping with the service-account created in the central cluster
to talk to the workload clusters.
type: string
externalAccess:
description: ExternalAccessConfiguration provides external access
configuration for Multi-Cluster.
properties:
externalDomain:
description: An external domain that is used for exposing
MongoDB to the outside world.
type: string
externalService:
description: Provides a way to override the default (NodePort)
Service
properties:
annotations:
additionalProperties:
type: string
description: A map of annotations that shall be added
to the externally available Service.
type: object
spec:
description: A wrapper for the Service spec object.
type: object
x-kubernetes-preserve-unknown-fields: true
type: object
type: object
memberConfig:
description: MemberConfig allows to specify votes, priorities
and tags for each of the mongodb process.
items:
properties:
priority:
type: string
tags:
additionalProperties:
type: string
type: object
votes:
type: integer
type: object
type: array
members:
description: Amount of members for this MongoDB Replica Set
type: integer
podSpec:
properties:
persistence:
description: Note, that this field is used by MongoDB resources
only, let's keep it here for simplicity
properties:
multiple:
properties:
data:
properties:
labelSelector:
type: object
x-kubernetes-preserve-unknown-fields: true
storage:
type: string
storageClass:
type: string
type: object
journal:
properties:
labelSelector:
type: object
x-kubernetes-preserve-unknown-fields: true
storage:
type: string
storageClass:
type: string
type: object
logs:
properties:
labelSelector:
type: object
x-kubernetes-preserve-unknown-fields: true
storage:
type: string
storageClass:
type: string
type: object
type: object
single:
properties:
labelSelector:
type: object
x-kubernetes-preserve-unknown-fields: true
storage:
type: string
storageClass:
type: string
type: object
type: object
podTemplate:
type: object
x-kubernetes-preserve-unknown-fields: true
type: object
service:
description: this is an optional service, it will get the name
"<rsName>-service" in case not provided
type: string
statefulSet:
description: |-
StatefulSetConfiguration holds the optional custom StatefulSet
that should be merged into the operator created one.
properties:
metadata:
description: StatefulSetMetadataWrapper is a wrapper around
Labels and Annotations
properties:
annotations:
additionalProperties:
type: string
type: object
labels:
additionalProperties:
type: string
type: object
type: object
spec:
type: object
x-kubernetes-preserve-unknown-fields: true
required:
- spec
type: object
required:
- members
type: object
type: array
configServerCount:
type: integer
configSrv:
Expand Down
2 changes: 1 addition & 1 deletion controllers/om/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (agent AgentStatus) IsRegistered(hostnamePrefix string, log *zap.SugaredLog
return false
}

// Results are needed to fulfil the Paginated interface
// Results are needed to fulfil the Paginated interface.
func (aar AutomationAgentStatusResponse) Results() []interface{} {
ans := make([]interface{}, len(aar.AutomationAgents))
for i, aa := range aar.AutomationAgents {
Expand Down
Loading
Loading