Skip to content

Conversation

@Martin-Rehr
Copy link
Contributor

Changed the lustre quota system from using a cronjob to use the grid daemon setup and thereby align with our existing grid services. This provide a tighter integration with the existing codebase as well as the possibility to extend with other storage quota systems.

export PYTHONPATH=${MIG_PATH}:$PYTHONPATH
fi
# Make sure '/usr/local/(s)bin' is in path and force lookup order
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm, I'm not sure we really want to replace or even tweak PATH in general here ... it could have ugly side effects.
If at all perhaps only add the missing /usr/local/(s)bin paths to any existing PATH and preferably only in the start_quota function if it's only needed there?
The same applies for the deb version of the script.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The advantage of setting the PATH in general is that we control the order.

If we don't wan't to set the full PATH I think we should add /usr/local/(s)bin to the existing PATH in the general case.

from mig.shared.logger import daemon_logger

from pylustrequota.lfs import lfs_set_project_id, lfs_get_project_quota, \
from lustreclient.lfs import lfs_set_project_id, lfs_get_project_quota, \
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is the source of some of the current CI errors. Should it perhaps be conditional like other imports relying on optional extras and only fail if actually ever used?
Something like:

try:
    import XYX as X
except ImportError:
    X = None

then inside function(s) have an

if X is None:
    print("You need module X installed for XYZ")
    exit(1)

Copy link
Contributor Author

@Martin-Rehr Martin-Rehr Nov 27, 2025

Choose a reason for hiding this comment

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

lustreclient.lfs is not optional for mig/lib/lustrequota.py

But we can make a:

try:
   import XYX as X
except ImportError:
   sys.exit(1)

To satisfy the linter

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, mostly a theoretical point as long as we only really support lustre as backend of grid_quota, but if we intend it to act as a generic quota handler, we should avoid it crashing from missing lustre client as soon as it tries to import lib/quota.py - which in turn unconditionally imports from lib/lustrequota.py.
So I guess the import would better be conditional either in quota.py or not fail until used in lustrequota.py to get around that, which would hopefully not just satisfy the linter but also solve practical use e.g. for any other future backends.
While at it perhaps it's worth considering an else clause to fail with a log error if update_quota is called without a valid backend?

# Only take dirs into account
msg = "Skiping non-dir path: %r" % entry.path
DEBUG(configuration, msg, verbose)
logger.debug("Skiping non-dir path: %r" % entry.path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: typo in 'Skipping'

# --- BEGIN_HEADER ---
#
# __init__ - luste quota python extensions
# __init__ - luste client python extension
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: 'lustre' typo

# -- END_HEADER ---
#
"""This package provide luste quota functionality"""
"""This package provide luste client functionality"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: 'lustre' typo

#
# --- BEGIN_HEADER ---
#
# grid_quota - daemon to create storage quota
Copy link
Contributor

Choose a reason for hiding this comment

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

minor suggestion: 'daemon to manage storage quotas' or similar?


if __name__ == "__main__":
print(
"""This is the MiG lustre quota daemon which collect storage quota
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if you want to drop 'lustre' here with the generalization? and nitpicking on it should be 'collects'.

Copy link
Contributor

@jonasbardino jonasbardino left a comment

Choose a reason for hiding this comment

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

Generally looks alright to me.

In line with previous internal discussions in the team I have a few additional remarks in regards to merging especially new code like this:

  1. Github check failures should be addressed before we merge
  2. all new code should have unit tests with decent test coverage to the extent possible.
  3. all new code should be 'style clean'

I commented on the CI error of (1) inline and perhaps the C-extension part needs some lustre header include adjustments to succeed.

We decided to be particularly strict about (2+3) for code in mig/lib/ and sbin/ as outlined on Milestone 7 and Milestone 11 .

Further hints and pointers are summarized on Project Contribution

@Martin-Rehr
Copy link
Contributor Author

Martin-Rehr commented Nov 27, 2025

  1. We don't really wan't to include the lustre headers in the migrid codebase since the header version is bound to the version of lustre installed on the system where migrid is deployed.

  2. Unit tests are not really applicable since they would require a working lustre storage system

@jonasbardino
Copy link
Contributor

  1. We don't really wan't to include the lustre headers in the migrid codebase since the header version is bound to the version of lustre installed on the system where migrid is deployed.

    1. Unit tests are not really applicable since they would require a working lustre storage system
  1. I wonder if we could pull in the headers from the lustre rpm package in the github action like we install other packages, but if not we should probably exclude the lustre client from the c-extension action completely, even if not so nice.
  2. the generic lib/quota.py is small and simple so far but could come with a basic unit test of update_quota already, and be ready for any future extensions. In fact the invalid backend value mentioned in a recent comment could be one thing to unit test there.

@Martin-Rehr
Copy link
Contributor Author

Thanks for the input, I'll try to pull in the headers for 'the github action' and make a unit test for the lib/quota.py

@jonasbardino
Copy link
Contributor

Thanks for the input, I'll try to pull in the headers for 'the github action' and make a unit test for the lib/quota.py

You're welcome, and sounds good 👍
The c-extension checks are defined in .github/workflows/python-c-ext-sanity-check.yml and that is also where we'd want to extend paths-ignore with whatever pattern matches the lustre client source if we can't get the checks running. So feel free to include changes there as part of the PR or separately.

@Martin-Rehr
Copy link
Contributor Author

Thanks for the input, I'll try to pull in the headers for 'the github action' and make a unit test for the lib/quota.py

You're welcome, and sounds good 👍 The c-extension checks are defined in .github/workflows/python-c-ext-sanity-check.yml and that is also where we'd want to extend paths-ignore with whatever pattern matches the lustre client source if we can't get the checks running. So feel free to include changes there as part of the PR or separately.

The paths-ignore isn't enough, as far as I can tell these are trigger ignores, if we wan't to ignore specific C files then we need to filter them out in the run splint like we already filter out non-C files:
git diff --diff-filter=ACMRTB --name-only HEAD^1 -- | grep -E '\.c$' | xargs -r splint ...

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.

3 participants