Only allow one rank per host in ovnisync

This commit is contained in:
Rodrigo Arias 2023-03-21 16:55:59 +01:00 committed by Rodrigo Arias Mallo
parent f22d9084ba
commit 740d8b0d4b

View File

@ -368,6 +368,27 @@ print_drift_row(FILE *out, struct offset_table *table)
static void
print_table_detailed(FILE *out, struct offset_table *table)
{
int fail = 0;
/* Ensure each hostname is unique */
for (int i = 0; i < table->nprocs; i++) {
struct offset *a = table->offset[i];
for (int j = 0; j < i; j++) {
struct offset *b = table->offset[j];
if (strcmp(a->hostname, b->hostname) == 0) {
fprintf(stderr, "FATAL: ranks %d and %d run in same hostname %s\n",
j, i, a->hostname);
fail = 1;
}
}
}
if (fail) {
fprintf(stderr, "Please run %s with one rank per host\n", progname);
exit(EXIT_FAILURE);
}
fprintf(out, "%-10s %-20s %-20s %-20s %-20s\n",
"rank", "hostname", "offset_median", "offset_mean", "offset_std");