Skip to content

Commit d686126

Browse files
committed
configure: drop JIT logic, which is not needed anymore with the sd-generator
This was originally implemented to generate & start systemd units just-in-time during the boot transaction (#162). With the implementation of a proper systemd-generator, Netplan generates the corresponding units in /run/system/generator* and automatically re-loads and re-calculates dependencies during "daemon-reload". Therefore, we do not need to inject them manually. This is covered by the "cloud-init" autopkgtest.
1 parent ccf28a1 commit d686126

File tree

1 file changed

+1
-72
lines changed

1 file changed

+1
-72
lines changed

src/configure.c

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -54,38 +54,6 @@ static GOptionEntry options[] = {
5454
{NULL}
5555
};
5656

57-
// LCOV_EXCL_START
58-
/* covered via 'cloud-init' integration test */
59-
static gboolean
60-
check_called_just_in_time()
61-
{
62-
const gchar *argv[] = { "/bin/systemctl", "is-system-running", NULL };
63-
gchar *output = NULL;
64-
g_spawn_sync(NULL, (gchar**)argv, NULL, G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, &output, NULL, NULL, NULL);
65-
if (output != NULL && strstr(output, "initializing") != NULL) {
66-
g_free(output);
67-
const gchar *argv2[] = { "/bin/systemctl", "is-active", "network.target", NULL };
68-
gint exit_code = 0;
69-
g_spawn_sync(NULL, (gchar**)argv2, NULL, G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, NULL, NULL, &exit_code, NULL);
70-
/* return TRUE, if network.target is not yet active */
71-
#if GLIB_CHECK_VERSION (2, 70, 0)
72-
return !g_spawn_check_wait_status(exit_code, NULL);
73-
#else
74-
return !g_spawn_check_exit_status(exit_code, NULL);
75-
#endif
76-
}
77-
g_free(output);
78-
return FALSE;
79-
};
80-
81-
static void
82-
start_unit_jit(gchar *unit)
83-
{
84-
const gchar *argv[] = { "/bin/systemctl", "start", "--no-block", "--no-ask-password", unit, NULL };
85-
g_spawn_sync(NULL, (gchar**)argv, NULL, G_SPAWN_DEFAULT, NULL, NULL, NULL, NULL, NULL, NULL);
86-
};
87-
// LCOV_EXCL_STOP
88-
8957
#define CHECK_CALL(call, ignore_errors) {\
9058
if (!call && !ignore_errors) {\
9159
error_code = 1; \
@@ -103,7 +71,6 @@ int main(int argc, char** argv)
10371
GOptionContext* opt_context;
10472
g_autofree char* generator_run_stamp = NULL;
10573
g_autofree char* netplan_try_stamp = NULL;
106-
glob_t gl;
10774
int error_code = 0;
10875
char* ignore_errors_env = NULL;
10976
NetplanParser* npp = NULL;
@@ -230,45 +197,7 @@ int main(int argc, char** argv)
230197

231198
if (nm_only) goto cleanup;
232199

233-
gboolean enable_wait_online = FALSE;
234-
if (any_networkd) {
235-
// _netplan_networkd_write_wait_online() is currently a no-op in the ./configure binary
236-
// _netplan_networkd_generate_wait_online() is for sd-generator late-stage validation, but not writing any files
237-
enable_wait_online = _netplan_networkd_generate_wait_online(np_state, NULL, _VALIDATION_ONLY);
238-
}
239-
240-
if (check_called_just_in_time()) {
241-
/* netplan-feature: generate-just-in-time */
242-
/* When booting with cloud-init, network configuration
243-
* might be provided just-in-time. Specifically after
244-
* system-generators were executed, but before
245-
* network.target is started. In such case, auxiliary
246-
* units that netplan enables have not been included in
247-
* the initial boot transaction. Detect such scenario and
248-
* add all netplan units to the initial boot transaction.
249-
*/
250-
// LCOV_EXCL_START
251-
/* covered via 'cloud-init' integration test */
252-
start_unit_jit("netplan-configure.service");
253-
if (any_networkd) {
254-
start_unit_jit("systemd-networkd.socket");
255-
if (enable_wait_online)
256-
start_unit_jit("systemd-networkd-wait-online.service");
257-
start_unit_jit("systemd-networkd.service");
258-
}
259-
g_autofree char* glob_run = g_build_path(G_DIR_SEPARATOR_S,
260-
rootdir != NULL ? rootdir : G_DIR_SEPARATOR_S,
261-
"run", "systemd", "generator.late", "netplan-*.service",
262-
NULL);
263-
if (!glob(glob_run, 0, NULL, &gl)) {
264-
for (size_t i = 0; i < gl.gl_pathc; ++i) {
265-
gchar *unit_name = g_path_get_basename(gl.gl_pathv[i]);
266-
start_unit_jit(unit_name);
267-
g_free(unit_name);
268-
}
269-
}
270-
// LCOV_EXCL_STOP
271-
}
200+
// Only logic that is not relevant for NetworkManager config below this point
272201

273202
cleanup:
274203
g_option_context_free(opt_context);

0 commit comments

Comments
 (0)