Skip to content

Commit

Permalink
xroot: handle haproxy and checksum command
Browse files Browse the repository at this point in the history
Motivation:
----------
When using xrootd doors behind an HAProxy w/
`xrootd.enable.proxy-protocol=true` it has been discovered
that
```
xrdcp --cksum adler32:<value> <source> <destiation>
```
hangs after upload has completed and then eventually fails
after a timeout. This is due to xrootd door repoting actual
door address to the client.

Modification:
-------------
Return destination address (that is haproxy address) if
`xrootd.enable.proxy-protocol=true` is set.

Result:
-------
```
xrdcp --cksum adler32:<value> <source> <destiation>
```
works as expected (and likely many other similar commands)

Target: trunk
Request: 10.*
Request: 9.2
Patch: https://rb.dcache.org/r/14338/
Acked-by: Tigran
Require-book: no
Require-notes: yes
Signed-off-by: Dmitry Litvintsev <[email protected]>
(cherry picked from commit e98ab94)
  • Loading branch information
DmitryLitvintsev authored and lemora committed Oct 29, 2024
1 parent 2aa172f commit 93c5074
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

package org.dcache.xrootd.door;

import static org.dcache.xrootd.plugins.tls.SSLHandlerFactory.SERVER_TLS;
Expand Down Expand Up @@ -286,7 +287,8 @@ protected void initChannel(Channel ch) throws Exception {
}

XrootdRedirectHandler handler = new XrootdRedirectHandler(_door, _rootPath,
_requestExecutor, _queryConfig, _appIoQueues);
_requestExecutor, _queryConfig,
_appIoQueues, _expectProxyProtocol);
handler.setSigningPolicy(_signingPolicy);
handler.setTlsSessionInfo(tlsSessionInfo);
pipeline.addLast("redirector", handler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ private Restriction computeRestriction(LoginReply reply) {
private final Deque<LoginSessionInfo> _logins;
private final FsPath _rootPath;
private final AtomicInteger openRetry = new AtomicInteger(0);
private boolean _expectProxy;

/**
* Custom entries for kXR_Qconfig requests.
Expand All @@ -247,16 +248,21 @@ private Restriction computeRestriction(LoginReply reply) {
*/
private volatile Thread onOpenThread;

public XrootdRedirectHandler(XrootdDoor door, FsPath rootPath, ExecutorService executor,
Map<String, String> queryConfig,
Map<String, String> appIoQueues) {
public XrootdRedirectHandler(XrootdDoor door,
FsPath rootPath,
ExecutorService executor,
Map<String, String> queryConfig,
Map<String, String> appIoQueues,
boolean expectProxy
) {
super(executor);
_door = door;
_rootPath = rootPath;
_queryConfig = queryConfig;
_appIoQueues = appIoQueues;
_defaultLoginSessionInfo = new LoginSessionInfo(Restrictions.denyAll());
_logins = new ArrayDeque<>(2);
_expectProxy = expectProxy;
}

@Override
Expand Down Expand Up @@ -516,7 +522,8 @@ private InetSocketAddress localAddress() {
* Use the advertised endpoint, if possble, otherwise fall back to the
* address to which the client connected.
*/
return _door.publicEndpoint().orElse(getDestinationAddress());
return _expectProxy ? getDestinationAddress() :
_door.publicEndpoint().orElse(getDestinationAddress());
}

/**
Expand Down

0 comments on commit 93c5074

Please sign in to comment.