Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker run: prevent concurrent unpacking of nar files #756

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,18 @@ public synchronized void scan() throws Exception {

public void handleNarFile(Path narFile) throws Exception {
String filename = narFile.getFileName().toString();
if (packages.containsKey(filename)) {
log.error(
"NarFileHandler ID: {} The package {} has already been processed",
System.identityHashCode(this),
filename);
log.error(
"NarFileHandler ID: {} Current packages: {}",
System.identityHashCode(this),
packages.keySet());
throw new IllegalStateException(
"The package " + filename + " has already been processed");
}

// first of all we look for an index file
try (ZipFile zipFile = new ZipFile(narFile.toFile())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,19 @@ public void run(
log.info("Code directory {}", codeDirectory);
log.info("Base persistent state directory {}", basePersistentStateDirectory);

boolean sharingNarFileHandler = sharedNarFileHandler != null;
List<URL> customLibClasspath = buildCustomLibClasspath(codeDirectory);
NarFileHandler narFileHandler =
sharedNarFileHandler != null
sharingNarFileHandler
? sharedNarFileHandler
: new NarFileHandler(
agentsDirectory,
customLibClasspath,
Thread.currentThread().getContextClassLoader());
try {
narFileHandler.scan();
if (!sharingNarFileHandler) {
nicoloboschi marked this conversation as resolved.
Show resolved Hide resolved
narFileHandler.scan();
}

TopicConnectionsRuntimeRegistry topicConnectionsRuntimeRegistry =
new TopicConnectionsRuntimeRegistry();
Expand Down Expand Up @@ -208,7 +211,7 @@ public void run(
topicConnectionsRuntimeWithClassloader.close();
}
} finally {
if (sharedNarFileHandler == null) {
if (!sharingNarFileHandler) {
narFileHandler.close();
}
}
Expand Down
Loading