apache/pulsar · error · PulsarAdminException

Resource group does not exist: ${name}

Error message

Resource group does not exist: ${name}

What it means

resourceGroupDelete throws PulsarAdminException when no resource group exists under the given name. Deletion requires an existing group; the follow-on check (error on tenant/namespace refs) only runs for existing groups.

Source

Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java:165

            throw new PulsarAdminException("Resource group does not exist: " + rgName);
        }
        rg.updateResourceGroup(rgConfig);
        rgUpdates.labels(rgName).inc();
    }

    public Set<String> resourceGroupGetAll() {
        return resourceGroupsMap.keySet();
    }

    /**
     * Delete RG.
     *
     * @throws if RG with that name does not exist, or if the RG exists but is still in use.
     */
    public void resourceGroupDelete(String name) throws PulsarAdminException {
        ResourceGroup rg = this.getResourceGroupInternal(name);
        if (rg == null) {
            throw new PulsarAdminException("Resource group does not exist: " + name);
        }

        long tenantRefCount = rg.getResourceGroupNumOfTenantRefs();
        long nsRefCount = rg.getResourceGroupNumOfNSRefs();
        if ((tenantRefCount + nsRefCount) > 0) {
            String errMesg = "Resource group " + name + " still has " + tenantRefCount + " tenant refs";
            errMesg += " and " + nsRefCount + " namespace refs on it";
            throw new PulsarAdminException(errMesg);
        }

        rg.resourceGroupPublishLimiter = null;
        resourceGroupsMap.remove(name);
    }

    /**
     * Get the current number of RGs. For testing.
     */
    protected long getNumResourceGroups() {

View on GitHub (pinned to 820761864e)

Solutions

  1. Verify the group exists with resourceGroupGet before deleting; treat not-found as success in idempotent cleanup.
  2. Check the exact name spelling and target cluster.
  3. If deletion races with another actor, catch PulsarAdminException with this message and continue.
  4. If the group exists but delete still fails for refs, first remove tenant/namespace references (see the still-has-tenant-refs error).

Example fix

// before
svc.resourceGroupDelete("rg1"); // fails if rg1 absent
// after
try {
  svc.resourceGroupDelete("rg1");
} catch (PulsarAdminException e) {
  if (!e.getMessage().contains("does not exist")) throw e; // idempotent delete
}
Defensive patterns

Strategy: validation

Validate before calling

if (!svc.resourceGroupGetAll().contains(name)) {
  return; // already gone; treat delete as idempotent no-op
}

Try / catch

try {
  svc.resourceGroupDelete(name);
} catch (PulsarAdminException e) {
  if (e.getMessage() != null && e.getMessage().startsWith("Resource group does not exist")) {
    log.info("Resource group {} already deleted; ignoring", name);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling resourceGroupDelete(name) when getResourceGroupInternal(name) returns null — the group was never created, already deleted, or the name is wrong.

Common situations: Double-delete from retry logic; typo in the name; deleting on the wrong cluster; cleanup scripts assuming groups exist from a prior environment.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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