Skip to content
This repository was archived by the owner on Dec 12, 2025. It is now read-only.

Commit 2b18764

Browse files
authored
make ensuring a poll (#1506)
1 parent a87bda5 commit 2b18764

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

pkg/agent/replica_set_port_manager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (r *ReplicaSetPortManager) calculateExpectedPorts() (processPortMap map[str
128128
for _, podState := range r.currentPodStates {
129129
if !podState.ReachedGoalState {
130130
r.log.Debugf("Port change required but not all pods reached goal state, abandoning port change")
131-
return processPortMap, portChangeRequired, oldPort
131+
return processPortMap, true, oldPort
132132
}
133133
}
134134

@@ -143,5 +143,5 @@ func (r *ReplicaSetPortManager) calculateExpectedPorts() (processPortMap map[str
143143
}
144144
}
145145

146-
return processPortMap, portChangeRequired, oldPort
146+
return processPortMap, true, oldPort
147147
}

test/e2e/util/mongotester/mongotester.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,14 +307,24 @@ func (m *Tester) WaitForRotatedCertificate(mdb mdbv1.MongoDBCommunity, initialCe
307307
}
308308
}
309309

310+
// EnsureMongodConfig is mostly used for checking port changes. Port changes take some until they finish.
311+
// We cannot fully rely on the statefulset or resource being ready/running since it will change its state multiple
312+
// times during a port change. That means a resource might leave, go into and leave running multiple times until
313+
// it truly finished its port change.
310314
func (m *Tester) EnsureMongodConfig(selector string, expected interface{}) func(*testing.T) {
311315
return func(t *testing.T) {
312-
opts, err := m.getCommandLineOptions()
316+
connectivityOpts := defaults()
317+
err := wait.Poll(connectivityOpts.IntervalTime, connectivityOpts.TimeoutTime, func() (done bool, err error) {
318+
opts, err := m.getCommandLineOptions()
319+
assert.NoError(t, err)
320+
321+
parsed := objx.New(bsonToMap(opts)).Get("parsed").ObjxMap()
322+
323+
return expected == parsed.Get(selector).Data(), nil
324+
})
325+
313326
assert.NoError(t, err)
314327

315-
// The options are stored under the key "parsed"
316-
parsed := objx.New(bsonToMap(opts)).Get("parsed").ObjxMap()
317-
assert.Equal(t, expected, parsed.Get(selector).Data())
318328
}
319329
}
320330

0 commit comments

Comments
 (0)