Skip to content

Commit faf6dc1

Browse files
committed
Add retries to runner.List()
1 parent b6f49d0 commit faf6dc1

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

pkg/proxy/util/nfacct/nfacct.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ type Interface interface {
3131
Add(name string) error
3232
// Get retrieves the nfacct counter with the specified name, returning an error if it doesn't exist.
3333
Get(name string) (*Counter, error)
34-
// List retrieves all nfacct counters.
34+
// List retrieves nfacct counters, it could receive all counters or a subset of them with an unix.EINTR error.
3535
List() ([]*Counter, error)
3636
}

pkg/proxy/util/nfacct/nfacct_linux.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ import (
2929

3030
"github.com/vishvananda/netlink/nl"
3131
"golang.org/x/sys/unix"
32+
33+
"k8s.io/client-go/util/retry"
34+
"k8s.io/kubernetes/pkg/proxy/util"
3235
)
3336

3437
// MaxLength represents the maximum length allowed for the name in a nfacct counter.
@@ -146,9 +149,15 @@ func (r *runner) Get(name string) (*Counter, error) {
146149

147150
// List is part of the interface.
148151
func (r *runner) List() ([]*Counter, error) {
149-
req := r.handler.newRequest(cmdGet, unix.NLM_F_REQUEST|unix.NLM_F_DUMP)
150-
msgs, err := req.Execute(unix.NETLINK_NETFILTER, 0)
151-
if err != nil {
152+
var err error
153+
var msgs [][]byte
154+
err = retry.OnError(util.MaxAttemptsEINTR, util.ShouldRetryOnEINTR, func() error {
155+
req := r.handler.newRequest(cmdGet, unix.NLM_F_REQUEST|unix.NLM_F_DUMP)
156+
msgs, err = req.Execute(unix.NETLINK_NETFILTER, 0)
157+
return err
158+
})
159+
160+
if err != nil && !errors.Is(err, unix.EINTR) {
152161
return nil, handleError(err)
153162
}
154163

@@ -160,7 +169,7 @@ func (r *runner) List() ([]*Counter, error) {
160169
}
161170
counters = append(counters, counter)
162171
}
163-
return counters, nil
172+
return counters, err
164173
}
165174

166175
var ErrObjectNotFound = errors.New("object not found")

0 commit comments

Comments
 (0)