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

K8s pod keeps getting restarted when http client object creation is within resource function #24705

Closed
nilushancosta opened this issue Jul 13, 2020 · 2 comments
Assignees
Labels

Comments

@nilushancosta
Copy link

nilushancosta commented Jul 13, 2020

Description:
I deployed the following ballerina passthrough service on Kubernetes. JMeter was used as the client and a Netty echo service as the backend.

import ballerina/http;
import ballerina/log;

@http:ServiceConfig {
    basePath: "/"
}
service testapi1 on new http:Listener(8090) {

    @http:ResourceConfig {
        methods: ["POST"],
        path: "/api1"
    }
    resource function api1(http:Caller caller, http:Request req) {
        http:Client API1 = new("http://<NettyIP>:8600");
        var response = API1->forward("/", req);

        if (response is http:Response) {
            var result = caller->respond(response);
        } else {
            log:printError("Error at h1c_h1c_passthrough", err = response);
            http:Response res = new;
            res.statusCode = 500;
            res.setPayload(response.message());
            var result = caller->respond(res);
        }
    }
}

This resulted in the pod being restarted even for low concurrency tests (concurrency of 5).
However when I move http:Client API1 = new("http://<NettyIP>:8600"); out of the service as follows, the service works without an issue.

import ballerina/http;
import ballerina/log;

http:Client API1 = new("http://<NettyIP>:8600");

@http:ServiceConfig {
    basePath: "/"
}
<code omitted>

Steps to reproduce:
Run the passthrough service given above with the specified line in the resource function block and outside the service block

Affected Versions:
Swan Lake Preview 1

OS, DB, other environment details and versions:
Kubernetes version - 1.16

Resource requests and limits are as follows

apiVersion: v1
kind: LimitRange
metadata:
  name: lr-cpu-mem
spec:
  limits:
  - default:
      cpu: 500m
      memory: 768Mi
    defaultRequest:
      cpu: 100m
      memory: 256Mi
    type: Container
@malithjayasinghe
Copy link
Contributor

When repeating the tests please ensure that you apply the same resource limits. The observability should be on

@Bhashinee
Copy link
Member

Fixed with #24738

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

No branches or pull requests

5 participants