-
Notifications
You must be signed in to change notification settings - Fork 7
fix: stop SMGC service on SR detach to prevent orphaned systemd units #92
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
base: 3.2.12-8.3
Are you sure you want to change the base?
Conversation
drivers/cleanup.py
Outdated
def stop_gc_service(sr_uuid): | ||
""" | ||
Stops the templated systemd service which runs GC on the given SR UUID. | ||
""" | ||
sr_uuid_esc = sr_uuid.replace("-", "\\x2d") | ||
util.SMlog(f"Stopping SMGC@{sr_uuid}...") | ||
cmd = ["/usr/bin/systemctl", "--quiet", "stop", f"SMGC@{sr_uuid_esc}"] | ||
try: | ||
subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True, check=True) | ||
except subprocess.CalledProcessError as e: | ||
util.SMlog(f"Failed to stop gc service `SMGC@{sr_uuid_esc}`: `{e.stderr.decode().strip()}`") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's cleaner to use util.doexec
and compact the common code with start_gc_service
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 4b1d2d9
f2d41c7
to
4b1d2d9
Compare
drivers/cleanup.py
Outdated
cmd=[ "/usr/bin/systemctl", "--quiet" ] | ||
if extra_args: | ||
cmd.extend(extra_args) | ||
cmd += [action, f"SMGC@{sr_uuid_esc}"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small difference in using arrays with and without spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 95ed874
Before merge, it would be great to open a PR on the upstream side. |
Opened PR on upstream: xapi-project#770 |
23aaeb6
to
3c9feba
Compare
e7801da
to
ca5b52d
Compare
Signed-off-by: Mathieu Labourier <mathieu.labourier@vates.tech>
…doexec instead of subprocess.run Signed-off-by: Mathieu Labourier <mathieu.labourier@vates.tech>
Signed-off-by: Mathieu Labourier <mathieu.labourier@vates.tech>
…to match upstream request Signed-off-by: Mathieu Labourier <mathieu.labourier@vates.tech>
3c9feba
to
e2d8514
Compare
This is not done on every and each implementation of SR but only on ones that calls
cleanup.start_gc_service
(likeFileSR
) and on the classes that inherits from them and don't call super ondetach
(likeCephFSSR
).This is to prevent useless errors logs like
Failed to stop xxx.service: Unit xxx.service not loaded.