Skip to content

Commit

Permalink
vine: handling temp files when peer transfers disabled (#3964)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
colinthomas-z80 authored Nov 5, 2024
1 parent df0d4f2 commit 43ba8b3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
13 changes: 13 additions & 0 deletions taskvine/src/manager/vine_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <errno.h>
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions taskvine/src/manager/vine_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
10 changes: 8 additions & 2 deletions taskvine/src/manager/vine_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 43ba8b3

Please sign in to comment.