Repository navigation
cephadm: add support for sidecar containers - #54722
Merged
Merged
Conversation
phlogistonjohn
force-pushed
the
jjm-cephadm-sidecars
branch
from
December 1, 2023 12:56
dcd075e to
9bc6764
Compare
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
phlogistonjohn
force-pushed
the
jjm-cephadm-sidecars
branch
from
December 4, 2023 15:13
9bc6764 to
6216a11
Compare
4 of 15 tasks
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
4 of 14 tasks
phlogistonjohn
force-pushed
the
jjm-cephadm-sidecars
branch
from
December 11, 2023 20:49
6216a11 to
9e4481d
Compare
phlogistonjohn
force-pushed
the
jjm-cephadm-sidecars
branch
2 times, most recently
from
December 14, 2023 20:01
16d2feb to
6457d97
Compare
phlogistonjohn
marked this pull request as ready for review
December 14, 2023 20:02
phlogistonjohn
force-pushed
the
jjm-cephadm-sidecars
branch
from
December 19, 2023 19:04
6457d97 to
90c7786
Compare
Contributor
Author
|
Updated to disable |
There are a bunch of places in the code that wants the full systemd service name but the code generally is just doing string concatenation. Add a method to avoid stringing it all the time. This will help as there will be more systemd work in the future. Signed-off-by: John Mulligan <[email protected]>
Use the new service_name method of the DaemonIdentity type in some basic cases where string concatenation was being used. I also converted the name of the agent's helper method to match and made it private to avoid future confusion. Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Add a method for duplicating the container properties into a new object. Signed-off-by: John Mulligan <[email protected]>
Add a new type representing sidecar containers. Signed-off-by: John Mulligan <[email protected]>
Add a `must` method that ensures a DaemonIdentity is a DaemonSubIdentity in a single call. Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Do not have data dir depend on the daemon_name property. This property is overriden by the subclass(es) but we want DaemonIdentities and DaemonSubIdentities to share the same data_dir. Signed-off-by: John Mulligan <[email protected]>
Add templates that will be used for advanced systemd services: sidecars, init containers, and drop-in files to glue them all together. Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Convert the call that writes out files for a daemon to use the new dedicated systemd-unit support for init containers. Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Add support for producing sidecar containers to the container daemon form type and pass the sidecars through to the unit/script management function. Signed-off-by: John Mulligan <[email protected]>
Convert the iscsi container daemon form class to produce a sidecar container for the tcmu runner and reduce the amount of special casing for iscsi. Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Rename get_unit_name_by_daemon_name to lookup__unit_name_by_daemon_name to emphasize that the function does a full lookup (via the daemon list) to determine the systemd service name for the given values and that there's a potential performance implication to doing that. Signed-off-by: John Mulligan <[email protected]>
Add the unlink_file function to file_utils. This fills in a gap between python 3.6 and features provided in pathlib.Path in later versions of python. Adds an option to ignore all errors for good measure. Signed-off-by: John Mulligan <[email protected]>
This will become handy later when we need DaemonSubIdentity objects and are not on the deploy path. Signed-off-by: John Mulligan <[email protected]>
Add a sidecars_from_dropin function that takes a minimal PathInfo object and returns a PathInfo populated with sidecars information based on reading the content of the dropin file. This will be useful when we need information on configured sidecars but are not on the deploy path. Signed-off-by: John Mulligan <[email protected]>
Add a function that encapsulates the common 3-step process found in cephadm of stopping, resetting errors, and disabling a service. This will be used to handle new services to stop as well as cleaning up some places where the three steps are performed inline. Signed-off-by: John Mulligan <[email protected]>
Make a few small chanes to command_rm_daemon to clean it up in preparation for future changes. Move the construction of a DaemonIdentity earlier and use the service name derived directly from it if possible. I didn't remove the old approach of looking up a service name in the listing because I don't know if doing so would break old/adopted services and there's no unit test coverage for that. Signed-off-by: John Mulligan <[email protected]>
This should be a little cleaner, perhaps a tiny performance improvement, and most importantly work better with the virtual-fs provided for the unit tests and make this function more testable in the future. Signed-off-by: John Mulligan <[email protected]>
Add support to the command_rm_daemon function to remove systemd services and corresponding unit files for any sidecars or init-containers associated with a primary daemon. Signed-off-by: John Mulligan <[email protected]>
The terminate_service function was added to encapsulate the act of terminating a systemd service. The rm-deamon handler was updated to use this function previously; this commit updates rm-cluster function(s) to do the same. This needed a bunch of test updates do to how the tests were mocking commands. Signed-off-by: John Mulligan <[email protected]>
A previous patch updated the rm-daemon functionality to remove sidecar and init-container systemd services. This patch does the same for the rm-cluster codepath. Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Remove a line from _rm_cluster that has no effect. The line uses
call_throws to execute an `rm -rf` command. The argument contains
asterisk chars that indicate that the file(s)/dir(s) to be created are
expected to match the given pattern. However, globs do not work in this
context in contemporary versions of cephadm.
To double check I added the following temporary unit test:
```
def test_does_it_glob(tmp_path):
from cephadmlib.call_wrappers import call_throws
d1 = (tmp_path / 'dir1')
d1.mkdir()
fns = ['f1.txt', 'f2.txt', 'f3.txt', 'f4']
for fn in fns:
with open(d1/fn, "w") as fh:
fh.write("xxx")
assert d1.exists()
for fn in fns:
assert (d1 / fn).exists()
ctx = FakeContext()
call_throws(ctx, ['rm', '-rf', f'{d1}/*.txt'])
print('files:', os.listdir(d1))
assert d1.exists()
for fn in fns:
if fn.endswith('.txt'):
assert not (d1 / fn).exists()
else:
assert (d1 / fn).exists()
```
If globs worked in this context this test would have passed. It does
not. I confirmed that the current implementation of call/call_wrapper
does not execute the command in a shell context.
I wondered if it was possible that an earlier version of cephadm did
execute this command in a shell context and some changes along the way
changed the behavior. I tracked the origin of the line back to
16ebc62 the first change to implement
rm-cluster. In this commit the code uses subprocess.check_output
directly. I am familiar with check_output and unless `shell=True` is
passed this function doesn't execute the args in a shell context. The
`shell=True` argument is not passed to check_output. This means that the
very first implementation of this line suffered from the same issue
- it would have no effect on any files except one named with actual
asterisk (`*`) characters.
While I'm sure there was a good intention behind this line, the fact
that it persisted in the code so long in a non-functional state and no
one noticed in both production and qa testing makes me feel that it can
be safely removed with no negative effect. Removing the line simplifies
the code and avoids needing to spend effort unit-testing or manually
checking a fix.
Signed-off-by: John Mulligan <[email protected]>
Convert a bunch of invocations of rm via a subprocess to function calls. This should make it easier (or possible?) to test the function in the unit test framework as well as possibly saving a few resources. Signed-off-by: John Mulligan <[email protected]>
Move the generation of the init container run script to a small function fixing a missing `set -e` along the way. This isolates the logic of generating this run script. Signed-off-by: John Mulligan <[email protected]>
Convert the init containers run script to be based on a template, like the sidecar run scripts are. The new script is loosely based on the sidecars run script but only does actions in batches - logically iterating over each init container configured. Signed-off-by: John Mulligan <[email protected]>
Now that there is a more robust init_containers.run script, we can use the new stop and poststop subcommands from the systemd unit. Signed-off-by: John Mulligan <[email protected]>
Disable the Restart= line in the init containers systemd template. It is commented out as there are probably more appropriate workarounds to use in the future but this should fix testing on centos8 based systems. Signed-off-by: John Mulligan <[email protected]>
phlogistonjohn
force-pushed
the
jjm-cephadm-sidecars
branch
from
January 2, 2024 14:30
39dbecd to
aaffa66
Compare
adk3798
approved these changes
Jan 3, 2024
Signed-off-by: John Mulligan <[email protected]>
Contributor
|
reruns of failed/dead jobs: https://pulpito.ceph.com/adking-2024-01-03_10:25:36-orch:cephadm-wip-adk-testing-2024-01-02-0614-distro-default-smithi/ After reruns: 3 failed/dead jobs:
Overall, nothing to block merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #54536
Add the initial support for creating sidecar containers. Sidecar containers are tightly coupled with a primary service container. This PR only adds the ability to create and delete sidecars via systemd service unit files. As part of the work updating systemd integration to use additional services the init containers are moved into a dedicated systemd service. The
cephadm lsoutput and the mgr are ignorant of sidecars and init containers.The iscsi service had a special care where the tcmu runner container was started as part of the unit.run file in the background. This has been converted to a sidecar container. The lack of insight into the sidecars should be no worse than before as the tcmu runner container was largely "invsible" to systemd & the mgr before this change.
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
opened tracker ticketShow available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test dashboard cephadmjenkins test apijenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume toxjenkins test windowsjenkins test rook e2e