Skip to content

Commit 49ba264

Browse files
committed
BUG/MINOR: raw: return full raw config on GET and POST responses
Also adds Configuration-Checksum and Cluster-Version response headers.
1 parent 4dc3b75 commit 49ba264

File tree

6 files changed

+285
-26
lines changed

6 files changed

+285
-26
lines changed

embedded_spec.go

+68
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ require (
2121
github.com/go-openapi/swag v0.22.4
2222
github.com/go-openapi/validate v0.22.1
2323
github.com/google/renameio v1.0.1
24-
github.com/google/uuid v1.3.0
25-
github.com/haproxytech/client-native/v4 v4.1.10
24+
github.com/google/uuid v1.3.1
25+
github.com/haproxytech/client-native/v4 v4.1.11
2626
github.com/haproxytech/config-parser/v4 v4.1.5
2727
github.com/hashicorp/consul/api v1.22.0
2828
github.com/hashicorp/hcl v1.0.0
@@ -34,8 +34,8 @@ require (
3434
github.com/rs/cors v1.9.0
3535
github.com/shirou/gopsutil v3.21.11+incompatible
3636
github.com/sirupsen/logrus v1.9.3
37-
github.com/stretchr/testify v1.8.3
38-
golang.org/x/net v0.14.0
37+
github.com/stretchr/testify v1.8.4
38+
golang.org/x/net v0.12.0
3939
golang.org/x/sys v0.12.0
4040
gopkg.in/yaml.v2 v2.4.0
4141
)
@@ -56,7 +56,7 @@ require (
5656
github.com/fatih/color v1.15.0 // indirect
5757
github.com/go-ole/go-ole v1.2.6 // indirect
5858
github.com/go-openapi/analysis v0.21.4 // indirect
59-
github.com/go-openapi/jsonpointer v0.19.6 // indirect
59+
github.com/go-openapi/jsonpointer v0.20.0 // indirect
6060
github.com/go-openapi/jsonreference v0.20.2 // indirect
6161
github.com/gofrs/flock v0.8.1 // indirect
6262
github.com/google/go-cmp v0.5.9 // indirect
@@ -87,7 +87,7 @@ require (
8787
github.com/tklauser/go-sysconf v0.3.11 // indirect
8888
github.com/tklauser/numcpus v0.6.1 // indirect
8989
github.com/yusufpapurcu/wmi v1.2.3 // indirect
90-
go.mongodb.org/mongo-driver v1.12.0 // indirect
91-
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect
90+
go.mongodb.org/mongo-driver v1.12.1 // indirect
91+
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
9292
gopkg.in/yaml.v3 v3.0.1 // indirect
9393
)

go.sum

+14-13
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ github.com/go-openapi/errors v0.20.4 h1:unTcVm6PispJsMECE3zWgvG4xTiKda1LIR5rCRWL
8888
github.com/go-openapi/errors v0.20.4/go.mod h1:Z3FlZ4I8jEGxjUK+bugx3on2mIAk4txuAOhlsB1FSgk=
8989
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
9090
github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
91-
github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE=
9291
github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
92+
github.com/go-openapi/jsonpointer v0.20.0 h1:ESKJdU9ASRfaPNOPRx12IUyA1vn3R9GiE3KYD14BXdQ=
93+
github.com/go-openapi/jsonpointer v0.20.0/go.mod h1:6PGzBjjIIumbLYysB73Klnms1mwnU4G3YHOECG3CedA=
9394
github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns=
9495
github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo=
9596
github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE=
@@ -163,11 +164,11 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/
163164
github.com/google/renameio v1.0.1 h1:Lh/jXZmvZxb0BBeSY5VKEfidcbcbenKjZFzM/q0fSeU=
164165
github.com/google/renameio v1.0.1/go.mod h1:t/HQoYBZSsWSNK35C6CO/TpPLDVWvxOHboWUAweKUpk=
165166
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
166-
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
167-
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
167+
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
168+
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
168169
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
169-
github.com/haproxytech/client-native/v4 v4.1.10 h1:FyCKNO76k/OZiBIhtGHYtdoDt5wq+uczy3vzf17VI7w=
170-
github.com/haproxytech/client-native/v4 v4.1.10/go.mod h1:YI7cBryojiSqiL407ZhvrIPJA0QSCsJNgVO0ULPDnaU=
170+
github.com/haproxytech/client-native/v4 v4.1.11 h1:m1g9w/wUcn+41gz8eVHodS0al9Ayiim/ObKoCe3sF0A=
171+
github.com/haproxytech/client-native/v4 v4.1.11/go.mod h1:nSywQLzMz85fYFm4MLaF6SW2mPltctvj/q3ILo91KUI=
171172
github.com/haproxytech/config-parser/v4 v4.1.5 h1:7Uf4ljHZ/rxWLxf2B+mp6tVDZOf5vNGm7AGsN5ovCZE=
172173
github.com/haproxytech/config-parser/v4 v4.1.5/go.mod h1:Pof9e9ohFCyX1dPhxENjAC3MXgWh28KXo2Z8T/0sOrc=
173174
github.com/haproxytech/go-logger v1.1.0 h1:HgGtYaI1ApkvbQdsm7f9AzQQoxTB7w37criTflh7IQE=
@@ -372,8 +373,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
372373
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
373374
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
374375
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
375-
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
376-
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
376+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
377+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
377378
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
378379
github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM=
379380
github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI=
@@ -399,17 +400,17 @@ github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQ
399400
go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg=
400401
go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng=
401402
go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8=
402-
go.mongodb.org/mongo-driver v1.12.0 h1:aPx33jmn/rQuJXPQLZQ8NtfPQG8CaqgLThFtqRb0PiE=
403-
go.mongodb.org/mongo-driver v1.12.0/go.mod h1:AZkxhPnFJUoH7kZlFkVKucV20K387miPfm7oimrSmK0=
403+
go.mongodb.org/mongo-driver v1.12.1 h1:nLkghSU8fQNaK7oUmDhQFsnrtcoNy7Z6LVFKsEecqgE=
404+
go.mongodb.org/mongo-driver v1.12.1/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ=
404405
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
405406
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
406407
golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
407408
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
408409
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
409410
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
410411
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
411-
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ=
412-
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8=
412+
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
413+
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
413414
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
414415
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
415416
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -422,8 +423,8 @@ golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy
422423
golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
423424
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
424425
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
425-
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
426-
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
426+
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
427+
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
427428
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
428429
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
429430
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

handlers/raw.go

+20-6
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,16 @@ func (h *GetRawConfigurationHandlerImpl) Handle(params configuration.GetHAProxyC
5858
return configuration.NewGetConfigurationVersionDefault(int(*e.Code)).WithPayload(e)
5959
}
6060

61-
v, data, err := cfg.GetRawConfiguration(t, v)
61+
v, clusterVersion, md5Hash, data, err := cfg.GetRawConfigurationWithClusterData(t, v)
6262
if err != nil {
6363
e := misc.HandleError(err)
6464
return configuration.NewGetHAProxyConfigurationDefault(int(*e.Code)).WithPayload(e)
6565
}
66-
return configuration.NewGetHAProxyConfigurationOK().WithPayload(&configuration.GetHAProxyConfigurationOKBody{Version: v, Data: &data})
66+
cVersion := ""
67+
if clusterVersion != 0 {
68+
cVersion = strconv.FormatInt(clusterVersion, 10)
69+
}
70+
return configuration.NewGetHAProxyConfigurationOK().WithPayload(&configuration.GetHAProxyConfigurationOKBody{Version: v, Data: &data}).WithClusterVersion(cVersion).WithConfigurationChecksum(md5Hash)
6771
}
6872

6973
// Handle executing the request and returning a response
@@ -115,9 +119,19 @@ func (h *PostRawConfigurationHandlerImpl) Handle(params configuration.PostHAProx
115119
return configuration.NewPostHAProxyConfigurationDefault(int(*e.Code)).WithPayload(e)
116120
}
117121

122+
_, clusterVersion, md5Hash, data, err := cfg.GetRawConfigurationWithClusterData("", 0)
123+
if err != nil {
124+
e := misc.HandleError(err)
125+
return configuration.NewPostHAProxyConfigurationDefault(int(*e.Code)).WithPayload(e)
126+
}
127+
128+
cVersion := ""
129+
if clusterVersion != 0 {
130+
cVersion = strconv.FormatInt(clusterVersion, 10)
131+
}
118132
if onlyValidate {
119133
// return here without reloading, since config is only validated.
120-
return configuration.NewPostHAProxyConfigurationAccepted().WithPayload(params.Data)
134+
return configuration.NewPostHAProxyConfigurationAccepted().WithPayload(data).WithClusterVersion(cVersion).WithConfigurationChecksum(md5Hash)
121135
}
122136
if skipReload {
123137
if params.XRuntimeActions != nil {
@@ -126,7 +140,7 @@ func (h *PostRawConfigurationHandlerImpl) Handle(params configuration.PostHAProx
126140
return configuration.NewPostHAProxyConfigurationDefault(int(*e.Code)).WithPayload(e)
127141
}
128142
}
129-
return configuration.NewPostHAProxyConfigurationCreated().WithPayload(params.Data)
143+
return configuration.NewPostHAProxyConfigurationCreated().WithPayload(data).WithClusterVersion(cVersion).WithConfigurationChecksum(md5Hash)
130144
}
131145
if forceReload {
132146
var callbackNeeded bool
@@ -145,7 +159,7 @@ func (h *PostRawConfigurationHandlerImpl) Handle(params configuration.PostHAProx
145159
e := misc.HandleError(err)
146160
return configuration.NewPostHAProxyConfigurationDefault(int(*e.Code)).WithPayload(e)
147161
}
148-
return configuration.NewPostHAProxyConfigurationCreated().WithPayload(params.Data)
162+
return configuration.NewPostHAProxyConfigurationCreated().WithPayload(data).WithClusterVersion(cVersion).WithConfigurationChecksum(md5Hash)
149163
}
150164
callbackNeeded, reconfigureFunc, err := cn.ReconfigureRuntime(h.Client, runtimeAPIsOld)
151165
if err != nil {
@@ -160,7 +174,7 @@ func (h *PostRawConfigurationHandlerImpl) Handle(params configuration.PostHAProx
160174
rID = h.ReloadAgent.Reload()
161175
}
162176

163-
return configuration.NewPostHAProxyConfigurationAccepted().WithReloadID(rID).WithPayload(params.Data)
177+
return configuration.NewPostHAProxyConfigurationAccepted().WithReloadID(rID).WithPayload(data).WithClusterVersion(cVersion).WithConfigurationChecksum(md5Hash)
164178
}
165179

166180
func executeRuntimeActions(actionsStr string, client client_native.HAProxyClient) error {

operations/configuration/get_h_a_proxy_configuration_responses.go

+44
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)