restlet / restlet-framework-java

The first REST API framework for Java
https://restlet.talend.com
647 stars 284 forks source link

k8s nginx ingress 2.4.0 2.4.1 422 Errors #1344

Open LargoUsagi opened 5 years ago

LargoUsagi commented 5 years ago

When deploying a restlet application inside of a docker container to a k8s cluster behind the nginx l7 ingress controller HTTP POST actions return a 422 error.

If you expose a port on the host in the cluster and connect without using the nginx ingress controller POST actions work.

This issue is not present in 2.3.12 and rolling back is how I am mitigating the issue.

Here are the restlet dependencies used in my pom

        <dependency>
            <groupId>org.restlet.jse</groupId>
            <artifactId>org.restlet</artifactId>
            <version>${restlet-version}</version>
        </dependency>
        <dependency>
            <groupId>org.restlet.jse</groupId>
            <artifactId>org.restlet.ext.jackson</artifactId>
            <version>${restlet-version}</version>
        </dependency>
        <dependency>
            <groupId>org.restlet.jse</groupId>
            <artifactId>org.restlet.ext.jetty</artifactId>
            <version>${restlet-version}</version>
        </dependency>
        <dependency>
            <groupId>org.restlet.jse</groupId>
            <artifactId>org.restlet.ext.slf4j</artifactId>
            <version>${restlet-version}</version>
        </dependency>

Here is an example of a failing resource.

ApiResource is a public abstract class ApiResource extends ServerResource class that has protected helper functions.

public class RegisterResource extends ApiResource {

    private final ApplicationUserRegistrationService userRegistrationService;

    @Inject
    public RegisterResource(ApplicationUserRegistrationService userRegistrationService) {
        this.userRegistrationService = userRegistrationService;
    }

    @Post("json")
    public boolean register(RegistrationCredentialsDto creds) {
        var user = userRegistrationService.attemptRegisterNewUser(creds);
        if(user != null) {
            this.setStatus(Status.SUCCESS_CREATED);
            return true;
        }
        this.setStatus(Status.CLIENT_ERROR_CONFLICT);
        return false;
    }

}
cyberquarks commented 3 years ago

@LargoUsagi you may be interested in joining the "Unofficial Restlet Community" https://gitter.im/restlet-framework/community?utm_source=share-link&utm_medium=link&utm_campaign=share-link