From 43ba8b30eccd5adec31de32677083b763f0a52d4 Mon Sep 17 00:00:00 2001 From: Colin Thomas <33940547+colinthomas-z80@users.noreply.github.com> Date: Tue, 5 Nov 2024 14:05:52 -0500 Subject: [PATCH] vine: handling temp files when peer transfers disabled (#3964) * add temp warning when disabling peer transfers * without peer transfers, create normal file instead of temps * unique name for local temps * unlink local temp when done * correct uuid generation for temp names --- taskvine/src/manager/vine_file.c | 13 +++++++++++++ taskvine/src/manager/vine_file.h | 1 + taskvine/src/manager/vine_manager.c | 10 ++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/taskvine/src/manager/vine_file.c b/taskvine/src/manager/vine_file.c index d2c236f930..c11be4355b 100644 --- a/taskvine/src/manager/vine_file.c +++ b/taskvine/src/manager/vine_file.c @@ -15,6 +15,7 @@ See the file COPYING for details. #include "stringtools.h" #include "timestamp.h" #include "unlink_recursive.h" +#include "uuid.h" #include "xxmalloc.h" #include @@ -245,6 +246,18 @@ struct vine_file *vine_file_temp() return vine_file_create("temp", 0, 0, 0, VINE_TEMP, 0, cache, 0); } +struct vine_file *vine_file_temp_no_peers() +{ + // temp files are always cached at workers until explicitely removed. + vine_cache_level_t cache = VINE_CACHE_LEVEL_WORKFLOW; + cctools_uuid_t uuid; + cctools_uuid_create(&uuid); + + char *name = string_format("temp-local-%s", uuid.str); + return vine_file_create(name, 0, 0, 0, VINE_FILE, 0, cache, VINE_UNLINK_WHEN_DONE); + free(name); +} + struct vine_file *vine_file_buffer(const char *data, size_t size, vine_cache_level_t cache, vine_file_flags_t flags) { return vine_file_create("buffer", 0, data, size, VINE_BUFFER, 0, cache, flags); diff --git a/taskvine/src/manager/vine_file.h b/taskvine/src/manager/vine_file.h index 10bb785776..a358a0b6e4 100644 --- a/taskvine/src/manager/vine_file.h +++ b/taskvine/src/manager/vine_file.h @@ -62,6 +62,7 @@ char * vine_file_make_file_url( const char * source); struct vine_file *vine_file_local( const char *source, vine_cache_level_t cache, vine_file_flags_t flags ); struct vine_file *vine_file_url( const char *source, vine_cache_level_t cache, vine_file_flags_t flags ); struct vine_file *vine_file_temp(); +struct vine_file *vine_file_temp_no_peers(); struct vine_file *vine_file_buffer( const char *buffer, size_t size, vine_cache_level_t cache, vine_file_flags_t flags ); struct vine_file *vine_file_mini_task( struct vine_task *t, const char *name, vine_cache_level_t cache, vine_file_flags_t flags ); struct vine_file *vine_file_untar( struct vine_file *f, vine_cache_level_t cache, vine_file_flags_t flags ); diff --git a/taskvine/src/manager/vine_manager.c b/taskvine/src/manager/vine_manager.c index 11cc0d8f59..f04c2b84bd 100644 --- a/taskvine/src/manager/vine_manager.c +++ b/taskvine/src/manager/vine_manager.c @@ -3993,6 +3993,7 @@ int vine_enable_peer_transfers(struct vine_manager *q) int vine_disable_peer_transfers(struct vine_manager *q) { debug(D_VINE, "Peer Transfers disabled"); + fprintf(stderr, "warning: Peer Transfers disabled. Temporary files will be returned to the manager upon creation."); q->peer_transfers_enabled = 0; return 1; } @@ -6177,8 +6178,13 @@ struct vine_file *vine_declare_url(struct vine_manager *m, const char *source, v struct vine_file *vine_declare_temp(struct vine_manager *m) { - struct vine_file *f = vine_file_temp(); - return vine_manager_declare_file(m, f); + if (m->peer_transfers_enabled) { + struct vine_file *f = vine_file_temp(); + return vine_manager_declare_file(m, f); + } else { + struct vine_file *f = vine_file_temp_no_peers(); + return vine_manager_declare_file(m, f); + } } struct vine_file *vine_declare_buffer(struct vine_manager *m, const char *buffer, size_t size, vine_cache_level_t cache, vine_file_flags_t flags)