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

Add support for ulimit flag #291

Merged
merged 11 commits into from
Oct 29, 2024
Merged

Add support for ulimit flag #291

merged 11 commits into from
Oct 29, 2024

Conversation

fpadula
Copy link
Contributor

@fpadula fpadula commented Oct 9, 2024

Hi, this PR adds support for the ulimit flag (https://docs.docker.com/reference/cli/docker/container/run/#ulimit). This flag is useful when running ROS 1 containers in machines with high nofile limits (default in Arch Linux) since not limiting this causes system crashes (please read https://answers.ros.org/question/336963/rosout-high-memory-usage/ for more info).

This PR adds:

  • Ulimit class that extends RockerExtension to add support for the --ulimit flag in Docker
  • Checks for appropriate syntax using regex
  • Descriptive message when using help command and when raising argument type exception (similar to the Volume extension)
  • Basic unit tests

@fpadula fpadula requested a review from tfoote as a code owner October 9, 2024 22:01
Copy link
Collaborator

@tfoote tfoote left a comment

Choose a reason for hiding this comment

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

Thanks for a well written plugin with good coverage. I have one request for the tests to improve the error capture if they fail. Otherwise this looks good to me.

def setUp(self):
self._instance = Ulimit()

def _is_arg_translation_ok(self, mock_cliargs, expected):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for comprehensive tests. Could you change this function to return a tuple of the success and message as a tuple that can then be passed to assertFalse or assertTrue so that the message gets captured in the unit test report not just in the console output.

The return would be (is_ok, message_string)

"""Test single soft limit argument."""
mock_cliargs = ["rtprio=99"]
expected = " --ulimit rtprio=99"
self.assertTrue(self._is_arg_translation_ok(mock_cliargs, expected))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
self.assertTrue(self._is_arg_translation_ok(mock_cliargs, expected))
self.assertTrue(*self._is_arg_translation_ok(mock_cliargs, expected))

With the addition of the tuple return of the helper method this will expand the results into the assertTrue arguments.

@fpadula
Copy link
Contributor Author

fpadula commented Oct 17, 2024

Thanks for a well written plugin with good coverage. I have one request for the tests to improve the error capture if they fail. Otherwise this looks good to me.

Thanks for the feedback! I've addressed the requests on the latest commit.

Copy link
Collaborator

@tfoote tfoote left a comment

Choose a reason for hiding this comment

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

Thanks for the iteration. It looks good to me now.

@tfoote tfoote merged commit cff5cb2 into osrf:main Oct 29, 2024
4 checks passed
@fpadula fpadula deleted the add_ulimit_support branch October 29, 2024 23:16
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.

2 participants