K8s API Server 400 Error

1/7/2017

I am seeing some strange behavior with K8s 1.5.1 API server. A GET request is sent for /api, 200 response arrives orderly, but the subsequent ACK is followed by 400 and FIN :

23:12:13.032057 IP localhost.52218 > localhost.http-alt: Flags [P.], seq 1:169, ack 1, win 86, options [nop,nop,TS val 3882137617 ecr 3882136607], length 168: HTTP: GET /api HTTP/1.1
23:12:13.032078 IP localhost.http-alt > localhost.52218: Flags [.], ack 169, win 88, options [nop,nop,TS val 3882137617 ecr 3882137617], length 0
23:12:13.032569 IP localhost.http-alt > localhost.52218: Flags [P.], seq 1:243, ack 169, win 88, options [nop,nop,TS val 3882137618 ecr 3882137617], length 242: HTTP: HTTP/1.1 200 OK
23:12:13.032584 IP localhost.52218 > localhost.http-alt: Flags [.], ack 243, win 88, options [nop,nop,TS val 3882137618 ecr 3882137618], length 0
23:12:13.032621 IP localhost.http-alt > localhost.52218: Flags [P.], seq 243:331, ack 169, win 88, options [nop,nop,TS val 3882137618 ecr 3882137618], length 88: HTTP: HTTP/1.1 400 Bad Request
23:12:13.032633 IP localhost.52218 > localhost.http-alt: Flags [.], ack 331, win 88, options [nop,nop,TS val 3882137618 ecr 3882137618], length 0
23:12:13.032666 IP localhost.http-alt > localhost.52218: Flags [F.], seq 331, ack 169, win 88, options [nop,nop,TS val 3882137618 ecr 3882137618], length 0

Same client code was running fine with earlier versions of the API server. Can anyone shed some light on this behavior?

-- Alex
kubernetes

1 Answer

1/7/2017

Ok, I found the culprit - request has HTTP basic-auth header ending with \n. Although the request as a whole is properly ended with CRLFCRLF, and there's no trailing garbage after that, somehow the API server interprets the \n as a beginning of new request. Kubernetes API server bug?

-- Alex
Source: StackOverflow