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

   Fixes [CAMEL-26511](https://issues.apache.org/jira/browse/CAMEL-26511).
   
   Both points of the issue are real and fixed here.
   
   ### 1. The socket option is documented with default `true`, but defaults to 
`false`
   
   **What was wrong:** `DockerConfiguration.socket` has `@UriParam(defaultValue 
= "true")`, and the `CamelDockerSocketEnabled` header in `DockerConstants` has 
`defaultValue = "true"`. The field is a plain `boolean`, so it is `false`, and 
the component connects to `tcp://localhost:2375` by default.
   
   **Which side to fix:** the docs. The history says the code side is the 
intended one:
   - `defaultValue = "true"` came with the docker-java upgrade in CAMEL-10307 
(2016, d09bc33af78b), but the field never got `= true`. At that time `toUrl()` 
built `unix://localhost:2375` in socket mode, which could not work, so `true` 
was never a working default.
   - CAMEL-13526 (2019, 842813896335) fixed the socket mode. It treats the 
socket as opt-in: the test sets `host=/var/run/docker.sock` together with 
`socket=true`, and `test-options.properties` has `#socket=true` commented out, 
with "To use a unix socket, specify the path to the docker daemon socket" on 
the host.
   
   So the effective default has been TCP for every release. Making it `true` 
now would switch every user without `socket` set from TCP to the socket.
   
   **What changed:** the documented default of the endpoint option, the 
component option and the header is `false`. The descriptions of `socket` and 
`host` say that in socket mode the host is the path of the socket, and the port 
is not used.
   
   ### 2. Socket mode with the default host gives `unix://localhost`
   
   **What was wrong:** with `socket=true`, `DockerClientProfile.toUrl()` built 
`unix://<host>`, so with the default `host=localhost` it was 
`unix://localhost`, which cannot connect (Netty: `connect(..) failed error(-22) 
Invalid argument`). It only worked with the host set to the socket path.
   
   **What changed:** in socket mode the default host `localhost` means 
`/var/run/docker.sock` (also the default socket of docker-java). Any other host 
is used as the path, as before. So `docker:info?socket=true` now works against 
the local daemon.
   
   ### Tests
   
   - `DockerClientProfileTest.clientProfileWithSocketDefaultHostUrlTest`: 
socket mode with the default host gives `unix:///var/run/docker.sock`. Failed 
before (`but was: <unix://localhost>`).
   - `DockerConfigurationTest.testSocketDefaultIsTheDocumentedDefault`: the 
default of `socket` in the generated `docker.json` (component option, endpoint 
option and header) equals the default of `DockerConfiguration`. Failed before 
(`expected: <false> but was: <true>`).
   - No Docker daemon is needed.
   - Full module: `mvn -o clean install -Psourcecheck` 69 tests, 0 failures (4 
skipped: the existing ITs that need a daemon).
   
   ### Docs and generated files
   
   - Component doc: new "Connecting to the Docker daemon" section (TCP by 
default, socket mode, host as the socket path).
   - Regenerated `docker.json`, copied to the catalog with the component doc; 
regenerated `DockerEndpointBuilderFactory` and `DockerComponentBuilderFactory`.
   - No upgrade guide entry: the effective default does not change (it was 
always TCP), and socket mode with the default host never connected before.
   
   ### Not changed
   
   - The default stays TCP. Docker does not open the TCP port by default, so 
the socket would be the friendlier default for a local daemon. But it would 
change how every existing route without `socket` set connects. If we want that, 
it should be its own change with an upgrade guide entry.
   
   _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