Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/generate.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ int main(int argc, char** argv)
g_fprintf(stderr, "%s can not be called directly, use 'netplan generate'.", argv[0]);
return 1;
}
generator_run_stamp = g_build_path(G_DIR_SEPARATOR_S, files[0], "netplan.stamp", NULL);
/* Write generator.stamp in /run/netplan/generator.stamp, this is due to
* /run/systemd/generator/... being cleaned on every daemon-reload. */
generator_run_stamp = g_build_path(G_DIR_SEPARATOR_S, rootdir, "run", "netplan", "generator.stamp", NULL);
if (g_access(generator_run_stamp, F_OK) == 0) {
g_fprintf(stderr, "netplan generate already ran, remove %s to force re-run\n", generator_run_stamp);
return 0;
Expand Down Expand Up @@ -318,6 +320,7 @@ int main(int argc, char** argv)

/* Leave a stamp file so that we don't regenerate the configuration
* multiple times and userspace can wait for it to finish */
_netplan_safe_mkdir_p_dir(generator_run_stamp);
FILE* f = fopen(generator_run_stamp, "w");
g_assert(f != NULL);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attention: This failed in Debian trixie.

| # /usr/lib/systemd/system-generators/netplan . . .
| **
| ERROR:../src/generate.c:325:main: assertion failed: (f != NULL)
| Bail out! ERROR:../src/generate.c:325:main: assertion failed: (f != NULL)
| Aborted

fclose(f);
Expand Down
8 changes: 5 additions & 3 deletions tests/generator/test_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ def test_systemd_generator(self):

# after removing the stamp it generates again, and not trip over the
# existing enablement symlink
os.unlink(os.path.join(outdir, 'netplan.stamp'))
run_netplan = os.path.join(self.workdir.name, 'run', 'netplan')
os.unlink(os.path.join(run_netplan, 'generator.stamp'))
subprocess.check_output([generator, '--root-dir', self.workdir.name, outdir, outdir, outdir])
self.assertTrue(os.path.exists(n))

Expand Down Expand Up @@ -340,7 +341,7 @@ def test_systemd_generator_noconf(self):

subprocess.check_call([generator, '--root-dir', self.workdir.name, outdir, outdir, outdir])
# no enablement symlink here
self.assertEqual(os.listdir(outdir), ['netplan.stamp'])
self.assertEqual(os.listdir(outdir), [])

def test_systemd_generator_badcall(self):
outdir = os.path.join(self.workdir.name, 'out')
Expand Down Expand Up @@ -409,6 +410,7 @@ def test_systemd_generator_escaping(self):

# after removing the stamp it generates again, and not trip over the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh the test above was passing because we don't call it through a daemon-reload

# existing enablement symlink
os.unlink(os.path.join(outdir, 'netplan.stamp'))
run_netplan = os.path.join(self.workdir.name, 'run', 'netplan')
os.unlink(os.path.join(run_netplan, 'generator.stamp'))
subprocess.check_output([generator, '--root-dir', self.workdir.name, outdir, outdir, outdir])
self.assertTrue(os.path.exists(n))
2 changes: 1 addition & 1 deletion tests/integration/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def tearDown(self):
subprocess.call(['udevadm', 'trigger', '--attr-match=subsystem=net'])
subprocess.call(['udevadm', 'settle'])
try:
os.remove('/run/systemd/generator/netplan.stamp')
os.remove('/run/netplan/generator.stamp')
except FileNotFoundError:
pass
# Keep the management network (eth0/ens3 from 20-wired.network) up
Expand Down
Loading