[
https://issues.apache.org/jira/browse/CAMEL-26240?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on CAMEL-26240 started by Claus Ibsen.
-------------------------------------------
> camel-kubernetes - custom-resources ignores the crd* endpoint options, and
> scale fails with a NullPointerException when the resource has no status yet
> ------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-26240
> URL: https://issues.apache.org/jira/browse/CAMEL-26240
> Project: Camel
> Issue Type: Bug
> Components: camel-kubernetes
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Major
> Fix For: 4.24.0
>
>
> Found while adding the catalog body types of the kubernetes components
> (CAMEL-24961, PR #28399 and PR #28400). The openshift-* components are in a
> separate issue.
> h4. 1. kubernetes-custom-resources producer ignores the crd* endpoint options
> {{KubernetesCustomResourcesProducer.getCRDContext}} (main 2a465aa4814c, lines
> 226-255) checks the {{crdName}}, {{crdGroup}}, {{crdScope}}, {{crdVersion}}
> and {{crdPlural}} options (else the headers), but builds the context from the
> headers only (lines 257-262). With only the endpoint options set, every
> operation fails; listCustomResources fails with "Neither kind nor plural was
> set". Checked on 4.24.0-SNAPSHOT with the fabric8 Kubernetes mock server in
> CRUD mode.
> Proposed: build the context from the resolved values.
> h4. 2. kubernetes-custom-resources getCustomResource of a missing name fails
> {{doGet}} (line 152) calls {{.require()}}, which throws a
> {{ResourceNotFoundException}} that the 404 catch (lines 155-160) does not
> handle, so a missing name fails the exchange instead of returning the empty
> JsonObject the code means to return. Checked on 4.24.0-SNAPSHOT with the
> fabric8 Kubernetes mock server in CRUD mode.
> Proposed: use {{.get()}} and return the empty JsonObject (or null) when it is
> null.
> h4. 3. kubernetes-custom-resources create/update: a 409 is swallowed
> {{doCreateOrUpdate}} (lines 208-214) catches a 409 Conflict, logs it at INFO,
> and sets an empty {{GenericKubernetesResource}} as the body, so the exchange
> succeeds although nothing was created or updated. Checked on 4.24.0-SNAPSHOT
> with the fabric8 Kubernetes mock server in CRUD mode.
> Proposed: let the conflict fail the exchange (or set a header that says so).
> h4. 4. kubernetes-custom-resources consumer: inverted namespace check
> {{KubernetesCustomResourcesConsumer}} (lines 87-88) logs "namespace is not
> specified." at ERROR when a namespace IS set ({{isNotEmpty}}). Checked on
> 4.24.0-SNAPSHOT with the fabric8 Kubernetes mock server in CRUD mode.
> Proposed: invert the check.
> h4. 5. scale fails when the resource has no status yet (deployments,
> replication-controllers)
> {{KubernetesDeploymentsProducer}} scaleDeployment (line 235) and
> {{KubernetesReplicationControllersProducer}} scaleReplicationController (line
> 229) return {{getStatus().getReplicas()}}: when the returned resource has no
> status yet this is a NullPointerException, and otherwise it is the current
> count, which may lag behind the requested one. Checked on 4.24.0-SNAPSHOT
> with the fabric8 Kubernetes mock server in CRUD mode.
> Proposed: return the requested replicas (or {{getSpec().getReplicas()}}) and
> guard against a null status.
> h4. 6. persistent-volumes listPersistentVolumesByLabels without labels
> {{KubernetesPersistentVolumesProducer}} (line 80) passes the labels header to
> {{withLabels(labels)}}; without it this fails with a NullPointerException
> '"m" is null'. Checked on 4.24.0-SNAPSHOT with the fabric8 Kubernetes mock
> server in CRUD mode.
> Proposed: fail with a message that the labels header is required (or list all
> when it is missing).
> h4. 7. The namespace URI option is used only by consumers
> The producers checked in PR #28400 (persistent-volumes-claims,
> replication-controllers, resources-quota, secrets, service-accounts,
> services, and the openshift ones) read the namespace from
> {{CamelKubernetesNamespaceName}} only (for example
> {{KubernetesServicesProducer}} line 90); the {{namespace}} endpoint option is
> ignored. In main only {{KubernetesCustomResourcesProducer}} reads the option.
> Checked on 4.24.0-SNAPSHOT with the fabric8 Kubernetes mock server in CRUD
> mode.
> Proposed: fall back to the {{namespace}} option when the header is not set,
> in all producers.
> h4. 8. kubernetes-secrets: the annotations header mutates the Secret header
> {{KubernetesSecretsProducer.doCreateOrUpdateSecret}} (lines 159-160) sets the
> annotations on the {{Secret}} from the {{CamelKubernetesSecret}} header in
> place, so the caller's object is changed, and a Secret without metadata fails
> with a NullPointerException. Read in the code, not run.
> Proposed: copy the Secret (or its metadata) before adding the annotations,
> and create the metadata when it is missing.
> h4. 9. Docs: kubernetes-services misses updateService
> The producer operation list of {{kubernetes-services-component.adoc}} (lines
> 35-36) has createService and deleteService but not updateService. Not fixed
> in the PR.
> Proposed: add updateService.
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)