Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: convert the memory value to decimal format #386

Merged
merged 1 commit into from
Jun 10, 2022
Merged

fix: convert the memory value to decimal format #386

merged 1 commit into from
Jun 10, 2022

Conversation

tpiperatgod
Copy link
Contributor

Signed-off-by: laminar tpiperatgod@gmail.com

(If this PR fixes a github issue, please add Fixes #<xyz>.)

Fixes #375

(or if this PR is one task of a github issue, please add Master Issue: #<xyz> to link to the master issue.)

Master Issue: #

Motivation

Java commands require memory values in resource.DecimalSI format.

Modifications

Convert memory values passed into the MakeJavaFunctionCommand function to decimal format

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Documentation

Check the box below.

Need to update docs?

  • doc-required

    (If you need help on updating docs, create a doc issue)

  • no-need-doc

    (Please explain why)

  • doc

    (If this PR contains doc changes)

@github-actions github-actions bot added the no-need-doc This pr does not need any document label Jun 10, 2022
@tpiperatgod
Copy link
Contributor Author

An example is as follows:

This is the configuration file for a Function, and I set its spec.resources.requests.memory value to 500Mi, which is a binary format units.

apiVersion: compute.functionmesh.io/v1alpha1
kind: Function
metadata:
  name: function-sample
  namespace: default
spec:
  image: streamnative/pulsar-functions-java-sample:2.10.0.4
  className: org.apache.pulsar.functions.api.examples.ExclamationFunction
  forwardSourceMessageProperty: true
  maxPendingAsyncRequests: 1000
  replicas: 1
  maxReplicas: 5
  logTopic: persistent://public/default/logging-function-logs
  input:
    topics:
    - persistent://public/default/input-java-topic
    typeClassName: java.lang.String
  output:
    topic: persistent://public/default/output-java-topic
    typeClassName: java.lang.String
  resources:
    requests:
      cpu: "0.1"
      memory: 500Mi

In the pod corresponding to the Function, we can see that it has been converted to a decimal format value -Xmx524288k.

spec:
  containers:
  - command:
    - sh
    - -c
    - SHARD_ID=${POD_NAME##*-} && echo shardId=${SHARD_ID} && exec java -cp /pulsar/instances/java-instance.jar
      -Dpulsar.functions.instance.classpath=/pulsar/lib/* -Dlog4j.configurationFile=kubernetes_instance_log4j2.xml
      -Dpulsar.function.log.dir=logs/functions -Dpulsar.function.log.file=function-sample-${SHARD_ID}
      -Xmx524288k

Java commands require memory values in resource.DecimalSI format.

Signed-off-by: laminar <tpiperatgod@gmail.com>
@freeznet freeznet merged commit 058d943 into streamnative:master Jun 10, 2022
@tpiperatgod tpiperatgod deleted the fix-375 branch June 11, 2022 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
m/2022-12 no-need-doc This pr does not need any document type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The numeric suffix of resources causes an exception: "Invalid maximum heap size: -Xmx1000Mi"
3 participants