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
3 changes: 3 additions & 0 deletions api/v1/mongodbcommunity_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ type MongoDBCommunitySpec struct {
// MemberConfig
// +optional
MemberConfig []automationconfig.MemberOptions `json:"memberConfig,omitempty"`

// OverrideClusterDomain overrides the cluster domain.
OverrideClusterDomain string `json:"overrideClusterDomain,omitempty"`
}

// MapWrapper is a wrapper for a map to be used by other structs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ spec:
members:
description: Members is the number of members in the replica set
type: integer
overrideClusterDomain:
description: OverrideClusterDomain overrides the cluster domain.
type: string
prometheus:
description: Prometheus configurations.
properties:
Expand Down
17 changes: 12 additions & 5 deletions controllers/replica_set_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,12 @@ func (r ReplicaSetReconciler) Reconcile(ctx context.Context, request reconcile.R
withMongoDBArbiters(mdb.AutomationConfigArbitersThisReconciliation()).
withPendingPhase(10))
}

mdbClusterDomain := mdb.Spec.OverrideClusterDomain
if mdbClusterDomain == "" {
mdbClusterDomain = os.Getenv(clusterDomain)
}
res, err := status.Update(ctx, r.client.Status(), &mdb, statusOptions().
withMongoURI(mdb.MongoURI(os.Getenv(clusterDomain))).
withMongoURI(mdb.MongoURI(mdbClusterDomain)).
withMongoDBMembers(mdb.AutomationConfigMembersThisReconciliation()).
withStatefulSetReplicas(mdb.StatefulSetReplicasThisReconciliation()).
withStatefulSetArbiters(mdb.StatefulSetArbitersThisReconciliation()).
Expand All @@ -218,7 +221,7 @@ func (r ReplicaSetReconciler) Reconcile(ctx context.Context, request reconcile.R
return res, err
}

if err := r.updateConnectionStringSecrets(ctx, mdb, os.Getenv(clusterDomain)); err != nil {
if err := r.updateConnectionStringSecrets(ctx, mdb, mdbClusterDomain); err != nil {
r.log.Errorf("Could not update connection string secrets: %s", err)
}

Expand Down Expand Up @@ -499,8 +502,12 @@ func (r ReplicaSetReconciler) ensureAutomationConfig(mdb mdbv1.MongoDBCommunity,
}

func buildAutomationConfig(mdb mdbv1.MongoDBCommunity, auth automationconfig.Auth, currentAc automationconfig.AutomationConfig, modifications ...automationconfig.Modification) (automationconfig.AutomationConfig, error) {
domain := getDomain(mdb.ServiceName(), mdb.Namespace, os.Getenv(clusterDomain))
arbiterDomain := getDomain(mdb.ServiceName(), mdb.Namespace, os.Getenv(clusterDomain))
mdbClusterDomain := mdb.Spec.OverrideClusterDomain
if mdbClusterDomain == "" {
mdbClusterDomain = os.Getenv(clusterDomain)
}
domain := getDomain(mdb.ServiceName(), mdb.Namespace, mdbClusterDomain)
arbiterDomain := getDomain(mdb.ServiceName(), mdb.Namespace, mdbClusterDomain)

zap.S().Debugw("AutomationConfigMembersThisReconciliation", "mdb.AutomationConfigMembersThisReconciliation()", mdb.AutomationConfigMembersThisReconciliation())

Expand Down