Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix content headers in Health Check Node Port response #26458

Merged
merged 2 commits into from
Jun 26, 2023

Conversation

cezarygerard
Copy link
Contributor

@cezarygerard cezarygerard commented Jun 23, 2023

Fix content headers in Health Check Node Port response.

Before the fix 2 content headers are not returned, because w.WriteHeader(http.StatusOK) must be called after setting the headers map

Fix: Return "Content-Type" and "X-Content-Type-Options" headers from  Health Check Node Port

@cezarygerard cezarygerard requested a review from a team as a code owner June 23, 2023 11:52
@maintainer-s-little-helper
Copy link

Commit 19e3244f61b09fc21bbb67f713685cecc80c56da does not contain "Signed-off-by".

Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin

@maintainer-s-little-helper maintainer-s-little-helper bot added dont-merge/needs-sign-off The author needs to add signoff to their commits before merge. dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. labels Jun 23, 2023
@github-actions github-actions bot added the kind/community-contribution This was a contribution made by a community member. label Jun 23, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-sign-off The author needs to add signoff to their commits before merge. label Jun 23, 2023
before the fix 2 content headers are not returned

```release-note
Fix: Return "Content-Type" and "X-Content-Type-Options" headers from  Health Check Node Port
```

Signed-off-by: Cezary Zawadka <czawadka@google.com>
Copy link
Contributor

@dlapcevic dlapcevic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@borkmann borkmann added the release-note/bug This PR fixes an issue in a previous release of Cilium. label Jun 23, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Jun 23, 2023
@borkmann
Copy link
Member

/test

@@ -8,6 +8,7 @@ import (
"net/http/httptest"
"testing"

"github.com/google/go-cmp/cmp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to run gofmt on this file

ake: *** [Makefile:645: precheck] Error 1
Unformatted Go source code:
make: *** Waiting for unfinished jobs....
./pkg/service/healthserver/healthserver_test.go
diff ./pkg/service/healthserver/healthserver_test.go.orig ./pkg/service/healthserver/healthserver_test.go
--- ./pkg/service/healthserver/healthserver_test.go.orig
+++ ./pkg/service/healthserver/healthserver_test.go
@@ -8,8 +8,8 @@
 	"net/http/httptest"
 	"testing"
 
-	"github.com/google/go-cmp/cmp"
 	. "github.com/cilium/checkmate"
+	"github.com/google/go-cmp/cmp"
 )
 
 type ServiceHealthServerSuite struct{}
@@ -94,7 +94,7 @@
 	assertRespHeader(c, resp, "Content-Type", "application/json")
 	assertRespHeader(c, resp, "X-Content-Type-Options", "nosniff")
 	resp.Body.Close()
-	
+

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if svc.LocalEndpoints == 0 {
w.WriteHeader(http.StatusServiceUnavailable)
} else {
w.WriteHeader(http.StatusOK)
}
w.Header().Set("Content-Type", "application/json")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not look that using trailers instead of headers are on purpose, and using headers is coherent with kube-proxy https://github.com/kubernetes/kubernetes/blob/027ac5a426a261ba6b66a40e79e123e75e9baf5b/pkg/proxy/healthcheck/proxier_health.go#L159-L173 , since this is a "replacement" it makes sense to be consistent.
Also, the failing test indicates that the goal may have been to use headers in the first place

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signed-off-by: Cezary Zawadka <czawadka@google.com>
@aojea
Copy link
Contributor

aojea commented Jun 26, 2023

/lgtm
/assign @borkmann @aanm

@borkmann
Copy link
Member

/test

@borkmann borkmann added release-blocker/1.14 This issue will prevent the release of the next version of Cilium. needs-backport/1.13 This PR / issue needs backporting to the v1.13 branch labels Jun 26, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from main in 1.13.5 Jun 26, 2023
Copy link
Member

@gandro gandro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Did this actually cause issues or how did you find this?

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Jun 26, 2023
@ldelossa
Copy link
Contributor

All required tests passing, and multiple committers approved. Merging 🚀

@ldelossa ldelossa merged commit fc105dd into cilium:main Jun 26, 2023
64 of 65 checks passed
@aojea
Copy link
Contributor

aojea commented Jun 26, 2023

Looks good to me. Did this actually cause issues or how did you find this?

google loadbalancers can use the headers for passing the data of the existing endpoints on the node and this way use weights, the headers were not coming at all 😄

@tklauser tklauser mentioned this pull request Jun 28, 2023
3 tasks
@tklauser tklauser added backport-pending/1.13 The backport for Cilium 1.13.x for this PR is in progress. and removed needs-backport/1.13 This PR / issue needs backporting to the v1.13 branch labels Jun 28, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Needs backport from main to Backport pending to v1.13 in 1.13.5 Jun 28, 2023
@tklauser tklauser added backport-done/1.13 The backport for Cilium 1.13.x for this PR is done. and removed backport-pending/1.13 The backport for Cilium 1.13.x for this PR is in progress. labels Jun 28, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Backport pending to v1.13 to Backport done to v1.13 in 1.13.5 Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-done/1.13 The backport for Cilium 1.13.x for this PR is done. kind/community-contribution This was a contribution made by a community member. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-blocker/1.14 This issue will prevent the release of the next version of Cilium. release-note/bug This PR fixes an issue in a previous release of Cilium.
Projects
No open projects
1.13.5
Backport done to v1.13
Development

Successfully merging this pull request may close these issues.

None yet

9 participants