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(editors): enable editors to set file access permissions #24

Merged
merged 3 commits into from
Oct 7, 2024

Conversation

NucciTheBoss
Copy link
Member

This PR expands the capabilities of the dump and edit functions to set file mode, user, and group owner on Slurm configuration files. All the editors use the shared set_file_permissions function under the hood to perform the permissions modification. This functionality is needed to that we can ensure that configuration files are owned by the correct SlurmUser rather than them all being owned by root.

Misc.

Swaps out the tempfile we were creating on disk for the unit tests and replaces it with pyfakefs. This way we don't have to worry about manually cleaning up testing resources with the addition of each new unit test.

Adds the function `set_file_permissions` which is used by the dump function
of the editors to apply file mode, user, and group permissions to supported
configuration files. This makes Slurm happy because then we don't need to default
to root for everything, and can instead use the dedicated SlurmUser.

Signed-off-by: Jason C. Nucciarone <[email protected]>
Also improves coverage of the `editor` module.

Signed-off-by: Jason C. Nucciarone <[email protected]>
Use `pyfakefs` to create a mock Slurm configuration file where we would
expect it to be located on a node. Also helps for testing file permissions
as we don't need to mess with privileges on the host filesystem.

Signed-off-by: Jason C. Nucciarone <[email protected]>
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.

Looks great! I just have a small question

slurmutils/editors/editor.py Show resolved Hide resolved
@NucciTheBoss NucciTheBoss requested a review from jedel1043 October 7, 2024 15:29
@NucciTheBoss
Copy link
Member Author

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

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.

LGTM!

@NucciTheBoss NucciTheBoss merged commit 3ea2755 into charmed-hpc:main Oct 7, 2024
3 checks passed
@NucciTheBoss NucciTheBoss deleted the feat-file-permissions branch October 7, 2024 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Proposes a new feature to be added to the project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants