Skip to content

Commit

Permalink
Fix load command trigger cache block fail in container env
Browse files Browse the repository at this point in the history
### What changes are proposed in this pull request?

```Console
$ /opt/alluxio/bin/alluxio fs load /ceph/mbl/testa12.txt
Failed to complete cache request for block 150994944 of file
/ceph/mbl/testa12.txt: io.grpc.StatusRuntimeException: UNKNOWN:
java.io.IOException: Failed to connect to remote block worker:
GrpcServerAddress{HostName=XXX,
SocketAddress=XXX/YYY:29999}/ceph/mbl/testa12.txt loaded
```

### Why are the changes needed?

It is a bug.

### Does this PR introduce any user facing changes?

No

pr-link: #14272
change-id: cid-5b719989ad7af10c019fdc0d0037a11ac2dbe028
  • Loading branch information
maobaolong committed Oct 19, 2021
1 parent d7c252d commit a25f0a1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions shell/src/main/java/alluxio/cli/fs/command/LoadCommand.java
Expand Up @@ -168,15 +168,21 @@ private void cacheBlock(long blockId, WorkerNetAddress dataSource, boolean local
URIStatus status, Protocol.OpenUfsBlockOptions options) {
BlockInfo info = status.getBlockInfo(blockId);
long blockLength = info.getLength();
String host = dataSource.getHost();
// issues#11172: If the worker is in a container, use the container hostname
// to establish the connection.
if (!dataSource.getContainerHost().equals("")) {
host = dataSource.getContainerHost();
}
CacheRequest request = CacheRequest.newBuilder().setBlockId(blockId).setLength(blockLength)
.setOpenUfsBlockOptions(options).setSourceHost(dataSource.getHost())
.setOpenUfsBlockOptions(options).setSourceHost(host)
.setSourcePort(dataSource.getDataPort()).build();
try (CloseableResource<BlockWorkerClient> blockWorker =
mFsContext.acquireBlockWorkerClient(dataSource)) {
blockWorker.get().cache(request);
} catch (Exception e) {
System.out.printf("Failed to complete cache request for block %d of file %s: %s", blockId,
status.getPath(), e.toString());
status.getPath(), e);
}
}
}

0 comments on commit a25f0a1

Please sign in to comment.