Bug 1775736 - KubeAPI server doesn't accept patch requests > 1MB
Summary: KubeAPI server doesn't accept patch requests > 1MB
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: kube-apiserver
Version: 4.2.0
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
: 4.2.z
Assignee: Stefan Schimanski
QA Contact: Xingxing Xia
Depends On: 1776189
Blocks: 1775757
TreeView+ depends on / blocked
Reported: 2019-11-22 17:04 UTC by Lukasz Szaszkiewicz
Modified: 2020-01-02 14:56 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2019-12-03 22:43:15 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Github openshift origin pull 24190 0 'None' closed Bug 1775736: KubeAPI server doesn't accept large patch requests 2020-12-03 06:55:57 UTC
Red Hat Product Errata RHBA-2019:3953 0 None None None 2019-12-03 22:43:23 UTC

Description Lukasz Szaszkiewicz 2019-11-22 17:04:06 UTC
The following PR[1] fixes bounds checking of large JSON patches in KubeAPI server. Before that sending/applying large (1 MB) patches were not possible[2]. The PR has been already backported to the master branch [3]


Comment 3 Xingxing Xia 2019-11-26 10:59:10 UTC
In 4.2.0-0.nightly-2019-11-25-200935 env, like bug 1687691#c9, prepare >1M file and verified:
for i in {1..1024}; do echo -n a >> bytes-1k.txt; done
for i in {1..1034}; do cat bytes-1k.txt >> bytes-1m-more.txt; done
cat > mypod-a.part << EOF
    "kind": "Pod",
    "apiVersion": "v1",
    "metadata": {
        "name": "mypod"
    "spec": {
        "containers": [
                "name": "mypod",
                "image": "openshift/hello-openshift",
                "env": [
                        "name": "ENV0",
cat > mypod-b.part << EOF
echo -n "`cat mypod-a.part`" > mypod-a1.part
echo -n ' "' >> mypod-a1.part
cat bytes-1m-more.txt >> mypod-a1.part
echo '"' >> mypod-a1.part
cat mypod-b.part >> mypod-a1.part
mv mypod-a1.part mypod-final.json
ls -lh bytes-1m-more.txt
-rw-rw-r--. 1 xxia qe 1.1M Nov 26 18:53 bytes-1m-more.txt
oc create -f mypod-final.json
pod/mypod created

Comment 4 Xingxing Xia 2019-11-26 14:05:20 UTC
From PR, verify json patch > 1M:
oc create deployment hello-openshift --image=openshift/hello-openshift
oc set env deployment hello-openshift ENV0=abc
echo -n '[{"op": "replace", "path": "/spec/template/spec/containers/0/env/0/value", "value": "' > patch.json
cat bytes-1m-more.txt >> patch-part1.json
echo -n '"}]' >> patch-part1.json
ls -lh patch.json
-rw-rw-r--. 1 xxia qe 1.1M Nov 26 21:59 patch.json # > 1M
curl -k -X PATCH https://...:6443/apis/extensions/v1beta1/namespaces/xxia-proj/deployments/hello-openshift -H "Content-Type: application/json-patch+json" -H "Authorization: Bearer $TOKEN" -d @patch.json # succeeded

Comment 6 errata-xmlrpc 2019-12-03 22:43:15 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.