Skip to content

Commit 83960cc

Browse files
steve-nzrhors
andauthored
fix: pbm connections leak (#1542)
Co-authored-by: Viacheslav Sarzhan <slava.sarzhan@percona.com>
1 parent e6f626b commit 83960cc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/psmdb/backup/pbm.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ func NewPBM(ctx context.Context, c client.Client, cluster *api.PerconaServerMong
184184

185185
// GetPriorities returns priorities to be used in PBM config.
186186
func GetPriorities(ctx context.Context, k8sclient client.Client, cluster *api.PerconaServerMongoDB) (map[string]float64, error) {
187+
log := logf.FromContext(ctx)
187188
priorities := make(map[string]float64)
188189

189190
usersSecret := corev1.Secret{}
@@ -218,6 +219,11 @@ func GetPriorities(ctx context.Context, k8sclient client.Client, cluster *api.Pe
218219
// including the primary. That's why, we need to get primary nodes and
219220
// set them in the config.
220221
primary, err := psmdb.GetPrimaryPod(ctx, cli)
222+
223+
if disconnectErr := cli.Disconnect(ctx); disconnectErr != nil {
224+
log.Error(err, "failed to close connection to replicaSet", "rs", rs.Name)
225+
}
226+
221227
if err != nil {
222228
return priorities, errors.Wrap(err, "get primary pod")
223229
}

0 commit comments

Comments
 (0)