@@ -27,7 +27,7 @@ type ReservationPoller interface {
2727 // from is the used as a filter to which reservation to use as
2828 // reservation.ID >= from. So a client to the Poll method should make
2929 // sure to call it with the last (MAX) reservation ID he receieved.
30- Poll (nodeID pkg.Identifier , from uint64 ) ([]* Reservation , error )
30+ Poll (nodeID pkg.Identifier , from uint64 ) (reservations []* Reservation , lastID uint64 , err error )
3131}
3232
3333// PollSource does a long poll on address to get new and to be deleted
@@ -50,7 +50,6 @@ type pollSource struct {
5050
5151func (s * pollSource ) Reservations (ctx context.Context ) <- chan * Reservation {
5252 ch := make (chan * Reservation )
53-
5453 // on the first run we will get all the reservation
5554 // ever made to this know, to make sure we provision
5655 // everything at boot
@@ -65,39 +64,26 @@ func (s *pollSource) Reservations(ctx context.Context) <-chan *Reservation {
6564 on = time .Now ().Add (s .maxSleep )
6665 log .Info ().Uint64 ("next" , next ).Msg ("Polling for reservations" )
6766
68- res , err := s .store .Poll (pkg .StrIdentifier (s .nodeID ), next )
67+ res , lastID , err := s .store .Poll (pkg .StrIdentifier (s .nodeID ), next )
6968 if err != nil && err != ErrPollEOS {
7069 // if this is not a temporary error, then skip the reservation entirely
7170 // and try to get the next one
7271 if shouldRetry (err ) {
7372 log .Error ().Err (err ).Uint64 ("next" , next ).Msg ("failed to get reservation, retry same" )
7473 } else {
7574 log .Error ().Err (err ).Uint64 ("next" , next ).Msg ("failed to get reservation" )
76- next ++
75+ next = lastID + 1
7776 }
7877 continue
7978 }
8079
80+ next = lastID + 1
81+
8182 select {
8283 case <- ctx .Done ():
8384 return
8485 default :
8586 for _ , r := range res {
86- current , _ , err := r .SplitID ()
87- if err != nil {
88- log .Warn ().Err (err ).Str ("id" , r .ID ).Msg ("skipping reservation" )
89- continue
90- }
91- if current >= next {
92- next = current + 1
93- }
94-
95- if r .Type == NOOPReservation {
96- // special type of reservation that does nothing
97- // we just ignore it here.
98- continue
99- }
100-
10187 ch <- r
10288 }
10389 }
0 commit comments