Bug 1775736

Summary: KubeAPI server doesn't accept patch requests > 1MB
Product: OpenShift Container Platform Reporter: Lukasz Szaszkiewicz <lszaszki>
Component: kube-apiserverAssignee: Stefan Schimanski <sttts>
Status: CLOSED ERRATA QA Contact: Xingxing Xia <xxia>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.2.0CC: aos-bugs, mfojtik
Target Milestone: ---   
Target Release: 4.2.z   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-12-03 22:43:15 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1776189    
Bug Blocks: 1775757    

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]

[1]https://github.com/kubernetes/kubernetes/pull/84963/files
[2]https://github.com/kubernetes/kubernetes/issues/84908
[3]https://github.com/openshift/origin/pull/24183

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",
                        "value":
EOF
cat > mypod-b.part << EOF
                    }
                ]
            }
        ]
    }
}
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.

https://access.redhat.com/errata/RHBA-2019:3953