openvidu-server: rollback autoremove property on runContainer

pull/780/head
pabloFuente 2023-02-16 17:05:15 +01:00
parent bd23cfcd71
commit 5a1bc4f7c3
5 changed files with 11 additions and 11 deletions

View File

@ -228,7 +228,7 @@ public class ComposedQuickStartRecordingService extends ComposedRecordingService
List<Bind> binds = new ArrayList<>(); List<Bind> binds = new ArrayList<>();
binds.add(bind1); binds.add(bind1);
containerId = dockerManager.runContainer(properties.mediaNode(), container, containerName, null, volumes, containerId = dockerManager.runContainer(properties.mediaNode(), container, containerName, null, volumes,
binds, "host", envs, null, properties.shmSize(), false, null, true, binds, "host", envs, null, properties.shmSize(), false, null,
openviduConfig.isOpenviduRecordingGPUEnabled()); openviduConfig.isOpenviduRecordingGPUEnabled());
this.sessionsContainers.put(session.getSessionId(), containerId); this.sessionsContainers.put(session.getSessionId(), containerId);
} catch (Exception e) { } catch (Exception e) {

View File

@ -164,7 +164,7 @@ public class ComposedRecordingService extends RecordingService {
List<Bind> binds = new ArrayList<>(); List<Bind> binds = new ArrayList<>();
binds.add(bind1); binds.add(bind1);
containerId = dockerManager.runContainer(properties.mediaNode(), container, containerName, null, volumes, containerId = dockerManager.runContainer(properties.mediaNode(), container, containerName, null, volumes,
binds, "host", envs, null, properties.shmSize(), false, null, true, binds, "host", envs, null, properties.shmSize(), false, null,
openviduConfig.isOpenviduRecordingGPUEnabled()); openviduConfig.isOpenviduRecordingGPUEnabled());
} catch (Exception e) { } catch (Exception e) {
this.cleanRecordingMaps(recording); this.cleanRecordingMaps(recording);

View File

@ -22,6 +22,7 @@ import java.io.IOException;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import com.github.dockerjava.api.async.ResultCallback; import com.github.dockerjava.api.async.ResultCallback;
import com.github.dockerjava.api.exception.NotFoundException;
import com.github.dockerjava.api.model.WaitResponse; import com.github.dockerjava.api.model.WaitResponse;
public class WaitForContainerStoppedCallback implements ResultCallback<WaitResponse> { public class WaitForContainerStoppedCallback implements ResultCallback<WaitResponse> {
@ -34,7 +35,6 @@ public class WaitForContainerStoppedCallback implements ResultCallback<WaitRespo
@Override @Override
public void close() throws IOException { public void close() throws IOException {
// TODO Auto-generated method stub
} }
@Override @Override
@ -44,17 +44,19 @@ public class WaitForContainerStoppedCallback implements ResultCallback<WaitRespo
@Override @Override
public void onError(Throwable arg0) { public void onError(Throwable arg0) {
// TODO Auto-generated method stub if (arg0 instanceof NotFoundException) {
// The container cannot be found
System.err.println("Waiting for container stopped but it did not exist: " + arg0.getMessage());
latch.countDown();
}
} }
@Override @Override
public void onStart(Closeable arg0) { public void onStart(Closeable arg0) {
// TODO Auto-generated method stub
} }
@Override @Override
public void onNext(WaitResponse arg0) { public void onNext(WaitResponse arg0) {
// TODO Auto-generated method stub
} }
} }

View File

@ -13,7 +13,7 @@ public interface DockerManager {
public String runContainer(String mediaNodeId, String image, String containerName, String user, public String runContainer(String mediaNodeId, String image, String containerName, String user,
List<Volume> volumes, List<Bind> binds, String networkMode, List<String> envs, List<String> command, List<Volume> volumes, List<Bind> binds, String networkMode, List<String> envs, List<String> command,
Long shmSize, boolean privileged, Map<String, String> labels, boolean autoremove, boolean enableGPU) Long shmSize, boolean privileged, Map<String, String> labels, boolean enableGPU)
throws Exception; throws Exception;
public void removeContainer(String mediaNodeId, String containerId, boolean force); public void removeContainer(String mediaNodeId, String containerId, boolean force);

View File

@ -127,8 +127,7 @@ public class LocalDockerManager implements DockerManager {
@Override @Override
public String runContainer(String mediaNodeId, String image, String containerName, String user, public String runContainer(String mediaNodeId, String image, String containerName, String user,
List<Volume> volumes, List<Bind> binds, String networkMode, List<String> envs, List<String> command, List<Volume> volumes, List<Bind> binds, String networkMode, List<String> envs, List<String> command,
Long shmSize, boolean privileged, Map<String, String> labels, boolean autoremove, boolean enableGPU) Long shmSize, boolean privileged, Map<String, String> labels, boolean enableGPU) throws Exception {
throws Exception {
CreateContainerCmd cmd = dockerClient.createContainerCmd(image).withEnv(envs); CreateContainerCmd cmd = dockerClient.createContainerCmd(image).withEnv(envs);
if (containerName != null) { if (containerName != null) {
@ -139,8 +138,7 @@ public class LocalDockerManager implements DockerManager {
cmd.withUser(user); cmd.withUser(user);
} }
HostConfig hostConfig = new HostConfig().withNetworkMode(networkMode).withPrivileged(privileged) HostConfig hostConfig = new HostConfig().withNetworkMode(networkMode).withPrivileged(privileged);
.withAutoRemove(autoremove);
if (shmSize != null) { if (shmSize != null) {
hostConfig.withShmSize(shmSize); hostConfig.withShmSize(shmSize);
} }