Skip to content

Commit f7eac0c

Browse files
rmaticevicmjuraga
authored andcommitted
MINOR: cluster: check response code based on registration method
1 parent 3e74d51 commit f7eac0c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

configuration/cluster_sync.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ type ClusterSync struct {
7373
ReloadAgent haproxy.IReloadAgent
7474
}
7575

76+
var expectedResponseCodes = map[string]int{
77+
"POST": 201,
78+
"PUT": 200,
79+
}
80+
7681
func (c *ClusterSync) Monitor(cfg *Configuration, cli *client_native.HAProxyClient) {
7782
c.cfg = cfg
7883
c.cli = cli
@@ -362,7 +367,7 @@ func (c *ClusterSync) issueJoinRequest(url, port, basePath string, registerPath
362367
if err != nil {
363368
return err
364369
}
365-
if resp.StatusCode != 201 {
370+
if resp.StatusCode != expectedResponseCodes[registerMethod] {
366371
return fmt.Errorf("status code not proper [%d] %s", resp.StatusCode, string(body))
367372
}
368373
var responseData Node

0 commit comments

Comments
 (0)