Skip to content

oidc-bootstrap hook blocks kubernetes-* upgrades on clusters without the Keycloak CRDs (ineffective api-resources guard) #3516

Closed

Description

@mattia-eleuteri

What happened

The oidc-bootstrap Job (packages/apps/kubernetes/templates/oidc-rbac-job.yaml), which runs as a
post-install,post-upgrade Helm hook with backoffLimit: 6, fails on any cluster that does not have the
Keycloak operator CRDs installed, even at oidc.mode: None:

mode=None: force-cleaning chart-owned OIDC resources Helm's SSA apply cannot reap...
  patching KamajiControlPlane <cluster> — remove OIDC-only entries ...
  deleting chart-owned OIDC Secrets
  deleting chart-owned Keycloak objects
error: the server doesn't have a resource type "keycloakclient"

Because it is a hook, the failure blocks the Helm upgrade of the kubernetes-<cluster> release.

Root cause

The cleanup step is guarded, but the guard is ineffective:

if kubectl api-resources --api-group=v1.edp.epam.com >/dev/null 2>&1; then
  echo "  deleting chart-owned Keycloak objects"
  kubectl ... delete keycloakclient.v1.edp.epam.com ... --ignore-not-found

kubectl api-resources --api-group=<absent group> exits 0 and simply prints an empty list, so the guard
always passes. The subsequent delete then fails because the resource type is unknown, and --ignore-not-found
does not help for an unknown type (only for a missing object).

Impact

On a cluster without the Keycloak operator (a perfectly supported configuration: oidc.mode: None is the
default), every kubernetes-* HelmRelease upgrade is blocked until the CRDs are installed. Our workaround was to
apply the two CRDs (keycloakclients, keycloakclientscopes) empty, with no operator and no CRs, purely to make
the guard's delete succeed.

Suggested fix

Guard on a non-empty result rather than on the exit code, for example:

if [ -n "$(kubectl api-resources --api-group=v1.edp.epam.com -o name 2>/dev/null)" ]; then

or test the CRD directly with kubectl get crd keycloakclients.v1.edp.epam.com --ignore-not-found -o name.

Environment

Cozystack v1.6.0, tenant Kubernetes app at oidc.mode: None (chart default), no keycloak-operator package.

Activity

  1. added a commit that references this issue on Sep 3, 2026
    356a377
  2. added
    kind/bugCategorizes issue or PR as related to a bug
    area/kubernetesIssues or PRs related to the tenant Kubernetes app
    area/keycloakIssues or PRs related to Keycloak (SSO / identity)
    triage/acceptedIndicates an issue is ready to be actively worked on
    priority/important-soonMust be staffed and worked on either currently, or very soon, ideally in time for the next release
    and removed
    triage/needs-triageIndicates an issue needs triage by a maintainer
    on Sep 23, 2026
  3. added a commit that references this issue on Sep 29, 2026
    06400ac
  4. added a commit that references this issue on Sep 29, 2026
    ff0752d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/keycloakIssues or PRs related to Keycloak (SSO / identity)area/kubernetesIssues or PRs related to the tenant Kubernetes appkind/bugCategorizes issue or PR as related to a bugpriority/important-soonMust be staffed and worked on either currently, or very soon, ideally in time for the next releasetriage/acceptedIndicates an issue is ready to be actively worked on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions