Skip to content

Trying to execute into pod results in 500 Internal Server error #3912

Open
@adityank11

Description

@adityank11

java.net.ProtocolException: Expected HTTP 101 response but was '500 Internal Server Error'

I am trying to execute a script in each pod of my namespace.

public void checkPods() 
{
    try 
    {
        V1PodList podList = api.listNamespacedPod(this.namespace).execute();
        int threshold = 80;
        String[] cmd = {"bash", "-c", "exec df -h | awk '$5 > " + threshold + " {print}' 2>/dev/null"};
        
        for (V1Pod pod : podList.getItems()) {
            String podName = pod.getMetadata().getName();
            Exec exec = new Exec(this.apiClient);
            Process p = exec.exec(pod, cmd, true);
        }
    } 
    catch (ApiException | IOException e) {
        throw new RuntimeException("Error executing command in pods", e);
    }
}

The above code is always giving the correct output but not without this error being thrown multiple times first. How to solve this error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions