Skip to content

NPE at io.javaoperatorsdk.operator.glue.reconciler.glue.GlueReconciler.getParentRelatedResource(GlueReconciler.java:346) #187

Open
@cmoulliard

Description

@cmoulliard

Issue

When I try to use a resourceTemplate defined as such

apiVersion: io.javaoperatorsdk.operator.glue/v1beta1
kind: GlueOperator
metadata:
  name: ingress-platform
spec:
  parent:
    apiVersion: halkyon.io/v1alpha1
    kind: Platform
  childResources:
    - name: jobs
      bulk: true
      resourceTemplate: |
        items:
        {#for p in parent.spec.packages}
        - apiVersion: v1
          kind: ConfigMap
          metadata:
            name: {p.name}
            namespace: default
          data:
            key: "value-{p.name}"
        {/for}

with the following CRD

apiVersion: "apiextensions.k8s.io/v1"
kind: "CustomResourceDefinition"
metadata:
  name: platforms.halkyon.io # "platforms.io.javaoperatorsdk.operator.glue"
spec:
  group: halkyon.io # "io.javaoperatorsdk.operator.glue"
  names:
    kind: "Platform"
    plural: "platforms"
    singular: "platform"
  scope: "Cluster"
  versions:
  - name: v1alpha1 # v1beta1
    schema:
      openAPIV3Schema:
        properties:
          spec:
            properties:
              description:
                type: "string"
              name:
                type: "string"
              packages:
                items:
                  properties:
                    description:
                      type: "string"
                    name:
                      type: "string"
                    pipeline:
                      properties:
                        description:
                          type: "string"
                        name:
                          type: "string"
                        steps:
                          items:
                            properties:
                              description:
                                type: "string"
                              repoUrl:
                                type: "string"
                              version:
                                type: "string"
                              id:
                                type: "string"
                              image:
                                type: "string"
                              name:
                                type: "string"
                              script:
                                type: "string"
                              valuesObject:
                                description: "ValuesObject specifies Helm values to\
                                  \ be passed to helm template, defined as a map."
                                type: "object"
                                x-kubernetes-preserve-unknown-fields: true
                            type: "object"
                          type: "array"
                      type: "object"
                  type: "object"
                type: "array"
              version:
                type: "string"
            type: "object"
          status:
            properties:
              message:
                type: "string"
              phase:
                type: "string"
            type: "object"
        type: "object"
    served: true
    storage: true
    subresources:
      status: {}

then we got the following error when we deplouy the YAML

apiVersion: halkyon.io/v1alpha1
kind: Platform
metadata:
  name: simple-platform
spec:
  version: 0.1.0
  description: "A simple platform"
  packages:
    - name: nginx-ingress
      description: "nginx-ingress package"
      pipeline:
        steps:
        - name: pre-install
          image: registry.access.redhat.com/ubi9
          script: |
            echo "This is a pre-installation running a job"
        - name: "Install nginx-ingress"
          repoUrl: https://kubernetes.github.io/ingress-nginx
          version: 4.12.2
          valuesObject:
            ingress:
              enabled: true
        - name: post-install
          image: registry.access.redhat.com/ubi9
          script: |
            echo "This is a post-installation running a job"

Error

2025-05-27 09:23:02,528 ERROR [io.jav.ope.pro.eve.EventProcessor] (ReconcilerExecutor-glue-111) Error during event processing ExecutionScope{ resource id: ResourceID{name='simple-platform-platform', namespace='default'}, version: 69002}: io.javaoperatorsdk.operator.OperatorException: java.lang.NullPointerException
	at io.javaoperatorsdk.operator.processing.Controller.cleanup(Controller.java:222)
	at io.javaoperatorsdk.operator.processing.event.ReconciliationDispatcher.handleCleanup(ReconciliationDispatcher.java:258)
	at io.javaoperatorsdk.operator.processing.event.ReconciliationDispatcher.handleDispatch(ReconciliationDispatcher.java:95)
	at io.javaoperatorsdk.operator.processing.event.ReconciliationDispatcher.handleExecution(ReconciliationDispatcher.java:68)
	at io.javaoperatorsdk.operator.processing.event.EventProcessor$ReconcilerExecutor.run(EventProcessor.java:467)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.NullPointerException
	at java.base/java.util.Objects.requireNonNull(Objects.java:233)
	at java.base/java.util.Optional.of(Optional.java:113)
	at io.javaoperatorsdk.operator.glue.reconciler.glue.GlueReconciler.lambda$getParentRelatedResource$18(GlueReconciler.java:357)
	at java.base/java.util.Optional.flatMap(Optional.java:289)
	at io.javaoperatorsdk.operator.glue.reconciler.glue.GlueReconciler.getParentRelatedResource(GlueReconciler.java:346)
	at io.javaoperatorsdk.operator.glue.reconciler.glue.GlueReconciler.removeFinalizerForParent(GlueReconciler.java:316)
	at io.javaoperatorsdk.operator.glue.reconciler.glue.GlueReconciler.cleanup(GlueReconciler.java:117)
	at io.javaoperatorsdk.operator.glue.reconciler.glue.GlueReconciler.cleanup(GlueReconciler.java:39)
	at io.javaoperatorsdk.operator.glue.reconciler.glue.GlueReconciler_ClientProxy.cleanup(Unknown Source)
	at io.javaoperatorsdk.operator.processing.Controller$2.execute(Controller.java:209)
	at io.javaoperatorsdk.operator.processing.Controller$2.execute(Controller.java:170)
	at io.javaoperatorsdk.operator.api.monitoring.Metrics.timeControllerExecution(Metrics.java:159)
	at io.javaoperatorsdk.operator.processing.Controller.cleanup(Controller.java:169)
	... 7 more

See the screenshot where the error occurs when we debug

Image

The problem is related to the fact that the HashMap created includes a resource but the value is null

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions