apache/pulsar · error · IllegalArgumentException
Per instance cpu requested, %s, ram requested, %s, for funct
Error message
Per instance cpu requested, %s, ram requested, %s, for function should be positive and the same multiple of the granularity, cpu, %s, ram, %s
What it means
When functionInstanceResourceChangeInLockStep is enabled, CPU and RAM must scale together: the multiples of their respective granularities must be identical. KubernetesRuntimeFactory computes cpu multiples and ramMultiples during admission; if they differ, doAdmissionChecks throws this IllegalArgumentException.
Source
Thrown at pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeFactory.java:529
functionDetails.getResources().getCpu(), grnCpu));
}
if (functionInstanceResourceChangeInLockStep) {
multiples = cpuMillis / grnCpuMillis;
}
}
}
if (grnRam != null && grnRam > 0) {
if (functionDetails.getResources().getRam() == 0
|| functionDetails.getResources().getRam() % grnRam != 0) {
throw new IllegalArgumentException(
String.format("Per instance ram requested, %s, "
+ "for function should be positive and a multiple of the granularity, %s",
functionDetails.getResources().getRam(), grnRam));
}
if (functionInstanceResourceChangeInLockStep && multiples > 0) {
long ramMultiples = functionDetails.getResources().getRam() / grnRam;
if (multiples != ramMultiples) {
throw new IllegalArgumentException(
String.format("Per instance cpu requested, %s, ram requested, %s,"
+ " for function should be positive and the same multiple of the "
+ "granularity, cpu, %s, ram, %s",
functionDetails.getResources().getCpu(),
functionDetails.getResources().getRam(), grnCpu, grnRam));
}
}
}
}
}
@Override
public Optional<KubernetesFunctionAuthProvider> getAuthProvider() {
return authProvider;
}
@Override
public Optional<KubernetesManifestCustomizer> getRuntimeCustomizer() {View on GitHub (pinned to 820761864e)
Solutions
- Set cpu and ram so that both are the SAME multiple of their granularities (e.g. 2x cpu granularity and 2x ram granularity).
- Disable functionInstanceResourceChangeInLockStep in the worker config if independent cpu/ram scaling is intended.
- Increase cpu and ram proportionally when scaling a function instance up or down.
- Verify both resources after every update; the check runs on each doAdmissionChecks pass.
Example fix
// before (granularity cpu=0.5, ram=1GB, lockStep=true) resources: cpu: 1.0 # 2 multiples ram: 1GB # 1 multiple // after resources: cpu: 1.0 # 2 multiples ram: 2GB # 2 multiples
Defensive patterns
Strategy: validation
Validate before calling
long cpuMultiples = Math.round(1000 * resources.getCpu()) / Math.round(1000 * grnCpu);
long ramMultiples = resources.getRam() / grnRam;
if (lockStepEnabled && cpuMultiples != ramMultiples) {
throw new IllegalArgumentException("cpu and ram must be the same multiple of their granularities");
} Type guard
boolean isLockStepConsistent(double cpu, long ramBytes, double grnCpu, long grnRam) {
long cpuM = Math.round(1000 * cpu) / Math.round(1000 * grnCpu);
long ramM = ramBytes / grnRam;
return cpuM == ramM;
} Prevention
- Scale cpu and ram together (same multiple count) when lock-step mode is on.
- Disable functionInstanceResourceChangeInLockStep if independent scaling is a requirement.
- Re-validate resources after every function update; admission checks run each time.
When it happens
Trigger: Submitting/updating a function with lock-step resource changes enabled where cpu/grnCpu != ram/grnRam — e.g. cpu=1.0 (2 multiples of 0.5) with ram=1GB (1 multiple of 1GB).
Common situations: Scaling cpu and ram independently while functionInstanceResourceChangeInLockStep=true; adjusting only one resource during a function update; provisioning bundles sized by different rules for cpu and memory.
Related errors
- Per instance cpu requested, %s, for function should be posit
- Per instance ram requested, %s, for function should be posit
- Function runtime customizer %s must implement KubernetesMani
- KubernetesSecretsProviderConfigurator should only be setup f
- UNSUPPORTED_ISSUER
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/e9056d057a331bca.
Report an issue: GitHub.