Skip to content

Commit

Permalink
fix scale up
Browse files Browse the repository at this point in the history
  • Loading branch information
egegunes committed Jul 11, 2024
1 parent db9e666 commit c39319c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions e2e-tests/functions
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,7 @@ wait_cluster_consistency() {
echo -n .
sleep 10
done
echo
}

run_backup() {
Expand Down
33 changes: 33 additions & 0 deletions e2e-tests/split-horizon/conf/some-name.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: psmdb.percona.com/v1
kind: PerconaServerMongoDB
metadata:
name: some-name
spec:
#platform: openshift
image:
imagePullPolicy: Always
backup:
enabled: false
image: perconalab/percona-server-mongodb-operator:main-backup
replsets:
- name: rs0
size: 3
expose:
enabled: true
exposeType: ClusterIP
affinity:
antiAffinityTopologyKey: none
resources:
limits:
cpu: 500m
memory: 0.5G
requests:
cpu: 100m
memory: 0.1G
volumeSpec:
persistentVolumeClaim:
resources:
requests:
storage: 1Gi
secrets:
users: some-users
21 changes: 21 additions & 0 deletions pkg/controller/perconaservermongodb/mgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,15 @@ func (r *ReconcilePerconaServerMongoDB) updateConfigMembers(ctx context.Context,
return 0, errors.Wrap(err, "get mongo config")
}

existingHorizons := make([]string, 0)
for _, member := range cnf.Members {
if len(member.Horizons) > 0 {
for name := range member.Horizons {
existingHorizons = append(existingHorizons, name)
}
}
}

members := mongo.ConfigMembers{}
for key, pod := range pods.Items {
if key >= mongo.MaxMembers {
Expand Down Expand Up @@ -294,6 +303,18 @@ func (r *ReconcilePerconaServerMongoDB) updateConfigMembers(ctx context.Context,
Votes: mongo.DefaultVotes,
}

if len(existingHorizons) > 0 {
for _, horizon := range existingHorizons {
if _, ok := rs.Horizons[pod.Name][horizon]; !ok {
return 0, errors.Errorf("horizon %s is missing for pod %s", horizon, pod.Name)
}

member.Horizons = map[string]string{
horizon: rs.Horizons[pod.Name][horizon],
}
}
}

switch pod.Labels["app.kubernetes.io/component"] {
case "arbiter":
member.ArbiterOnly = true
Expand Down

0 comments on commit c39319c

Please sign in to comment.