Skip to content

Commit

Permalink
use case-insensitive header keys for http probes
Browse files Browse the repository at this point in the history
  • Loading branch information
dddddai committed Apr 17, 2023
1 parent 892f0dc commit f1a4bfb
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion api/openapi-spec/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/openapi-spec/v3/api__v1_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2552,7 +2552,7 @@
"properties": {
"name": {
"default": "",
"description": "The header field name",
"description": "The header field name. This will be canonicalized upon output, so case-variant names will be understood as the same header.",
"type": "string"
},
"value": {
Expand Down
2 changes: 1 addition & 1 deletion api/openapi-spec/v3/apis__apps__v1_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2488,7 +2488,7 @@
"properties": {
"name": {
"default": "",
"description": "The header field name",
"description": "The header field name. This will be canonicalized upon output, so case-variant names will be understood as the same header.",
"type": "string"
},
"value": {
Expand Down
2 changes: 1 addition & 1 deletion api/openapi-spec/v3/apis__batch__v1_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1799,7 +1799,7 @@
"properties": {
"name": {
"default": "",
"description": "The header field name",
"description": "The header field name. This will be canonicalized upon output, so case-variant names will be understood as the same header.",
"type": "string"
},
"value": {
Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2012,7 +2012,8 @@ type SecretEnvSource struct {

// HTTPHeader describes a custom header to be used in HTTP probes
type HTTPHeader struct {
// The header field name
// The header field name.
// This will be canonicalized upon output, so case-variant names will be understood as the same header.
Name string
// The header field value
Value string
Expand Down
2 changes: 1 addition & 1 deletion pkg/generated/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/kubelet/prober/prober.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (pb *prober) runProbeWithRetries(probeType probeType, p *v1.Probe, pod *v1.
func buildHeader(headerList []v1.HTTPHeader) http.Header {
headers := make(http.Header)
for _, header := range headerList {
headers[header.Name] = append(headers[header.Name], header.Value)
headers.Add(header.Name, header.Value)
}
return headers
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/kubelet/prober/prober_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ func TestHTTPHeaders(t *testing.T) {
{Name: "X-Muffins-Or-Cupcakes", Value: "Muffins"},
{Name: "X-Muffins-Or-Cupcakes", Value: "Cupcakes, too"},
}, http.Header{"X-Muffins-Or-Cupcakes": {"Muffins", "Cupcakes, too"}}},
{[]v1.HTTPHeader{
{Name: "HOST", Value: "example.com"},
{Name: "FOO-bAR", Value: "value"},
}, http.Header{"Host": {"example.com"},
"Foo-Bar": {"value"}}},
}
for _, test := range testCases {
headers := buildHeader(test.input)
Expand Down
3 changes: 2 additions & 1 deletion staging/src/k8s.io/api/core/v1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion staging/src/k8s.io/api/core/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2112,7 +2112,8 @@ type SecretEnvSource struct {

// HTTPHeader describes a custom header to be used in HTTP probes
type HTTPHeader struct {
// The header field name
// The header field name.
// This will be canonicalized upon output, so case-variant names will be understood as the same header.
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
// The header field value
Value string `json:"value" protobuf:"bytes,2,opt,name=value"`
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f1a4bfb

Please sign in to comment.