Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.7 Relocate Systemd Files #11147

Merged
merged 2 commits into from
Jan 24, 2020
Merged

2.7 Relocate Systemd Files #11147

merged 2 commits into from
Jan 24, 2020

Conversation

manadart
Copy link
Member

@manadart manadart commented Jan 23, 2020

Checklist

  • Checked if it requires a pylibjuju change?
  • Added integration tests for the PR?
  • Added or updated doc.go related to packages changed?
  • Do comments answer the question of why design decisions were made?

Description of change

This patch changes the location of systemd unit files and start-up scripts.

Instead of writing each service definition and it's exec-start script into a service folder in /lib/systemd/system and using dbus (systemd) to link them into /etc/systemd/system, we write them directly to /etc/systemd/system. This means the exec-start script is co-located with its service definition and prefixed with the service name.

This change was required to support Focal Fossa (20.04) which has these two directories on different partitions, causing systemd to fail.

The linking step remains for now, though it effectively does nothing - the service definitions are in the default search path, so reloading the systemd daemon should be sufficient to have them loaded.

Subsequent patches will take care of any required upgrade paths, including upgrading the OS series.

QA steps

  • Bootstrap to Focal: juju bootstrap lxd systemd-test-focal --bootstrap-series focal --debug --no-gui --force --config image-stream=daily.
  • SSH to the controller machine and observe the shutdown, database and machine services and scripts in etc/systemd/system.
  • juju add-machine --series focal
  • juju deploy cs:ubuntu-13 -n 2 --to 0,0 --series focal --force
  • juju ssh 0 and observe the service units/scripts are present in /etc/systemd/system.
  • juju remove-unit ubuntu/1 and observe that the service and script for the unit disappear.

Documentation changes

None.

Bug reference

https://bugs.launchpad.net/juju/+bug/1860432

Instead of writing each service definition and it's exec-start script
into a service folder in /lib/systemd/system and using dbus (systemd) to
link them into /etc/systemd/system, we write them directly to
/etc/systemd/system.

This change was required to support Focal Fossa (20.04) which has these
two directories on different partitions, causing systemd to fail.

The linking step remains for now, though it effectively does nothing -
the service definitions are in the default search path, so reloading the
systemd daemon should be sufficient to have them loaded.
@manadart manadart changed the title Relocate systemd files 2.7 Relocate Systemd Files Jan 23, 2020
@manadart
Copy link
Member Author

@@ -227,13 +227,7 @@ func (s *systemdServiceManager) WriteSystemdAgents(

// Otherwise we need to manually ensure the service unit links.
svcFileName := svcName + ".service"
if err = os.Symlink(path.Join(systemd.LibSystemdDir, svcName, svcFileName),
Copy link
Member Author

Choose a reason for hiding this comment

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

This method (WriteSystemdAgents) is all at sea. I will refactor it in a forthcoming patch.

Copy link
Member

@SimonRichardson SimonRichardson left a comment

Choose a reason for hiding this comment

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

Nice bit of clean up on the way. More to do obviously, but removing un-needed arguments in the constructor seems like a win win.

The Q&A steps went well, although I should note there is a small issue when using LXD as the provider:

sudo: setrlimit(RLIMIT_CORE): Operation not permitted

We should ping the LXD team to see if there can be anything done with this?

@manadart
Copy link
Member Author

$$merge$$

1 similar comment
@manadart
Copy link
Member Author

$$merge$$

@mitechie
Copy link
Contributor

mitechie commented Jan 23, 2020 via email

@howbazaar
Copy link
Contributor

One thing that was mentioned here was to not bother with an external script at all, but instead have multiple ExecStart lines rather than an external script.

The "install" command is a better way to create the log file with the right permissions and ownership.

I think it would be worthwhile dropping the exec script if we can get all the behaviour into just the service file.

@manadart
Copy link
Member Author

We can look at how we might achieve multi-command ExecStart, but as the commands stand, they use bash-isms that are not supported by the format.
See: https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines

@manadart
Copy link
Member Author

$$merge$$

@jujubot jujubot merged commit e04f31b into juju:2.7 Jan 24, 2020
@manadart manadart deleted the relocate-systemd-files branch January 24, 2020 09:43
jujubot added a commit that referenced this pull request Jan 24, 2020
#11149

### Checklist

 - [x] Checked if it requires a [pylibjuju](https://github.com/juju/python-libjuju) change?
 - [x] Added [integration tests](https://github.com/juju/juju/tree/develop/tests) for the PR?
 - [x] Added or updated [doc.go](https://discourse.jujucharms.com/t/readme-in-packages/451) related to packages changed?
 - [x] Do comments answer the question of why design decisions were made?

----

## Description of change

This patch is a follow-up to #11147 and precedes forthcoming work on accompanying upgrade steps.

It is refactoring only; removing an unused argument and adding various modularisations.

Accompanying mocks are regenerated.

## QA steps

No functional changes. Unit tests pass.

## Documentation changes

None.

## Bug reference

N/A
@babbageclunk babbageclunk mentioned this pull request Jan 26, 2020
4 tasks
jujubot added a commit that referenced this pull request Jan 26, 2020
#11151

### Checklist

 - [x] Checked if it requires a [pylibjuju](https://github.com/juju/python-libjuju) change?
 - [x] Added [integration tests](https://github.com/juju/juju/tree/develop/tests) for the PR?
 - [x] Added or updated [doc.go](https://discourse.jujucharms.com/t/readme-in-packages/451) related to packages changed?
 - [x] Do comments answer the question of why design decisions were made?

----

## Description of change

This pulls the latest changes in the 2.7 branch into develop.
Brings in:
- #11139 from jameinel/2.7-detach-volume-state-changing-1860542
- #11141 from howbazaar/2.7-fix-provisioner-leak
- #11144 from babbageclunk/2.7-fix-destroy-test
- #11137 from ycliuhw/feature/vSphere-disk-resizing
- #11146 from manadart/2.7-provisioner-worker-test
- #11147 from manadart/relocate-systemd-files
- #11150 from manadart/2.7-controller-integration-test
- #11149 from manadart/2.7-systemd-upgrades

(No conflicts when merging.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants