Skip to content

common/admin_socket: add a command to raise a signal - #53689

Merged
yuriw merged 2 commits into
ceph:mainfrom
leonid-s-usov:mds-raise
Oct 30, 2023
Merged

yuriw merged 2 commits into
ceph:mainfrom
leonid-s-usov:mds-raise

Conversation

@leonid-s-usov

@leonid-s-usov leonid-s-usov commented Sep 26, 2023 •

Copy link
Copy Markdown
Contributor

The new command "raise [--after X]" accepts signals in the forms: '9', '-9', 'kill', '-KILL'
When --after is specified, the program will fork to wait for the timeout

The forked instance will bail out if it detects that the parent PID has changed which would indicate that the original parent has terminated.

Forking an instance allows to schedule delivery of signals even if the original process is suspended, e.g.:

  ceph tell mds.a raise CONT --after 10
  ceph tell mds.a raise STOP

Fixes: https://tracker.ceph.com/issues/62882

Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

@github-actions github-actions Bot added the cephfs Ceph File System label Sep 26, 2023
@vshankar
vshankar requested a review from a team September 27, 2023 12:35
@vshankar vshankar changed the title mds/MDSDaemon: add an asock command to raise a signal mds/MDSDaemon: add an asok command to raise a signal Sep 27, 2023
@leonid-s-usov

Copy link
Copy Markdown
Contributor Author

jenkins test api

@github-actions github-actions Bot added the common label Oct 2, 2023
@leonid-s-usov leonid-s-usov changed the title mds/MDSDaemon: add an asok command to raise a signal common/admin_socket: add a command to raise a signal Oct 2, 2023

@batrick batrick left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I like it! Some proposed changes:

  • Find a suitable place in docs/ for the new asok command. Note it's available for all Ceph processes (event clients).
  • Note in the ReleaseNotes
  • Add a test. I think a good starting test would be to check that SIGHUP causes the daemons to reopen their log files: first delete the log file then check it's recreated after SIGHUP.

Comment thread src/common/admin_socket.cc Resolved
Comment thread src/common/admin_socket.cc Resolved
Comment thread src/common/admin_socket.cc Resolved
Comment thread src/common/admin_socket.cc Resolved
Comment thread src/common/admin_socket.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You need to wait for the child.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably should add a wait for the pid (WNOHANG) in the poll loop in AdminSocket::entry.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure. That child will be killed anyway, and I'm forking another one. If any race we can't really prevent it fully so why bother?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If you don't wait for the child then you create zombie processes.

@leonid-s-usov leonid-s-usov Oct 8, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed with a note: I decided not to add code to the general admin_socket polling loop. That means we will have at most one zombie child per daemon if this command is used, which I thought was a reasonable tradeoff

Comment thread src/common/admin_socket.cc Resolved
Comment thread src/common/admin_socket.cc Resolved
Comment thread src/common/admin_socket.cc Resolved
Comment thread doc/rados/operations/monitoring.rst Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: add an containerized example where the .asok file is under /var/lib/something

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is an example at line 622

   ceph daemon /var/run/ceph/ceph-osd.0.asok foo

Isn't that sufficient?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Someone running containerized will find nothing under /var/run/ceph

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My plan was to only mention the new command while leaving the rest without modifications. If you'd like to use this as an opportunity to improve the adjacent text, be my guest, but I'd have to ask you to suggest the actual edits. Thanks!

Comment thread doc/rados/operations/monitoring.rst Resolved
Comment thread doc/rados/operations/monitoring.rst Resolved
Comment thread src/common/admin_socket.cc Resolved
Comment thread src/common/admin_socket.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Check errors and dout

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread src/common/admin_socket.cc Resolved
Comment thread src/common/admin_socket.cc Resolved
Comment thread src/common/admin_socket.cc Resolved
Comment thread src/test/admin_socket.cc Resolved
@leonid-s-usov

Copy link
Copy Markdown
Contributor Author

jenkins test api

1 similar comment
@leonid-s-usov

Copy link
Copy Markdown
Contributor Author

jenkins test api

Comment thread src/common/admin_socket.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We use this polling due to the pid check below? Would it not suffice to sleep for the entire duration and then check the pids post the sleep? (pid reuse issue?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wanted to avoid having the forked child pin all that memory beyond the parent's lifetime to only find out about it after the timeout, so this loop was the simplest mitigation I could think of.
The timeout could be arbitrarily large, so some kind of mitigation is required.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Have you considered using prctl w/ PR_SET_PDEATHSIG?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, I didn't know about this one, thanks!
I mean, I suspected there was a more elegant way to handle this case, but again, decided to go with a simpler solution thinking that it would be easier to manage.

For example, this solution you suggested which I liked, is not available on MacOS :/.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We could use the prctl for Linux and fallback to polling for other systems.

@vshankar vshankar Oct 10, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Which means #ifdef conditionals, so, I'm probably fine with using a single solution that works across 🤷

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

right.. i already had to contaminate this code with some WIN32 ifdefs :/ and here I'd really prefer a simple portable solution given that it has no performance or other constraints.

@leonid-s-usov
leonid-s-usov force-pushed the mds-raise branch 4 times, most recently from ef90ba9 to 80bf336 Compare October 11, 2023 09:47
@leonid-s-usov

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@leonid-s-usov

Copy link
Copy Markdown
Contributor Author

jenkins test api

The new command "raise <signal> [--after X]" accepts signals
in the forms: '9', '-9', 'kill', '-KILL'
When --after is specified, the program will fork to wait for the timeout

The forked instance will bail out if it detects that the parent PID has changed
which would indicate that the original parent has terminated.

Forking an instance allows to schedule delivery of signals even if the original
process is suspended, e.g.:

  ceph tell mds.a raise CONT --after 10
  ceph tell mds.a raise STOP

Signed-off-by: Leonid Usov <[email protected]>
Fixes: https://tracker.ceph.com/issues/62882
@leonid-s-usov

Copy link
Copy Markdown
Contributor Author

jenkins test api

@leonid-s-usov

Copy link
Copy Markdown
Contributor Author

@batrick , @vshankar This has finally passed the CI test and is ready for your review


static const std::map<std::string, int> known_signals = {
// the following 6 signals are recognized in windows according to
// https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/raise?view=msvc-170

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i.e. C89 required these signals so windows apparently must support it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants