Skip to content

Commit a1c02ff

Browse files
authored
Merge pull request #5297 from garlick/f58plain
add f58plain job encoding
2 parents 0ec34e0 + 1343943 commit a1c02ff

File tree

8 files changed

+42
-11
lines changed

8 files changed

+42
-11
lines changed

src/bindings/python/flux/job/JobID.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ def f58(self):
8080
"""Return RFC19 F58 representation of a JobID"""
8181
return self.encode("f58")
8282

83+
@property
84+
def f58plain(self):
85+
"""Return RFC19 F58 representation of a JobID with ASCII prefix"""
86+
return self.encode("f58plain")
87+
8388
@property
8489
def hex(self):
8590
"""Return 0x-prefixed hexadecimal representation of a JobID"""

src/common/libjob/id.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ int flux_job_id_encode (flux_jobid_t id,
8888
t = FLUID_STRING_MNEMONIC;
8989
else if (strcasecmp (type, "f58") == 0)
9090
t = FLUID_STRING_F58;
91+
else if (strcasecmp (type, "f58plain") == 0)
92+
t = FLUID_STRING_F58_PLAIN;
9193
else if (strcasecmp (type, "emoji") == 0)
9294
t = FLUID_STRING_EMOJI;
9395
else {

src/common/libjob/job.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ int flux_job_id_parse (const char *s, flux_jobid_t *id);
8484
/* Encode a jobid into encoding "type", writing the result to buffer
8585
* buf of size bufsz.
8686
* Supported encoding types include:
87-
* "dec", "hex", "kvs", "dothex", "words", or "f58".
87+
* "dec", "hex", "kvs", "dothex", "words", "f58", or "f58plain"
8888
* Returns 0 on success, -1 on failure with errno set:
8989
* EPROTO: Invalid encoding type
9090
* EINVAL: Invalid other argument

src/common/libutil/fluid.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ static inline int is_utf8_locale (void)
189189
return 0;
190190
}
191191

192-
static int fluid_f58_encode (char *buf, int bufsz, fluid_t id)
192+
static int fluid_f58_encode (char *buf, int bufsz, fluid_t id, bool plain)
193193
{
194194
int count;
195195
const char *prefix = f58_prefix;
@@ -203,7 +203,7 @@ static int fluid_f58_encode (char *buf, int bufsz, fluid_t id)
203203

204204
#if !ASSUME_BROKEN_LOCALE
205205
/* Use alternate "f" prefix if locale is not multibyte */
206-
if (!is_utf8_locale())
206+
if (!is_utf8_locale() || plain)
207207
prefix = f58_alt_prefix;
208208
#endif
209209

@@ -332,7 +332,11 @@ int fluid_encode (char *buf, int bufsz, fluid_t fluid,
332332
return -1;
333333
break;
334334
case FLUID_STRING_F58:
335-
if (fluid_f58_encode (buf, bufsz, fluid) < 0)
335+
if (fluid_f58_encode (buf, bufsz, fluid, false) < 0)
336+
return -1;
337+
break;
338+
case FLUID_STRING_F58_PLAIN:
339+
if (fluid_f58_encode (buf, bufsz, fluid, true) < 0)
336340
return -1;
337341
break;
338342
case FLUID_STRING_EMOJI:

src/common/libutil/fluid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ typedef enum {
2424
FLUID_STRING_MNEMONIC = 2, // mnemonicode x-x-x--x-x-x
2525
FLUID_STRING_F58 = 3, // FLUID base58 enc: ƒXXXX or fXXXX
2626
FLUID_STRING_EMOJI = 4, // FLUID basemoji enc: 😪🏭🐭🍑👨
27+
FLUID_STRING_F58_PLAIN = 5, // FLUID base58 enc: fXXXX
2728
} fluid_string_type_t;
2829

2930
struct fluid_generator {

src/common/libutil/test/fluid.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ void test_f58 (void)
103103
"fluid_encode with FLUX_F58_FORCE_ASCII used ascii prefix");
104104
if (unsetenv ("FLUX_F58_FORCE_ASCII") < 0)
105105
BAIL_OUT ("Failed to unsetenv FLUX_F58_FORCE_ASCII");
106+
107+
ok (fluid_encode (buf,
108+
sizeof (buf),
109+
f58_tests->id,
110+
FLUID_STRING_F58_PLAIN) == 0,
111+
"fluid_encode FLUX_STRING_F58_PLAIN works");
112+
is (buf, f58_tests->f58_alt,
113+
"fluid_encode FLUID_STRING_F58_PLAIN used ascii prefix");
106114
#endif
107115

108116
ok (fluid_encode (buf, 1, 1, type) < 0 && errno == EOVERFLOW,

src/modules/job-exec/job-exec.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,14 @@ flux_future_t *jobinfo_shell_rpc_pack (struct jobinfo *job,
171171
char *shell_topic = NULL;
172172
flux_future_t *f = NULL;
173173
uint32_t rank;
174-
175-
if (asprintf (&shell_topic,
176-
"%ju-shell-%s.%s",
177-
(uintmax_t) job->userid,
178-
idf58 (job->id),
179-
topic) < 0
174+
char idbuf[21];
175+
176+
if (flux_job_id_encode (job->id, "f58plain", idbuf, sizeof (idbuf)) < 0
177+
|| asprintf (&shell_topic,
178+
"%ju-shell-%s.%s",
179+
(uintmax_t) job->userid,
180+
idbuf,
181+
topic) < 0
180182
|| ((rank = resource_set_nth_rank (job->R, 0)) == IDSET_INVALID_ID))
181183
goto out;
182184
va_start (ap, fmt);

src/shell/svc.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,25 @@ static int lookup_rank (struct shell_svc *svc, int shell_rank, int *rank)
6161
return 0;
6262
}
6363

64+
/* Avoid locale-specific encoding for the shell service name.
65+
* See flux-framework/flux-core#5257.
66+
*/
6467
static int build_topic (struct shell_svc *svc,
6568
const char *method,
6669
char *buf,
6770
int len)
6871
{
72+
char idbuf[21];
73+
if (flux_job_id_encode (svc->shell->info->jobid,
74+
"f58plain",
75+
idbuf,
76+
sizeof (idbuf)) < 0)
77+
return -1;
6978
if (snprintf (buf,
7079
len,
7180
"%ju-shell-%s%s%s",
7281
(uintmax_t)svc->uid,
73-
idf58 (svc->shell->info->jobid),
82+
idbuf,
7483
method ? "." : "",
7584
method ? method : "") >= len) {
7685
errno = EINVAL;

0 commit comments

Comments
 (0)