{"record":{"id":"66a281f77f9908d7","repo":"apache/pulsar","slug":"per-instance-cpu-requested-s-for-function-is-gr","errorCode":null,"errorMessage":"Per instance CPU requested, %s, for function is greater than the maximum required, %s","messagePattern":"Per instance CPU requested, (.+?), for function is greater than the maximum required, (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeFactory.java","lineNumber":481,"sourceCode":"                            String.format(\"Per instance RAM requested is not specified. \"\n                                    + \"Must specify RAM requested for function to be at least %s\", minRam));\n                } else if (functionDetails.getResources().getRam() < minRam) {\n                    throw new IllegalArgumentException(\n                            String.format(\"Per instance RAM requested, %s, \"\n                                            + \"for function is less than the minimum required, %s\",\n                                    functionDetails.getResources().getRam(), minRam));\n                }\n            }\n        }\n    }\n\n    void validateMaxResourcesRequired(FunctionDetails functionDetails) {\n        if (functionInstanceMaxResources != null) {\n            Double maxCpu = functionInstanceMaxResources.getCpu();\n            Long maxRam = functionInstanceMaxResources.getRam();\n\n            if (maxCpu != null && functionDetails.getResources().getCpu() > maxCpu) {\n                throw new IllegalArgumentException(\n                        String.format(\n                                \"Per instance CPU requested, %s, for function is greater than the maximum required, %s\",\n                                functionDetails.getResources().getCpu(), maxCpu));\n            }\n\n            if (maxRam != null && functionDetails.getResources().getRam() > maxRam) {\n                throw new IllegalArgumentException(\n                        String.format(\n                                \"Per instance RAM requested, %s, for function is greater than the maximum required, %s\",\n                                functionDetails.getResources().getRam(), maxRam));\n            }\n        }\n    }\n\n    void validateResourcesGranularityAndProportion(FunctionDetails functionDetails) {\n        final long baseMillis = 1000;\n        long multiples = 0L;\n        if (functionInstanceResourceGranularities != null) {","sourceCodeStart":463,"sourceCodeEnd":499,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeFactory.java#L463-L499","documentation":"validateMaxResourcesRequired enforces a worker-configured maximum CPU per function instance. If functionDetails.resources.cpu exceeds functionInstanceMaxResources.cpu, Pulsar throws IllegalArgumentException with both values to prevent oversized functions from being admitted to Kubernetes.","triggerScenarios":"Submitting/updating a function whose --cpu is greater than the cluster's configured functionInstanceMaxResources.cpu (doAdmissionChecks -> validateMaxResourcesRequired, line 481).","commonSituations":"Scaling CPU up without checking cluster caps; copying configs from a cluster without maximums; accidental unit mistakes (cores vs millicores); cluster admin tightening max resources after deployment.","solutions":["Reduce the function's --cpu to at most the configured maximum.","Split the workload into more function instances with lower per-instance CPU instead of raising per-instance CPU.","Ask the cluster admin to raise functionInstanceMaxResources.cpu if the cap is too low.","Check whether a units mistake (millicores vs cores) inflated the requested value."],"exampleFix":"// before\n--cpu 8\n// after\n--cpu 2  (assuming max cpu is 2) -- or increase --instances to scale out","handlingStrategy":"validation","validationCode":"Double maxCpu = workerCfg.getFunctionInstanceMaxResources().getCpu();\nif (maxCpu != null && details.getResources().getCpu() > maxCpu) {\n    throw new IllegalArgumentException(\"cpu \" + details.getResources().getCpu() + \" > allowed max \" + maxCpu);\n}","typeGuard":null,"tryCatchPattern":"try { admin.functions().updateFunction(config); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"greater than the maximum\")) { /* lower cpu / scale out instances */ } throw e; }","preventionTips":["Cap CPU in deployment templates to the cluster maximum","Prefer horizontal scale (more instances) over raising per-instance CPU","Watch for core-vs-millicore unit mistakes"],"tags":["kubernetes","resources","cpu","quota","admission"],"backgroundTag":"resource-quota-exceeded","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}