提交 2bc5c5b7 编写于 作者: B Boyang Jerry Peng 提交者: Matteo Merli

For integration tests, copy function logs out of container on shutdown for...

For integration tests, copy function logs out of container on shutdown for debugging purposes (#3529)
上级 3b1dd8cf
......@@ -18,6 +18,8 @@
*/
package org.apache.pulsar.tests.integration.containers;
import org.apache.pulsar.tests.integration.utils.DockerUtils;
/**
* A pulsar container that runs functions worker.
*/
......@@ -35,4 +37,16 @@ public class WorkerContainer extends PulsarContainer<WorkerContainer> {
BROKER_HTTP_PORT,
"/admin/v2/worker/cluster");
}
@Override
protected void beforeStop() {
super.beforeStop();
if (null != containerId) {
DockerUtils.dumpContainerDirToTargetCompressed(
getDockerClient(),
containerId,
"/pulsar/logs/functions"
);
}
}
}
......@@ -24,6 +24,7 @@ import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.async.ResultCallback;
import com.github.dockerjava.api.command.InspectContainerResponse;
import com.github.dockerjava.api.command.InspectExecResponse;
import com.github.dockerjava.api.exception.NotFoundException;
import com.github.dockerjava.api.model.ContainerNetwork;
import com.github.dockerjava.api.model.Frame;
import com.github.dockerjava.api.model.StreamType;
......@@ -140,7 +141,9 @@ public class DockerUtils {
read = dockerStream.read(block, 0, READ_BLOCK_SIZE);
}
} catch (RuntimeException|IOException e) {
LOG.error("Error reading dir from container {}", containerName, e);
if (!(e instanceof NotFoundException)) {
LOG.error("Error reading dir from container {}", containerName, e);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册