Skip to content

Commit 087cd3e

Browse files
authored
Merge pull request #6823 from garlick/local_ipc
use local ipc for TBON when brokers are co-located
2 parents 37e6006 + 80271d7 commit 087cd3e

File tree

13 files changed

+887
-261
lines changed

13 files changed

+887
-261
lines changed

doc/man1/flux-start.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ OPTIONS
207207
Set the pmi clique mode, which determines how ``PMI_process_mapping`` is set
208208
in the PMI server used to bootstrap the brokers. If ``none``, the mapping
209209
is not created. If ``single``, all brokers are placed in one clique. If
210-
``per-broker``, each broker is placed in its own clique.
211-
Default: ``single``.
210+
``per-broker``, each broker is placed in its own clique. Otherwise the
211+
option argument is interpreted as an RFC 34 taskmap. Default: ``single``.
212212

213213
.. option:: -r, --recovery=[TARGET]
214214

src/broker/Makefile.am

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ libbroker_la_SOURCES = \
3636
modservice.h \
3737
overlay.h \
3838
overlay.c \
39+
bizcard.h \
40+
bizcard.c \
3941
service.h \
4042
service.c \
4143
attr.h \
@@ -89,7 +91,8 @@ TESTS = test_attr.t \
8991
test_boot_config.t \
9092
test_runat.t \
9193
test_overlay.t \
92-
test_topology.t
94+
test_topology.t \
95+
test_bizcard.t
9396

9497
test_ldadd = \
9598
$(builddir)/libbroker.la \
@@ -147,4 +150,9 @@ test_topology_t_CPPFLAGS = $(test_cppflags)
147150
test_topology_t_LDADD = $(test_ldadd)
148151
test_topology_t_LDFLAGS = $(test_ldflags)
149152

153+
test_bizcard_t_SOURCES = test/bizcard.c
154+
test_bizcard_t_CPPFLAGS = $(test_cppflags)
155+
test_bizcard_t_LDADD = $(test_ldadd)
156+
test_bizcard_t_LDFLAGS = $(test_ldflags)
157+
150158
EXTRA_DIST = README.md

