Skip to content

Commit

Permalink
K8SPSMDB-1038: don't delete mongos svc on pause (#1467)
Browse files Browse the repository at this point in the history
* K8SPSMDB-1038: don't delete mongos svc on pause

https://perconadev.atlassian.net/browse/K8SPSMDB-1038

* add test

---------

Co-authored-by: Viacheslav Sarzhan <slava.sarzhan@percona.com>
  • Loading branch information
pooknull and hors authored Mar 25, 2024
1 parent 79880ad commit c697fa7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions e2e-tests/monitoring-2-0/run
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ wait_for_delete "pod/${cluster}-mongos-0"
wait_for_delete "pod/${cluster}-rs0-0"
wait_for_delete "pod/${cluster}-cfg-0"

desc 'check if services are not deleted'

kubectl_bin get svc $cluster-rs0
kubectl_bin get svc $cluster-cfg
kubectl_bin get svc $cluster-mongos

does_node_id_exists_in_pmm=($(does_node_id_exists "${nodeList[@]}"))
for instance in "${does_node_id_exists_in_pmm[@]}"; do
if [ -n "$instance" ]; then
Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/perconaservermongodb/psmdb_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,10 @@ func (r *ReconcilePerconaServerMongoDB) reconcileMongos(ctx context.Context, cr
}

func (r *ReconcilePerconaServerMongoDB) removeOutdatedMongosSvc(ctx context.Context, cr *api.PerconaServerMongoDB) error {
if cr.Spec.Pause && cr.Spec.Sharding.Enabled {
return nil
}

svcNames := make(map[string]struct{}, cr.Spec.Sharding.Mongos.Size)
if cr.Spec.Sharding.Mongos.Expose.ServicePerPod {
for i := 0; i < int(cr.Spec.Sharding.Mongos.Size); i++ {
Expand Down

0 comments on commit c697fa7

Please sign in to comment.