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

feat(slurm_ops): set correct permissions on files owned by Slurm #40

Merged
merged 6 commits into from
Oct 8, 2024

Conversation

NucciTheBoss
Copy link
Member

This PR enables the slurm_ops lib to correctly set the user, group, and mode on files owned by Slurm. Originally, we had everything owned by root which isn't bad, but it's encourage that files like slurm.conf and jwt_hs256.key are owned by the dedicated system user slurm instead.

The PR adds public user and group properties that (a) be used to retrieve the user and group for configuration options such as SlurmUser and (b) pushes down to the configuration managers so that slurmutils can assign the proper access permissions to the configuration files.

Currently a draft because this PR needs PR charmed-hpc/slurmutils#24 to land since it introduces the mode, user, and group setting features to slurmutils.

Adds logic to create slurmrestd user at install time. slurmrestd
cannot be the SlurmUser or SlurmdUser, so we must create a dedicated
user similar to how the slurmrestd charm currently creates the user + group.

Signed-off-by: Jason C. Nucciarone <[email protected]>
pyfakefs seemingly doesn't work for JWTKeyManager, so we need
to manually mock the user and group for `shutil`. Just sets
the user and group to the current user and group running the unit tests.

Signed-off-by: Jason C. Nucciarone <[email protected]>
Apply formatting to the TODO messages so that they render
nicely within tool windows such as PyCharm's TODO widget. Easy
to quickly browse through outstanding items we want to tackle.

Signed-off-by: Jason C. Nucciarone <[email protected]>
@NucciTheBoss
Copy link
Member Author

NucciTheBoss commented Oct 6, 2024

Unit tests are expected to fail because setting config file permissions with slurmutils is not upstreamed yet.

@NucciTheBoss NucciTheBoss requested a review from jedel1043 October 7, 2024 13:48
…g files

Changes:

- Adds onto `test_config` tests to check the file mode, user, and group of file.
- Fake the user and group by reassigning the `_user` and `_group` to the uid and gid of the user running the tests.
- Redefines constants at the top of the test module so they can be easily found.

Signed-off-by: Jason C. Nucciarone <[email protected]>
@NucciTheBoss
Copy link
Member Author

I know the problem here. Slurm snap doesn't create a slurm user or group so the config editors are geeking out. Brewing up a patch to the integration tests that will fix this issue.

The Slurm snap currently does not create a Slurm system user, so the integration
tests needs an additional step to add both the slurm group and user. This is
something that should be patched in the Slurm snap when the team revisits the
snap package.

Signed-off-by: Jason C. Nucciarone <[email protected]>
@NucciTheBoss NucciTheBoss marked this pull request as ready for review October 8, 2024 14:02
@NucciTheBoss
Copy link
Member Author

@jedel1043 R4R 🔍

@NucciTheBoss NucciTheBoss added the enhancement New feature or request label Oct 8, 2024
Copy link
Contributor

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

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

Small question that I have about adduser. Looks great!

lib/charms/hpc_libs/v0/slurm_ops.py Show resolved Hide resolved
@NucciTheBoss
Copy link
Member Author

@jedel1043 please sir, might I have another review 🥺👉👈

@NucciTheBoss NucciTheBoss requested a review from jedel1043 October 8, 2024 19:40
Copy link
Contributor

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

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

Preemptively approving this, since the discussion in the comment is mostly personal preference IMO.

@NucciTheBoss NucciTheBoss merged commit e53f6a3 into charmed-hpc:main Oct 8, 2024
4 checks passed
@NucciTheBoss NucciTheBoss deleted the feat-slurm-users branch October 8, 2024 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants