Need to place upper limit on activation response object
As with other resources, this needs to be controlled and documented. The idea would be that if a user action returns a result that is bigger than a threshold, then an error is flagged similar to exhausting other limits such as CPU limits. @rabbah and I considered a 1MB limit as a reasonable starting point.
Documenting plan:
- Response is sized by the invoker.
- If it exceeds the system limit, the invoker will reject it.
- If it is within the limits, it will be processed as usual.
- When the invoker rejects an action response, it will do the following:
- Construct an error response object with a message explaining the failure
- In addition, it will provide as a debugging aid a partial result that contains as many of the top level fields from the dictionary response into the error object.
- The error response for large responses shall include:
- "Action result of X MB exceeds system limit of Y MB".
- The number of top level fields contained in the response and how many are actually included in the partial response.
As part of doing this work, I will also apply the same technique to reject large incoming payloads which currently get rejected a bit later in the pipeline than they should.
On 3.ii, also include the sizes of the fields so a user knows that the rejection was due to some particular field being too bug.
There is a trade off involving invoker performance vs user debugging info.
I would for starter implement 3.2 behind a configuration flag turned off by default that can be turn on in ansible then downstream/operator can choose if they want their invokers to suffer by always trying parse/process the very large response into a json object into memory and the n inspecting the object to pick up fields to slim it down to fit the limit of 1mb
Iterating over each field and check and try to come up with all the fields that summing them together will be close to 1mb and marking the fields that don't fit the 1mb with some value like null
If the debugging flag is off, I would just make invoker create and store the reason message and then the first 1MB of raw (no JSON) data string
Something like { message: "Action result of X MB exceeds system limit of Y MB" payload:"{ a:1, b:"c", ..., z:"hell" " } payload above will be 1mb worth of data and it will be truncated z was suppose to be hello :-)
basically invoker takes the payload text from the response of the action proxy checks against the limit for the exception and then takes the first 1mb and stores it straig without trying to parse into JSON and try to find what are the largest fields to nuke to come up with a small 1mb JSON to store
Is the 1MB already a configuration setting in ansible that operator can in their production deployment?
Would make sense to optimized even more by making the action proxy for the runtimes check the the size of the result and check against limit?
That would save action proxy from Parsing the large data into json Sending a large payload over network to invoker
Action will convert the response into an error response with a payload of the first 1mb raw data
Still invoker would need to implement the check for docker actions which are black box, but the runtimes pre installed we would trust.
Commit https://github.com/openwhisk/openwhisk/commit/0a4ca55b29617ccf907f8b2db76db2fe97d47167 implements the variant suggest by @csantanapr - no attempt to parse the response in the invoker and instead return as many bytes as possible (up to the limit).
The limit is not deployment configurable yet - this is tied to how we configure the Kafka limit. Will open a separate issue to address the discrepancy between the stated limit and the message bus limit.
Will the limit of the response(or the request) be configurable in the future?
I'm trying to configure it now with checking Kafka limits. But it seems a little complex to adjust them.
Thanks for you reply!
it seems a little complex to adjust them
@kingzevin I have the same problem and look forward to be configurable for the limit. By the way, How do you adjust them .
I received the error from inover logs. The request included a message larger than the max message size the server will accept .
so I modified kafka-pod.yaml in openwhisk-deploy-kube.
add max.request.size and KAFKA_MESSAGE_MAX_BYTES
containers:
- name: kafka
image: "{{- .Values.docker.registry.name -}}{{- .Values.kafka.imageName -}}:{{- .Values.kafka.imageTag -}}"
imagePullPolicy: {{ .Values.kafka.imagePullPolicy | quote }}
command: ["/bin/bash", "-c", "export KAFKA_BROKER_ID=`hostname | awk -F '-' '{print $NF}'`; echo 'max.request.size=5000000' >> /opt/kafka/config/producer.properties ; /usr/bin/start-kafka.sh"]
{{- if .Values.k8s.persistence.enabled }}
volumeMounts:
- mountPath: /kafka
name: "{{ .Release.Name }}-kafka-pvc"
{{- end }}
ports:
- containerPort: {{ .Values.kafka.port }}
name: kafka
env:
- name: "HOSTNAME_COMMAND"
value: "hostname -f"
- name: "KAFKA_ADVERTISED_PORT"
value: "{{ .Values.kafka.port }}"
- name: "KAFKA_PORT"
value: "{{ .Values.kafka.port }}"
- name: "KAFKA_LISTENER_SECURITY_PROTOCOL_MAP"
value: "EXTERNAL:PLAINTEXT"
- name: "KAFKA_LISTENERS"
value: "EXTERNAL://:{{ .Values.kafka.port }}"
- name: "KAFKA_ADVERTISED_LISTENERS"
value: "EXTERNAL://_{HOSTNAME_COMMAND}:{{ .Values.kafka.port }}"
- name: "KAFKA_INTER_BROKER_LISTENER_NAME"
value: "EXTERNAL"
- name: "KAFKA_MESSAGE_MAX_BYTES"
value: "12000000"
But it is not working.
it seems a little complex to adjust them
@kingzevin I have the same problem and look forward to be configurable for the limit. By the way, How do you adjust them .
@kaivean I skipped and chose another store for a large response, e.g. couchdb. Good luck!