davsclaus opened a new pull request, #29102:
URL: https://github.com/apache/camel/pull/29102

   Fixes [CAMEL-26240](https://issues.apache.org/jira/browse/CAMEL-26240).
   
   Each bug of the issue, as numbered there:
   
   **1. custom-resources ignores the crd\* options.** `getCRDContext` checked 
`crdName`, `crdGroup`, `crdScope`, `crdVersion` and `crdPlural` (else the 
headers), then built the context from the headers only. With only the options 
set, every operation failed with "Neither kind nor plural was set". It now 
builds the context from the values it resolved.
   
   **2. getCustomResource of a missing name failed.** `.require()` throws a 
`ResourceNotFoundException`, which the 404 catch did not handle. It now uses 
`.get()` and returns the empty `JsonObject` the code meant to return. The shape 
of a found instance is unchanged (`GenericKubernetesResource.get()`, as before).
   
   **3. A 409 on create/update was swallowed.** The conflict was logged at INFO 
and the body was an empty `GenericKubernetesResource`, so the exchange 
succeeded although nothing was created or updated. The 
`KubernetesClientException` now fails the exchange, as in all the other 
kubernetes producers. For an update, a 409 means the change was lost.
   
   **4. Consumer: inverted namespace check.** It logged "namespace is not 
specified." at ERROR when the namespace was set. The check is inverted. There 
is no test for this log line.
   
   **5. scale fails without status.** `scaleDeployment` and 
`scaleReplicationController` returned `getStatus().getReplicas()`. That is a 
NPE when the resource has no status yet, and the current count otherwise. They 
now return the replicas of the spec of the scaled resource (the requested 
number if the spec has none).
   
   **6. listPersistentVolumesByLabels without labels.** This failed with a NPE 
(`"m" is null`). It now fails with an `IllegalArgumentException` that the 
labels header is required, like the other ByLabels operations. The same fix is 
applied to `listNodesByLabels` and `listCustomResourcesByLabels`, which had the 
same NPE.
   
   **7. The namespace option is ignored by the producers.** A new 
`KubernetesHelper.extractNamespace` returns the `CamelKubernetesNamespaceName` 
header, or else the `namespace` option. The namespaced kubernetes-* producers 
use it: config-maps, cronjob, deployments, events, hpa, job, 
persistent-volumes-claims, pods, replication-controllers, resources-quota, 
secrets, service-accounts and services. The header still wins.
   
   **8. secrets: the annotations header changed the Secret header.** The 
annotations were set on the caller's `Secret` in place, and a `Secret` without 
metadata failed with a NPE. They are now set on a copy 
(`SecretBuilder.editOrNewMetadata()`).
   
   **9. Docs.** `updateService` is added to the operation list of 
kubernetes-services.
   
   ### Tests
   
   - `KubernetesCustomResourcesProducerCrudTest` and 
`KubernetesProducersCrudTest` run against the fabric8 mock server in CRUD mode.
   - 12 of the 13 new tests fail without the fix. The 13th checks that the 
header still wins over the option.
   - Module: 193 tests, 0 failures, 6 skipped. `-Psourcecheck` is clean.
   
   ### Docs and generated files
   
   - The `@BodyTypes` descriptions of custom-resources (no "empty one when it 
already exists"; empty `JsonObject` when not found), deployments and 
replication-controllers (spec replicas) are updated.
   - The catalog JSON and the services doc are regenerated.
   - Upgrade guide 4.24: a new `camel-kubernetes` section covers the namespace 
fallback, the crd\* options, the 409 and the scale result.
   
   ### Not changed
   
   - The openshift-\* producers are not changed: that is CAMEL-26241.
   - The custom-resources producer keeps its existing order: the `namespace` 
option wins over the header. Changing that order could break existing routes.
   - kubernetes-namespaces does not fall back to the option. There the header 
names the namespace that is got, created or deleted, not the scope of the 
operation.
   - The consumer with no namespace still calls `inNamespace(null)`. Only the 
log line is fixed.
   
   ### Open questions
   
   - 409 on `createCustomResource`: some routes may rely on an idempotent 
create. I chose to fail, to match the other producers. The alternative is to 
keep swallowing the 409 on create only and set a header.
   - Namespace order: should the custom-resources producer also let the header 
win, like the others now do?
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to