src/broker/bizcard.c

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
/************************************************************\
2+
* Copyright 2025 Lawrence Livermore National Security, LLC
3+
* (c.f. AUTHORS, NOTICE.LLNS, COPYING)
4+
*
5+
* This file is part of the Flux resource manager framework.
6+
* For details, see https://github.com/flux-framework.
7+
*
8+
* SPDX-License-Identifier: LGPL-3.0
9+
\************************************************************/
10+
11+
#if HAVE_CONFIG_H
12+
#include "config.h"
13+
#endif
14+
#include <stdlib.h>
15+
#include <jansson.h>
16+
#include <flux/core.h>
17+
18+
#include "src/common/libutil/errprintf.h"
19+
#include "src/common/libutil/errno_safe.h"
20+
#include "ccan/str/str.h"
21+
22+
#include "bizcard.h"
23+
24+
struct bizcard {
25+
json_t *obj;
26+
char *encoded;
27+
size_t cursor;
28+
int refcount;
29+
};
30+
31+
void bizcard_decref (struct bizcard *bc)
32+
{
33+
if (bc && --bc->refcount == 0) {
34+
int saved_errno = errno;
35+
json_decref (bc->obj);
36+
free (bc->encoded);
37+
free (bc);
38+
errno = saved_errno;
39+
}
40+
}
41+
42+
struct bizcard *bizcard_incref (struct bizcard *bc)
43+
{
44+
if (bc)
45+
bc->refcount++;
46+
return bc;
47+
}
48+
49+
struct bizcard *bizcard_create (const char *hostname, const char *pubkey)
50+
{
51+
struct bizcard *bc;
52+
53+
if (!hostname || !pubkey) {
54+
errno = EINVAL;
55+
return NULL;
56+
}
57+
if (!(bc = calloc (1, sizeof (*bc))))
58+
return NULL;
59+
bc->refcount = 1;
60+
if (!(bc->obj = json_pack ("{s:s s:s s:[]}",
61+
"host", hostname,
62+
"pubkey", pubkey,
63+
"uri"))) {
64+
errno = ENOMEM;
65+
bizcard_decref (bc);
66+
return NULL;
67+
}
68+
return bc;
69+
}
70+
71+
const char *bizcard_encode (const struct bizcard *bc_const)
72+
{
73+
struct bizcard *bc = (struct bizcard *)bc_const;
74+
if (!bc) {
75+
errno = EINVAL;
76+
return NULL;
77+
}
78+
char *s;
79+
if (!(s = json_dumps (bc->obj, JSON_COMPACT))) {
80+
errno = ENOMEM;
81+
return NULL;
82+
}
83+
free (bc->encoded);
84+
bc->encoded = s;
85+
return bc->encoded;
86+
}
87+
88+
struct bizcard *bizcard_decode (const char *s, flux_error_t *error)
89+
{
90+
struct bizcard *bc;
91+
json_error_t jerror;
92+
93+
if (!(bc = calloc (1, sizeof (*bc))))
94+
return NULL;
95+
bc->refcount = 1;
96+
if (!(bc->obj = json_loads (s, 0, &jerror))) {
97+
errprintf (error, "%s", jerror.text);
98+
errno = EINVAL;
99+
goto error;
100+
}
101+
if (json_unpack_ex (bc->obj,
102+
&jerror,
103+
JSON_VALIDATE_ONLY,
104+
"{s:s s:s s:o}",
105+
"host",
106+
"pubkey",
107+
"uri") < 0) {
108+
errprintf (error, "%s", jerror.text);
109+
errno = EINVAL;
110+
goto error;
111+
}
112+
return bc;
113+
error:
114+
bizcard_decref (bc);
115+
return NULL;
116+
}
117+
118+
int bizcard_uri_append (struct bizcard *bc, const char *uri)
119+
{
120+
json_t *a;
121+
json_t *o;
122+
123+
if (!bc
124+
|| !uri
125+
|| !strstr (uri, "://")
126+
|| !(a = json_object_get (bc->obj, "uri"))) {
127+
errno = EINVAL;
128+
return -1;
129+
}
130+
if (!(o = json_string (uri)) || json_array_append_new (a, o) < 0) {
131+
json_decref (o);
132+
errno = ENOMEM;
133+
return -1;
134+
}
135+
return 0;
136+
}
137+
138+
const char *bizcard_uri_next (const struct bizcard *bc_const)
139+
{
140+
struct bizcard *bc = (struct bizcard *)bc_const;
141+
json_t *a;
142+
json_t *o;
143+
const char *s;
144+
145+
if (!bc
146+
|| !(a = json_object_get (bc->obj, "uri"))
147+
|| !(o = json_array_get (a, bc->cursor))
148+
|| !(s = json_string_value (o)))
149+
return NULL;
150+
bc->cursor++;
151+
return s;
152+
}
153+
154+
const char *bizcard_uri_first (const struct bizcard *bc_const)
155+
{
156+
struct bizcard *bc = (struct bizcard *)bc_const;
157+
if (bc)
158+
bc->cursor = 0;
159+
return bizcard_uri_next (bc);
160+
}
161+
162+
const char *bizcard_uri_find (const struct bizcard *bc, const char *scheme)
163+
{
164+
const char *uri;
165+
166+
uri = bizcard_uri_first (bc);
167+
while (uri) {
168+
if (!scheme || strstarts (uri, scheme))
169+
return uri;
170+
uri = bizcard_uri_next (bc);
171+
}
172+
return NULL;
173+
}
174+
175+
const char *bizcard_pubkey (const struct bizcard *bc)
176+
{
177+
const char *s;
178+
if (!bc || json_unpack (bc->obj, "{s:s}", "pubkey", &s) < 0)
179+
return NULL;
180+
return s;
181+
}
182+
183+
const char *bizcard_hostname (const struct bizcard *bc)
184+
{
185+
const char *s;
186+
if (!bc || json_unpack (bc->obj, "{s:s}", "host", &s) < 0)
187+
return NULL;
188+
return s;
189+
}
190+
191+
// vi:ts=4 sw=4 expandtab

src/broker/bizcard.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/************************************************************\
2+
* Copyright 2025 Lawrence Livermore National Security, LLC
3+
* (c.f. AUTHORS, NOTICE.LLNS, COPYING)
4+
*
5+
* This file is part of the Flux resource manager framework.
6+
* For details, see https://github.com/flux-framework.
7+
*
8+
* SPDX-License-Identifier: LGPL-3.0
9+
\************************************************************/
10+
11+
#ifndef BROKER_BIZCARD_H
12+
#define BROKER_BIZCARD_H
13+
14+
#include <flux/core.h>
15+
16+
struct bizcard *bizcard_create (const char *hostname, const char *pubkey);
17+
struct bizcard *bizcard_incref (struct bizcard *bc);
18+
void bizcard_decref (struct bizcard *bc);
19+
20+
const char *bizcard_encode (const struct bizcard *bc);
21+
struct bizcard *bizcard_decode (const char *s, flux_error_t *error);
22+
23+
int bizcard_uri_append (struct bizcard *bc, const char *uri);
24+
const char *bizcard_uri_first (const struct bizcard *bc);
25+
const char *bizcard_uri_next (const struct bizcard *bc);
26+
const char *bizcard_uri_find (const struct bizcard *bc, const char *scheme);
27+
28+
const char *bizcard_pubkey (const struct bizcard *bc);
29+
const char *bizcard_hostname (const struct bizcard *bc);
30+
31+
#endif /* BROKER_BIZCARD_H */
32+
33+
// vi:ts=4 sw=4 expandtab

src/broker/boot_config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ int boot_config (flux_t *h,
614614
bind_uri,
615615
sizeof (bind_uri)) < 0)
616616
goto error;
617-
if (overlay_bind (overlay, bind_uri) < 0)
617+
if (overlay_bind (overlay, bind_uri, NULL) < 0)
618618
goto error;
619619
if (overlay_authorize (overlay,
620620
overlay_cert_name (overlay),

0 commit comments

Comments
 (0)