Skip to content

Commit

Permalink
Merge pull request #746 from jcmoraisjr/jm-fix-dns-ep
Browse files Browse the repository at this point in the history
Fix incorrect reload if endpoint list grows
  • Loading branch information
jcmoraisjr authored Mar 8, 2021
2 parents 1fa4c33 + 0d1878a commit 7241e17
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/haproxy/dynupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ func (d *dynUpdater) checkBackendPair(pair *backendPair) bool {

// Resolver == update via DNS discovery
if curBack.Resolver != "" {
if updated {
// DNS based updates finishes prematurelly. Ensure the ep
// list size of the new one is at least as big as the old one.
for i := len(curBack.Endpoints); i < len(oldBack.Endpoints); i++ {
curBack.AddEmptyEndpoint()
}
}
return updated
}

Expand Down
20 changes: 20 additions & 0 deletions pkg/haproxy/dynupdate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,26 @@ set server default_app_8080/srv001 state ready
set server default_app_8080/srv001 weight 1`,
logging: `INFO-V(2) updated endpoint '172.17.0.3:8080' weight '1' state 'ready' on backend/server 'default_app_8080/srv001'`,
},
// 27
{
doconfig1: func(c *testConfig) {
b := c.config.Backends().AcquireBackend("default", "app", "8080")
b.Resolver = "k8s"
b.AcquireEndpoint("172.17.0.2", 8080, "")
b.AddEmptyEndpoint()
},
doconfig2: func(c *testConfig) {
b := c.config.Backends().AcquireBackend("default", "app", "8080")
b.Resolver = "k8s"
b.Dynamic.DynUpdate = true
b.AcquireEndpoint("172.17.0.3", 8080, "")
},
expected: []string{
"srv001:172.17.0.3:8080:1",
"srv002:127.0.0.1:1023:1",
},
dynamic: true,
},
}
for i, test := range testCases {
c := setup(t)
Expand Down

0 comments on commit 7241e17

Please # to comment.