Skip to content

Cannot resolve requests containing cookies in Kubernetes #33735

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

Closed
rob-oberbeck opened this issue Jan 9, 2023 · 8 comments
Closed

Cannot resolve requests containing cookies in Kubernetes #33735

rob-oberbeck opened this issue Jan 9, 2023 · 8 comments

Comments

@rob-oberbeck
Copy link

rob-oberbeck commented Jan 9, 2023

Versions:

  • Spring Boot 3.0.1
  • Spring Cloud 2022.0.0
  • Kubernetes v1.22.11

Description:
Spring application cannot resolve requests containing cookies when running in a Kubernetes cluster.
However, running the application locally from the IDE works just fine.
Did not experience this issue with Spring Boot 2.7.6 and Spring Cloud 2021.0.5.

Given the application is deployed in a Kubernetes cluster, the following requests have been sent from the pod itself.

Request without a cookie:

curl 'http://localhost:80/management/health' 
{"status":"UP","groups":["liveness","readiness"]}

Request with cookie:

curl 'http://localhost:80/management/health' -H 'cookie: foo=bar'                                                                                                   
{"timestamp":"2023-01-09T14:15:48.105+00:00","status":404,"error":"Not Found","path":"barnagement/health"}

Server log:

{
   "timestamp":"2023-01-09 14:21:51.840",
   "logger":"org.springframework.web.servlet.PageNotFound",
   "level":"WARN",
   "message":"No mapping for foo barnagement/health"
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 9, 2023
@wilkinsona
Copy link
Member

Does the problem occur without Spring Cloud?

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Jan 9, 2023
@rob-oberbeck
Copy link
Author

rob-oberbeck commented Jan 9, 2023

Removed all the application code besides the main and removed Spring Cloud dependencies.
However, still facing the very same issue.

I'm using Spring actuator in this example but experienced the same behaviour with @RequestMapping.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 9, 2023
@wilkinsona
Copy link
Member

Thanks for trying things with a more minimal setup. It appears that something is using the value of the foo cookie to rewrite the URL. When you've set it to bar, the request to management/health has become a request to barnagement/health or perhaps foo barnagement/health.

I've never seen anything like this before, either with Kubernetes or without. As such, I am inclined to suspect that something in your K8S enviroment is causing the problem. What is listening on port 80? It's quite unusual for a Boot app to listen directly on port 80. If it's something else that's routing requests to the Boot application, what is it and how is it configured?

@wilkinsona wilkinsona added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Jan 9, 2023
@rob-oberbeck
Copy link
Author

Changing the port to 8080 and Docker image from mcr.microsoft.com/java/jdk:17-zulu-ubuntu to openjdk:17-alpine as build resolved the issue, at least for the minimal setup (Spring Boot without Spring Cloud and only a main method).
Unfortunately, the issue remains the same when running the complete application with an alpine image.
Interestingly, I only experience this behaviour in Kubernetes, everything works fine when running the Docker image on my local machine.

We'll have to do more investigation on our end to find the root cause.
For now we'll continue using Spring Boot 2.7.7.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 10, 2023
@wilkinsona wilkinsona added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Jan 10, 2023
@philwebb
Copy link
Member

@rob-oberbeck I'll close this one for now whilst you investigate. If you're able to create a simple reproducer, please let us know and we can reopen it.

@philwebb philwebb closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2023
@philwebb philwebb removed the status: waiting-for-feedback We need additional information before we can continue label Jan 10, 2023
@cxjava
Copy link

cxjava commented Jan 11, 2023

Same issue from our application.

Strange things is that: we have two application, one application can work fine with cookie, other application can't work fine, both are same spring boot version 3.0.1.

@cxjava
Copy link

cxjava commented Jan 11, 2023

@rob-oberbeck After our application upgrade com.datadoghq:dd-java-agent to 1.3.0, then fix this issue.

@rob-oberbeck
Copy link
Author

rob-oberbeck commented Jan 11, 2023

Did the same to fix the issue.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants