Skip to content

Commit

Permalink
fixes for antlir2
Browse files Browse the repository at this point in the history
Summary:

antlir2 builds never have a booted systemd as pid1, so any dbus interactions will fail

This diff no-ops:
- `daemon-reload`
- `daemon-reexec`

and branches with `--root=/` for:
- `set-default`

Differential Revision: D48618221

fbshipit-source-id: 4cecc50040bcbae7325063bdca7e1c9fffd07868
  • Loading branch information
vmagro authored and facebook-github-bot committed Aug 31, 2023
1 parent 4e01666 commit 6baf374
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions cookbooks/fb_systemd/metadata.rb
Expand Up @@ -13,3 +13,4 @@
supports 'arch'
depends 'fb_helpers'
depends 'fb_nsswitch'
depends 'fb_util'
8 changes: 6 additions & 2 deletions cookbooks/fb_systemd/recipes/default.rb
Expand Up @@ -159,15 +159,19 @@

execute 'set default target' do
only_if do
current = shell_out('systemctl get-default').stdout.strip
if node.antlir2_build?
current = shell_out('systemctl --root=/ get-default').stdout.strip
else
current = shell_out('systemctl get-default').stdout.strip
end
is_ignored = node['fb_systemd']['ignore_targets'].include?(current)
is_supported = FB::Version.new(node['packages']['systemd'][
'version']) >= FB::Version.new('205')
is_supported && !is_ignored &&
current != node['fb_systemd']['default_target']
end
command lazy {
"systemctl set-default #{node['fb_systemd']['default_target']}"
"systemctl set-default #{node['fb_systemd']['default_target']} #{node.antlir2_build? ? '--root=/' : ''}"
}
end

Expand Down
4 changes: 4 additions & 0 deletions cookbooks/fb_systemd/resources/reload.rb
Expand Up @@ -34,6 +34,10 @@ def daemon_reload_or_reexec(action)
)
return
end
# Image builds don't have a running systemd, that would make no sense
if node.antlir2_build?
return
end
case new_resource.instance
when 'system'
execute "#{action} systemd system instance" do
Expand Down

0 comments on commit 6baf374

Please sign in to comment.