apache/pulsar · error · RuntimeException

Kubernetes job name size should be less than %s

Error message

Kubernetes job name size should be less than %s

What it means

KubernetesRuntime.getJobName-like validation checks the generated job/pod name against Kubernetes naming rules and a configured maximum size. Kubernetes only admits DNS-1123 labels (lowercase letters, numbers, hyphens) for object names, and names are capped in length. Pulsar throws a RuntimeException instead of submitting a job Kubernetes would reject.

Source

Thrown at pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntime.java:1172

        return convertedJobName + "-" + shortHash;
    }
    @VisibleForTesting
    String getServiceUrl(String jobName, String jobNamespace, int instanceId) {
        String suffix = isNotBlank(kubernetesServiceDomainSuffix) ? kubernetesServiceDomainSuffix : "svc.cluster.local";
        return String.format("%s-%d.%s.%s.%s", jobName, instanceId, jobName, jobNamespace, suffix);
    }
    public static void doChecks(FunctionDetails functionDetails, String overridenJobName) {
        final String jobName = createJobName(functionDetails, overridenJobName);
        if (!jobName.equals(jobName.toLowerCase())) {
            throw new RuntimeException("Kubernetes does not allow upper case jobNames.");
        }
        final Matcher matcher = VALID_POD_NAME_REGEX.matcher(jobName);
        if (!matcher.matches()) {
            throw new RuntimeException("Kubernetes only admits lower case and numbers. "
                    + "(jobName=" + jobName + ")");
        }
        if (jobName.length() > maxJobNameSize) {
            throw new RuntimeException("Kubernetes job name size should be less than " + maxJobNameSize);
        }
    }
}

View on GitHub (pinned to 820761864e)

Solutions

  1. Rename the function (and tenant/namespace components) to contain only lowercase alphanumerics and '-', e.g. 'my-func-1'.
  2. Shorten the tenant/namespace/function names so the composed job name is under maxJobNameSize (check runtime customizer or factory config).
  3. If the name is fixed, set a shorter tenant/namespace prefix or use a custom KubernetesManifestCustomizer to control naming.
  4. Catch the RuntimeException in the submission path and surface a clear 'invalid function name' error to the user before submitting.

Example fix

// before
functions: myFunction_WithCaps
// after
functions: myfunction-with-caps
Defensive patterns

Strategy: validation

Validate before calling

Pattern DNS = Pattern.compile("[a-z0-9]([-a-z0-9]*[a-z0-9])?");
String jobName = (tenant + "-" + namespace + "-" + functionName + "-" + suffix).toLowerCase();
if (!DNS.matcher(jobName).matches()) throw new IllegalArgumentException("invalid chars: " + jobName);
if (jobName.length() > 55) throw new IllegalArgumentException("job name too long: " + jobName);

Prevention

When it happens

Trigger: Deploying a function/connector/source/sink to Kubernetes whose derived job name (function name, tenant, namespace, plus random suffix) fails to match VALID_POD_NAME_REGEX or exceeds maxJobNameSize (checked in doAdmissionChecks/validation path at KubernetesRuntime.java:1172).

Common situations: Function or tenant names containing uppercase letters, underscores, dots, or other invalid characters; very long tenant/namespace/function names pushing the composed job name past the size limit (default 55); renaming conventions applied by CI that introduce invalid characters.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/e74db21c6c2b3d38. Report an issue: GitHub.