@@ -50,13 +50,15 @@ func isNetworkError(err error) bool {
5050func (c * Client ) getConnection (ctx context.Context , isModify bool , f func (client * ldapConn ) error ) error {
5151 l := ctxzap .Extract (ctx )
5252
53+ var err error
5354 connectAttempts := 0
5455 for connectAttempts < maxConnectAttempts {
5556 if connectAttempts > 0 {
5657 l .Warn ("baton-ldap: retrying connection" , zap .Int ("attempts" , connectAttempts ), zap .Int ("maxAttempts" , maxConnectAttempts ))
5758 time .Sleep (time .Duration (connectAttempts ) * time .Second )
5859 }
59- cp , err := c .pool .Acquire (ctx )
60+ var cp * puddle.Resource [* ldapConn ]
61+ cp , err = c .pool .Acquire (ctx )
6062 if err != nil {
6163 if isNetworkError (err ) {
6264 l .Warn ("baton-ldap: network error acquiring connection. retrying" , zap .Error (err ), zap .Int ("attempts" , connectAttempts ), zap .Int ("maxAttempts" , maxConnectAttempts ))
@@ -99,7 +101,7 @@ func (c *Client) getConnection(ctx context.Context, isModify bool, f func(client
99101 cp .Release ()
100102 break
101103 }
102- return nil
104+ return err
103105}
104106
105107func parsePageToken (pageToken string ) (string , []byte , error ) {
@@ -172,8 +174,6 @@ func (c *Client) _ldapSearch(ctx context.Context,
172174 var ret []* ldap.Entry
173175 var nextPageToken string
174176
175- // TODO (ggreer): Reconnecting with a pageToken doesn't work because the ldap cookie is per-connection
176- // To fix this, we should restart the query with no pageToken
177177 err := c .getConnection (ctx , false , func (client * ldapConn ) error {
178178 if pageSize <= 0 {
179179 pageSize = defaultPageSize
0 commit comments